-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.sh
executable file
·201 lines (170 loc) · 5.71 KB
/
ui.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
# ======================================================================================================
# Deployment any (local or prod) instance
# ======================================================================================================
# =============================================
# Checking location is the script folder
# =============================================
BASEDIR=$(readlink -f "$0")
BASEDIR=$(dirname "$BASEDIR")
#if [[ $BASEDIR != *"scripts/deployment" ]]; then
# echo "Wrong script directory!"
# echo $BASEDIR
# exit
#fi
# =============================================
# generate system.sh by parsing template ...
# =============================================
if [ "$1" != "-n" ]; then
php artisan deploy-env:update-bash || exit
fi
# =============================================
# Preparing ...
# =============================================
PROJECTDIR="$BASEDIR/bash-scripts"
# =============================================
# Read default values ...
# =============================================
. "$PROJECTDIR/env/system.default.sh"
# =============================================
# Read config ...
# =============================================
. "$PROJECTDIR/env/system.sh"
# =============================================
# include functions we need ...
# =============================================
. "$PROJECTDIR/functions/output.sh"
. "$PROJECTDIR/functions/confirmation.sh"
. "$PROJECTDIR/functions/mysql.sh"
. "$PROJECTDIR/functions/env.sh" || exit
. "$PROJECTDIR/functions/maintenance.sh"
# =============================================
# calculate variables depends on config
# =============================================
fullModulePath="$destination_mercy_root_path/$mercyModuleDirectory"
# =============================================
# Check settings ...
# =============================================
#f_output_info "Checking system basic settings ..."
f_env_check_system_basics
if [ $? -eq 0 ]; then
f_output_success "Basic settings ok."
else
exit
fi
#f_output_info "Checking location settings ..."
f_env_check_mercy_location
if [ $? -eq 0 ]; then
f_output_success "Location ok."
else
exit
fi
#f_output_info "Checking DB settings ..."
f_env_check_db_settings
if [ $? -eq 0 ]; then
f_output_success "DB settings ok."
else
exit
fi
f_env_check_mercy_deploy_mode_developer
mercy_deploy_mode_developer=$?
if [ $mercy_deploy_mode_developer -eq 0 ]; then
mercy_deploy_mode="DEVELOPER (local,dev,dusk-testing)"
deploy_env_option="--dev-mode"
else
mercy_deploy_mode="PRODUCTION (composer --no-dev)"
deploy_env_option=""
fi
# =============================================
# Ask
# =============================================
# ask to run
#f_confirmation_mercy_root_settings "Start UI for $mercy_deploy_mode ..."
#[ ! $? -eq 0 ] && { exit 1; } # return not 0 = error and exit
# =============================================
# UI
# =============================================
function f_show_ui() {
f_output_info "Press any key to show menu (clear screen) ..."
read -s -N 1 SELECT
clear
f_output_system_info "Jumble Sale Menu"
f_output_info "[c] Clear Cache"
f_output_info "[b] Build Frontend (incl. Caches)"
f_output_info "[u] System Update (deployment/run.sh)"
f_output_info " - git update app"
f_output_info " - git update modules SystemBase, DeployEnv"
f_output_info " - require-dependencies : Updating Modules, Themes, Composer, Frontend, Caches"
f_output_info "[e] (extern) System Update (deployment/run-extern.sh)"
f_output_info " - git update app"
f_output_info " - git update all modules in /Modules"
f_output_info " - composer dump-autoload"
f_output_info " - composer update"
f_output_info "[p] Git pull main app only"
f_output_info "[i] ide-helper generate (facades,models,meta)"
f_output_info "[t] show last log (using less, press 'ctrl+c', 'q' to exit)"
f_output_info "[q] Quit"
f_output_line_separator
# f_confirmation_ask_key "Press key: "
# return $?
}
#
cd "$destination_mercy_root_path" || exit
SELECT=""
# prevent parsing of the input line
IFS=''
#while [[ "$SELECT" != $'\x0a' && "$SELECT" != $'\x20' ]]; do
# echo "Select session type:"
# echo "Press <Enter> to do foo"
# echo "Press <Space> to do bar"
# read -s -N 1 SELECT
# echo "Debug/$SELECT/${#SELECT}"
# [[ "$SELECT" == $'\x0a' ]] && echo "enter" # do foo
# [[ "$SELECT" == $'\x20' ]] && echo "space" # do bar
#done
while [ true ]; do
f_show_ui
read -s -N 1 SELECT
if [[ "$SELECT" == $'q' ]]; then
f_output_info "Quit ..."
exit 1
fi
if [[ "$SELECT" == $'c' ]]; then
f_output_info "Clearing Caches ..."
php artisan deploy-env:cc || exit
fi
if [[ "$SELECT" == $'b' ]]; then
f_output_info "Lets Build Frontend ..."
php artisan deploy-env:build-frontend || exit
fi
if [[ "$SELECT" == $'p' ]]; then
f_output_info "Starting Git Pull ..."
git pull || exit
fi
if [[ "$SELECT" == $'u' ]]; then
f_output_info "Starting deployment run ..."
cd bash-scripts/scripts/deployment || exit
./run.sh || exit
cd "$destination_mercy_root_path" || exit
fi
if [[ "$SELECT" == $'e' ]]; then
f_output_info "Starting extern deployment ..."
cd bash-scripts/scripts/deployment || exit
./run-extern.sh || exit
cd "$destination_mercy_root_path" || exit
fi
if [[ "$SELECT" == $'i' ]]; then
f_output_info "Starting ide-helper ..."
php artisan clear-compiled || exit
php artisan ide-helper:generate || exit
php artisan ide-helper:models -M || exit
php artisan ide-helper:meta || exit
fi
if [[ "$SELECT" == $'t' ]]; then
f_output_info "Starting tail ..."
logsDir="storage/logs"
tmp=$(ls "$logsDir" -t1 | head -n 1)
echo "Showing $tmp:"
less +F "$logsDir/$tmp"
fi
done