You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
set -euo pipefail;
|
|
|
|
export TERM="${TERM:-linux}"; # Fix term var if launched without term
|
|
|
|
if [ "$TERM" = "dumb" -o "$TERM" = "unknown" ]; then
|
|
|
|
export TERM=linux;
|
|
|
|
fi
|
|
|
|
tput civis; # Hide cursor
|
|
|
|
|
|
|
|
function read_key() {
|
|
|
|
read -n 1 -s "$@";
|
|
|
|
}
|
|
|
|
|
|
|
|
function setup_failed() {
|
|
|
|
cat <<EOF
|
|
|
|
Einrichtung fehlgeschlagen, bitte melden Sie dies Ihrem Systemadministrator!
|
|
|
|
Sonst können Sie auch versuchen, das System erneut mit dem Installationsmedium aufzusetzen.
|
|
|
|
Drücken Sie eine beliebige Taste, um das System herunterzufahren
|
|
|
|
EOF
|
|
|
|
read_key;
|
|
|
|
systemctl poweroff;
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setup_finished() {
|
|
|
|
echo "Einrichtung abgeschlossen, drücken Sie eine beliebige Taste, um das System neu zu starten";
|
|
|
|
read_key;
|
|
|
|
systemctl reboot;
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ask_yes_no() {
|
|
|
|
local var="$1";
|
|
|
|
local question="$2";
|
|
|
|
while true; do
|
|
|
|
echo "$question [j|n]";
|
|
|
|
local answer="";
|
|
|
|
read_key answer;
|
|
|
|
if [[ "$answer" == [jJyY] ]]; then
|
|
|
|
export "$var"=true;
|
|
|
|
return 0;
|
|
|
|
elif [[ "$answer" == [nN] ]]; then
|
|
|
|
export "$var"=false;
|
|
|
|
return 0;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function retry_on_fail() {
|
|
|
|
local repeat_msg="$1";
|
|
|
|
c=0;
|
|
|
|
while ! "${@:2}"; do
|
|
|
|
echo "$repeat_msg";
|
|
|
|
((c+=1));
|
|
|
|
if [[ $c -ge 2 ]]; then
|
|
|
|
ask_yes_no retry "Es scheint ein system-bedingter Fehler zu sein, möchten Sie es dennoch erneut versuchen?";
|
|
|
|
if ! $retry; then
|
|
|
|
setup_failed;
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|