@@ -5,37 +5,39 @@ set -o pipefail
55
66mkdir -p data
77
8+ function txt {
9+ case " $1 " in
10+ bold) tput bold 2> /dev/null ;;
11+ reset) tput sgr0 2> /dev/null ;;
12+ red) tput setaf 1 2> /dev/null ;;
13+ green) tput setaf 2 2> /dev/null ;;
14+ yellow) tput setaf 3 2> /dev/null ;;
15+ esac
16+ }
17+
818function txt_bold {
9- tput bold 2> /dev/null
19+ txt bold
1020}
1121
1222function txt_reset {
13- tput sgr0 2> /dev/null
23+ txt reset
1424}
1525
1626function txt_red {
17- tput setaf 1 2> /dev/null
27+ txt red
1828}
1929
2030function txt_green {
21- tput setaf 2 2> /dev/null
31+ txt green
2232}
2333
2434function txt_yellow {
25- tput setaf 3 2> /dev/null
26- }
27-
28- function info {
29- echo " $( txt_bold) $( txt_green) [+] $* $( txt_reset) "
35+ txt yellow
3036}
3137
32- function error {
33- echo " $( txt_bold) $( txt_red) [!] $* $( txt_reset) "
34- }
35-
36- function warning {
37- echo " $( txt_bold) $( txt_yellow) [!] $* $( txt_reset) "
38- }
38+ function info { echo " $( txt bold) $( txt green) [+] $* $( txt reset) " ; }
39+ function error { echo " $( txt bold) $( txt red) [!] $* $( txt reset) " ; }
40+ function warning { echo " $( txt bold) $( txt yellow) [!] $* $( txt reset) " ; }
3941
4042function execute_cmd {
4143 info " * $* "
@@ -45,65 +47,64 @@ function execute_cmd {
4547function usage {
4648cat << EOF
4749Usage:
48- $0 <Command > [OPTIONS...]
50+ $0 <command > [OPTIONS...]
4951
5052Commands:
51- build
52- Build and pull all images including the docker based image.
53- update
54- Update the repository and all submodules.
55-
56- up
57- Start all serviceses.
58- --debug
59- Enables debug mode. This causes exception to be printed
60- on the webinterface. Use this only for development.
61- --debug-toolbar
62- Enable the debug toolbar. This should never be enabled in
63- production (not even in the maintenance mode).
64- --maintenance
65- Only allow admin users to login.
66- --disable-telegram
67- Disable error reporting via telegram.
68- --hot-reloading
69- Enable hot reloading of the server if any file expect .html, .js or .sh
70- is changed in tree.
71-
72- stop
73- Stop all services without removing the associated containers.
74-
75- ps
76- List all running containers.
77-
78- top
79- List all processes running inside the containers.
80-
81- restart-web
82- Only restart the webinterface without the other services, thus
83- user get not disconnected since the SSH server is left untouched.
84- This command can be used to reload changes applied to the webinterface.
85-
86- restart
87- Restart all services. This will disconnect currently connected users.
88-
89- down
90- Stop and delete all services and networks. This operation disconnects all users
91- and orphans all currently running instances since the network connecting them
92- with the ssh entry server is deleted. Consequently, all instances must be recreated
93- on demand when a user first connects. In general this command is only needed if
94- changes where applied to the container composition itself.
95-
96- logs
97- Print the logs of all services on stdout.
98- -f
99- Follow to the log output and print incoming messages.
100-
101- flask-cmd
102- Run a flask CLI command, e.g.,
103- flask-cmd db init
104- flask-cmd db migrate
105- flask-cmd db upgrade
106- ...
53+ build
54+ Build and pull all images, including the docker base image.
55+
56+ update
57+ Update the repository and all submodules.
58+
59+ up [OPTIONS...]
60+ Start all services.
61+ Options:
62+ --debug Enable debug mode (prints exceptions on web interface).
63+ --debug-toolbar Enable the debug toolbar (never use in production).
64+ --maintenance Only allow admin users to login.
65+ --disable-telegram Disable error reporting via telegram.
66+ --hot-reloading Enable hot reloading of the server (except .html, .js, .sh files).
67+
68+ down
69+ Stop and delete all services and networks. Disconnects all users and orphans running instances.
70+
71+ stop
72+ Stop all services without removing the associated containers.
73+
74+ restart
75+ Restart all services (disconnects currently connected users).
76+
77+ restart-web
78+ Restart only the web interface (users stay connected via SSH).
79+
80+ ps
81+ List all running containers.
82+
83+ top
84+ List all processes running inside the containers.
85+
86+ logs [-f]
87+ Print the logs of all services.
88+ -f Follow log output and print incoming messages.
89+
90+ flask-cmd <args>
91+ Run a Flask CLI command, e.g.:
92+ flask-cmd db init
93+ flask-cmd db migrate
94+ flask-cmd db upgrade
95+
96+ db-migrate
97+ Run Flask database migration.
98+
99+ db-init
100+ Initialize the Flask database.
101+
102+ db-upgrade
103+ Upgrade the Flask database.
104+
105+ --help
106+ Show this help message and exit.
107+
107108EOF
108109}
109110
@@ -412,13 +413,8 @@ function flask-cmd {
412413}
413414
414415function are_you_sure {
415- info " Are you sure? [y/n]"
416- read yes_no
417- if [[ " $yes_no " == " y" ]]; then
418- return 0
419- else
420- return 1
421- fi
416+ read -r -p " $( txt bold) $( txt green) Are you sure? [y/N] $( txt reset) " yes_no
417+ [[ " $yes_no " =~ ^[Yy]$ ]]
422418}
423419
424420cmd=" $1 "
@@ -471,15 +467,6 @@ case "$cmd" in
471467 db-upgrade)
472468 db_upgrade " $@ "
473469 ;;
474- run-tests)
475- run_tests " $@ "
476- ;;
477- up-testing)
478- up_testing " $@ "
479- ;;
480- down-testing)
481- down_testing " $@ "
482- ;;
483470 --help)
484471 usage
485472 exit 0
0 commit comments