-
Notifications
You must be signed in to change notification settings - Fork 62
/
run.sh
92 lines (76 loc) · 1.84 KB
/
run.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
#!/bin/bash
########################################################################
script_dir=$(dirname "${BASH_SOURCE:?}")
########################################################################
FILE_LAST_RUN="${script_dir:?}/.run_last"
RUN=
PASS=
########################################################################
if [[ -f "${FILE_LAST_RUN}" ]]; then
LAST_RUN=$(<"${FILE_LAST_RUN:?}")
case "${LAST_RUN}" in
"install")
RUN="setup"
;;
"setup")
RUN="update"
;;
"update")
RUN="update"
;;
*)
RUN="install"
;;
esac
else
RUN="install"
fi
########################################################################
if ! [[ -z "${1}" ]]; then
RUN="${1:?}"
fi
########################################################################
case "${RUN}" in
"install")
PASS="p0"
;;
"setup")
PASS="p1"
;;
"update")
PASS="p2"
;;
*)
;;
esac
########################################################################
echo "Available actions:"
echo
echo "'install'"
echo " This will run script 'p0-install'"
echo " to install required packages"
echo
echo "'setup'"
echo " This will run script 'p1-setup'"
echo " to setup / configure services"
echo
echo "'update'"
echo " This will run script 'p2-update'"
echo " to download and mount images"
echo " or unmount and remove images"
echo " and update menue items"
echo
echo "Automatic next action will be '${RUN}'"
echo
read -p "Do you want to continue with: '${RUN}' [y|N]? " CHOICE
echo
case "${CHOICE}" in
Y|y) ;;
*) echo "To override automatic action, you can give the script 'run.sh' one of the above actions"
exit 1
;;
esac
########################################################################
. "${script_dir:?}/${PASS:?}-${RUN:?}"
########################################################################
echo "${RUN:?}" > "${FILE_LAST_RUN:?}"