-
Notifications
You must be signed in to change notification settings - Fork 14
/
autosetup.sh
102 lines (87 loc) · 2.5 KB
/
autosetup.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
#!/bin/bash
#
# skip menu - use "autosetup" file
#
# (c) 2008-2016, Hetzner Online GmbH
#
# read global variables and functions
# shellcheck disable=SC1091
. /tmp/install.vars
# check if the script is temporary disabled due some maintenance or something
debug "# checking if the script is disabled"
if [ -f "$DISABLEDFILE" ]; then
debug "=> script is DISABLED"
echo_red "Due to maintenance the installimage-script is temporarily unavailable.\\nWe are sorry for the inconvenience."
exit 1
fi
# display information about autosetup
echo ""
echo -e "\\033[01;32mFound AUTOSETUP file '$AUTOSETUPCONFIG'\\033[00m"
echo -e "\\033[01;33mRunning unattended installimage installation ...\\033[00m"
echo ""
grep -v "^#" "$FOLD/install.conf" | grep -v "^$"
echo ""
echo ""
# validate config
VALIDATED="false"
CANCELLED="false"
while [ "$VALIDATED" = "false" ]; do
debug "# validating config ..."
validate_vars "$FOLD/install.conf"; EXITCODE=$?
if [ "$CANCELLED" = "true" ]; then
echo "Cancelled."
exit 1
fi
if [ $EXITCODE = 0 ]; then
VALIDATED="true"
else
debug "=> FAILED"
mcedit "$FOLD/install.conf"
fi
done
# if we are using the config file option "-c" and not using the automatic mode,
# ask for confirmation before continuing ...
if [ "$OPT_CONFIGFILE" ] && [ -z "$OPT_AUTOMODE" ] ; then
echo -n ""
echo -e "${RED}ALL DATA ON THE GIVEN DISKS WILL BE DESTROYED!"
echo ""
echo -e -n "${YELLOW}DO YOU REALLY WANT TO CONTINUE?${NOCOL} [y|N] "
read -r -n1 aw
case "$aw" in
y|Y|j|J) echo -e "\\n\\n" ;;
*) echo -e "\\n\\n${GREEN}ABORT${NOCOL}\\n" ; exit 0 ;;
esac
fi
# execute installfile
if [ "$SLEEP_BEFORE_START" -gt 0 ]; then
echo -e "\\033[01;31mWARNING:"
echo -e "\\033[01;33m Starting installation in $SLEEP_BEFORE_START seconds ..."
echo -e "\\033[01;33m Press X to continue immediately ...\\033[00m"
echo -e "\\033[01;31m Installation will DELETE ALL DATA ON DISK(s)!"
echo -e "\\033[01;33m Press CTRL-C to abort now!\\033[00m"
echo -n " => "
for ((i=0; i<=SLEEP_BEFORE_START; i++)); do
echo -n "."
read -r -t1 -n1 anykey
if [ "$anykey" = "x" ] || [ "$anykey" = "X" ]; then
break
fi
done
echo ""
fi
#
debug "# executing installfile ..."
if [ -f "$INSTALLFILE" ] && [ "$VALIDATED" = "true" ] ; then
# shellcheck disable=SC1090,SC1091
. "$INSTALLFILE"
declare -i EXITCODE="$?"
else
debug "=> FAILED"
echo ""
echo -e "\\033[01;31mERROR: Cant find files\\033[00m"
fi
# abort on error
if [ "$EXITCODE" = "1" ]; then
exit 1
fi
# vim: ai:ts=2:sw=2:et