-
Notifications
You must be signed in to change notification settings - Fork 4
/
cli.sh
executable file
·82 lines (65 loc) · 2.52 KB
/
cli.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
current_directory=${PWD##*/}
set_vm_ip () {
if [[ $HUB_VM ]]; then
echo "A default $(gum style --foreground 212 "public ip") has been previously set up. Do you wish to $(gum style --foreground 212 "reuse") it?"
USE_DEFAULT=$(gum choose --limit 1 "yes" "no")
if [ "$USE_DEFAULT" == "yes" ]; then
VM_IP=$HUB_VM
return
fi
fi
echo "What's the $(gum style --foreground 212 "user") of the $(gum style --foreground 212 "Virtual Machine") (in most cases it's $(gum style --foreground 212 "root")):"
read USER
echo "What's the $(gum style --foreground 212 "public ip") of the $(gum style --foreground 212 "Virtual Machine"):"
read IP
VM_IP="$USER@$IP"
echo "Would you like to remember the $(gum style --foreground 212 "Virtual Machine")?"
USE_DEFAULT=$(gum choose --limit 1 "yes" "no")
if [ $USE_DEFAULT == "yes" ]; then
echo "export HUB_VM=\"$VM_IP\"" >> ~/.bashrc
fi
}
if [[ $current_directory != "spa-website-2022" && $current_directory != "monolith" ]]
then
echo "Run this script from the root of the monolith"
exit 1
fi
if ! hash gum &> /dev/null
then
echo "GUM could not be found, running installation script"
make install-gum
fi
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Hello, there! Welcome to The Hub's $(gum style --foreground 212 'monolith')."
echo -e "What instance do you want to spin up?"
WEB_CLIENT="React frontend"
LOCAL_PY_API="Python backend"
LOCAL_QUESTIONNAIRE="Questionnaire"
LOCAL_RUST_API="URL Shortener"
EMAIL_TEMPLATE="Email Template"
ACTIONS=$(gum choose --limit 1 "$WEB_CLIENT" "$LOCAL_PY_API" "$LOCAL_RUST_API" "$LOCAL_QUESTIONNAIRE" "$EMAIL_TEMPLATE")
ACTIONS_EXIT_STATUS=$?
clear
if [ $ACTIONS_EXIT_STATUS -eq 0 ]; then
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "You might need to pull the latest dependencies if the service is unable to start."
fi
if [ "$ACTIONS" == "$WEB_CLIENT" ]; then
make run-web
elif [ "$ACTIONS" == "$LOCAL_PY_API" ]; then
make run-py-api
elif [ "$ACTIONS" == "$LOCAL_QUESTIONNAIRE" ]; then
make run-svelte-quest
elif [ "$ACTIONS" == "$LOCAL_RUST_API" ]; then
make run-rust-api
elif [ "$ACTIONS" == "$NGINX" ]; then
make run-nginx
elif [ "$ACTIONS" == "$EMAIL_TEMPLATE" ]; then
make run-email-template
else
echo "Invalid option"
exit 1
fi
if [ -z $HUB_VM ] && [ $VM_IP ]; then
echo "Saving the $(gum style --foreground 212 "Virtual Machine")..."
exec $SHELL
fi