-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.sh
104 lines (87 loc) · 4.38 KB
/
controller.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# backup error handler
set -e
function banner() {
clear
echo " "
echo -e "\e[1;31m ██████╗ ██████╗ ██████╗ ██╗ ███████╗██╗███████╗██████╗ ██████╗ █████╗ \e[1;0m"
echo -e "\e[1;31m ██╔══██╗██╔══██╗██╔═══██╗ ██║ ██╔════╝██║██╔════╝██╔══██╗██╔══██╗██╔══██╗ \e[1;0m"
echo -e "\e[1;31m ██████╔╝██████╔╝██║ ██║ ██║ ███████╗██║█████╗ ██████╔╝██████╔╝███████║ \e[1;0m"
echo -e "\e[1;31m ██╔═══╝ ██╔══██╗██║ ██║██ ██║ ╚════██║██║██╔══╝ ██╔══██╗██╔══██╗██╔══██║ \e[1;0m"
echo -e "\e[1;31m ██║ ██║ ██║╚██████╔╝╚█████╔╝██╗ ███████║██║███████╗██║ ██║██║ ██║██║ ██║ \e[1;0m"
echo -e "\e[1;31m ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚════╝ ╚═╝ ╚══════╝╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ \e[1;0m"
echo ""
echo -e "\n *Please Note: This is a beta version of the script. It is still under development. "
echo ""
echo -e "
+----------------------------------+--------------+------------------------------+
| \e[1;34mCommand\e[1;0m | \e[1;34mShortCut\e[1;0m | \e[1;34m Description\e[1;0m |
+----------------------------------+--------------+------------------------------+
| \e[1;32m Update \e[1;0m | \e[1;35m u \e[1;0m | \e[1;36m Update the GitHub Code\e[1;0m |
| \e[1;32m Start \e[1;0m | \e[1;35m s \e[1;0m | \e[1;36m Start the Project\e[1;0m |
| \e[1;32m Restart \e[1;0m | \e[1;35m r \e[1;0m | \e[1;36m Restart the Project \e[1;0m |
| \e[1;32m Monitor \e[1;0m | \e[1;35m m \e[1;0m | \e[1;36m Open Project Monitor \e[1;0m |
| \e[1;32m Quit \e[1;0m | \e[1;35m q \e[1;0m | \e[1;36m Exit the menu \e[1;0m |
+----------------------------------+--------------+------------------------------+
"
}
function update() {
echo -e "\e[1;32mUpdating the GitHub Code\e[1;0m"
{
git pull
git add .
git commit -m "Update"
git push
echo -e "\e[1;32mUpdate Complete\e[1;0m"
} || {
echo -e "\e[1;31mError: Please make sure you have installed the dependencies\e[1;0m"
exit -1
}
}
function start() {
echo -e "\e[1;32mStarting the Project\e[1;0m"
{
clear && npm start
echo -e "\e[1;32mProject Started\e[1;0m"
} || {
clear && npm build && npm start
echo -e "\e[1;32mProject Started\e[1;0m"
}
}
function restart() {
echo -e "\e[1;32mRestarting the Project\e[1;0m"
{ # Try
clear && npm restart
echo -e "\e[1;32mProject Restarted\e[1;0m"
} || {
echo -e "\e[1;31mError: Please make sure you have installed the dependencies\e[1;0m"
exit -1
}
}
function monitor() {
echo -e "\e[1;32mMonitoring the Project\e[1;0m"
{ # Try
clear && npx pm2 monit
} || {
echo -e "\e[1;31mError: Please make sure you have installed the dependencies\e[1;0m"
exit -1
}
}
function main() {
banner
read -p "Enter command choice: " choice
while [ "$choice" != "q" ]
do
case $choice in
u|update) update ;;
s|start) start ;;
r|restart) restart ;;
m|monitor) monitor ;;
q|quit) exit 0 ;;
*) echo -e "\e[1;31mInvalid option\e[1;0m" ;;
esac
banner
read -p "Enter command choice: " choice
done
}
main