-
Notifications
You must be signed in to change notification settings - Fork 141
/
autosetup.sh
111 lines (96 loc) · 2.67 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
103
104
105
106
107
108
109
110
111
#!/bin/bash
#
# skip menu - use "autosetup" file
#
# (c) 2008-2022, Hetzner Online GmbH
#
# read global variables and functions
. /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 -en "${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
# warn about unsupported image
warn=""
if other_image "$IMAGE" || [[ "$PROXMOX" == true ]]; then
warn="$(other_image_warning)"
elif old_image "$IMAGE"; then
warn="$(old_image_warning)"
fi
if [[ -n "$warn" ]]; then
debug "WARNING: $(tr "\n" ' ' <<< "$warn")"
echo -e "\e[1;31mWARNING:"
echo -e "\e[1;33m$(sed 's/^/ /' <<< "$warn")\e[0m\n"
fi
warn=""
# execute installfile
echo -e "\033[01;31mWARNING:"
echo -e "\033[01;33m Starting installation in 20 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=1; i<=20; i++)); do
echo -n "."
read -r -t1 -n1 anykey
if [ "$anykey" = "x" ] || [ "$anykey" = "X" ]; then
break
fi
done
echo ""
#
debug "# executing installfile ..."
if [ -f "$INSTALLFILE" ] && [ "$VALIDATED" = "true" ] ; then
. "$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