summaryrefslogtreecommitdiffstats
path: root/satellit_installer/static_files/system-base
diff options
context:
space:
mode:
authorSimon Rettberg2024-04-30 14:26:10 +0200
committerSimon Rettberg2024-04-30 14:26:10 +0200
commit6512e211c44832fae7d04684ac1820c0c28c8d0a (patch)
tree05b8665da19275e79183018725ca4e558312c5d8 /satellit_installer/static_files/system-base
parent[SS*S] lighttpd: Don't try to use ssl.ca-file for certificate chain (diff)
downloadsetup-scripts-6512e211c44832fae7d04684ac1820c0c28c8d0a.tar.gz
setup-scripts-6512e211c44832fae7d04684ac1820c0c28c8d0a.tar.xz
setup-scripts-6512e211c44832fae7d04684ac1820c0c28c8d0a.zip
[SS?S] Split static_files/system into base and updates
base is considered static, i.e. only copied once when *installing* a server, because they are config files the user/admin is expected to edit, or because they have to match the specific Debian release the installed server is based on, and thus should not - or only selectively - be replaced by the satellite updater. In other words, the system-updates module should be save to be copied over a running satellite server on update via "install_files", while files from system-base will only be updated selectively, if at all.
Diffstat (limited to 'satellit_installer/static_files/system-base')
-rw-r--r--satellit_installer/static_files/system-base/etc/apt/apt.conf.d/99update-config27
-rw-r--r--satellit_installer/static_files/system-base/etc/issue7
-rw-r--r--satellit_installer/static_files/system-base/etc/issue.disabled9
-rw-r--r--satellit_installer/static_files/system-base/etc/mysql/conf.d/99-openslx.cnf7
-rw-r--r--satellit_installer/static_files/system-base/etc/systemd/system/firstboot.service14
-rw-r--r--satellit_installer/static_files/system-base/etc/tmux.conf5
-rw-r--r--satellit_installer/static_files/system-base/etc/vim/vimrc.local10
-rw-r--r--satellit_installer/static_files/system-base/opt/openslx/bashrc.inc17
-rwxr-xr-xsatellit_installer/static_files/system-base/opt/openslx/firstboot.sh136
-rwxr-xr-xsatellit_installer/static_files/system-base/opt/openslx/firstrun.sh99
-rwxr-xr-xsatellit_installer/static_files/system-base/usr/local/bin/finalize21
-rwxr-xr-xsatellit_installer/static_files/system-base/usr/local/bin/netsetup205
12 files changed, 557 insertions, 0 deletions
diff --git a/satellit_installer/static_files/system-base/etc/apt/apt.conf.d/99update-config b/satellit_installer/static_files/system-base/etc/apt/apt.conf.d/99update-config
new file mode 100644
index 0000000..0f66e29
--- /dev/null
+++ b/satellit_installer/static_files/system-base/etc/apt/apt.conf.d/99update-config
@@ -0,0 +1,27 @@
+// Updates aktivieren
+APT::Periodic::Update-Package-Lists "1";
+APT::Periodic::Unattended-Upgrade "1";
+
+// Wenn ein Paket nicht sauber installiert wird, Installation erneut
+// versuchen, und alte Paketkonfiguration beibehalten.
+Unattended-Upgrade::AutoFixInterruptedDpkg "true";
+
+// Macht den Updatevorgang langsamer, aber robuster
+Unattended-Upgrade::MinimalSteps "true";
+
+// Alte Kernelversionen automatisch deinstallieren
+Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
+
+// Wenn nach einem Update Pakete nicht mehr benötigt werden, diese automatisch deinstallieren
+//Unattended-Upgrade::Remove-New-Unused-Dependencies "true";
+Unattended-Upgrade::Remove-Unused-Dependencies "true";
+
+// Automatisch rebooten, wenn ein Paket dies nach dem Update erfordert?
+Unattended-Upgrade::Automatic-Reboot "false";
+
+// ... Reboot auch durchführen, wenn jemand auf dem Server eingeloggt ist? (SSH, Terminal)
+Unattended-Upgrade::Automatic-Reboot-WithUsers "false";
+
+// Uhrzeit, zu der bei erforderlichem Reboot neugestartet werden soll.
+// Der Wert "now" führt den Reboot unverzüglich durch.
+Unattended-Upgrade::Automatic-Reboot-Time "02:00";
diff --git a/satellit_installer/static_files/system-base/etc/issue b/satellit_installer/static_files/system-base/etc/issue
new file mode 100644
index 0000000..a097cee
--- /dev/null
+++ b/satellit_installer/static_files/system-base/etc/issue
@@ -0,0 +1,7 @@
+-------------------------------------------------
+ bwLehrpool Satellitenserver (Debian \S{VERSION_ID})
+-------------------------------------------------
+
+Bitte loggen Sie sich als Nutzer "bwlp" ein, um die
+Einrichtung des Systems abzuschließen.
+
diff --git a/satellit_installer/static_files/system-base/etc/issue.disabled b/satellit_installer/static_files/system-base/etc/issue.disabled
new file mode 100644
index 0000000..078ef2a
--- /dev/null
+++ b/satellit_installer/static_files/system-base/etc/issue.disabled
@@ -0,0 +1,9 @@
+-------------------------------------------------
+ bwLehrpool Satellitenserver (Debian \S{VERSION_ID})
+-------------------------------------------------
+
+Web interface for configuration:
+
+\e{lightred}http(s)://\4/\e{reset}
+\e{lightred}http(s)://\n.\O/\e{reset}
+
diff --git a/satellit_installer/static_files/system-base/etc/mysql/conf.d/99-openslx.cnf b/satellit_installer/static_files/system-base/etc/mysql/conf.d/99-openslx.cnf
new file mode 100644
index 0000000..f4ff6f7
--- /dev/null
+++ b/satellit_installer/static_files/system-base/etc/mysql/conf.d/99-openslx.cnf
@@ -0,0 +1,7 @@
+[mysqld]
+character-set-server = utf8mb4
+collation-server = utf8mb4_unicode_520_ci
+sql_mode = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+
+[client]
+default-character-set = utf8mb4
diff --git a/satellit_installer/static_files/system-base/etc/systemd/system/firstboot.service b/satellit_installer/static_files/system-base/etc/systemd/system/firstboot.service
new file mode 100644
index 0000000..f19b51a
--- /dev/null
+++ b/satellit_installer/static_files/system-base/etc/systemd/system/firstboot.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Initialization of bwLehrpool on first boot
+ConditionFileIsExecutable=/opt/openslx/firstboot.sh
+After=network.target mysql.service mariadb.service
+Before=ssh.service lighttpd.service dmsd.service taskmanager.service
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/firstboot.sh
+RemainAfterExit=yes
+RefuseManualStart=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/satellit_installer/static_files/system-base/etc/tmux.conf b/satellit_installer/static_files/system-base/etc/tmux.conf
new file mode 100644
index 0000000..537f52c
--- /dev/null
+++ b/satellit_installer/static_files/system-base/etc/tmux.conf
@@ -0,0 +1,5 @@
+set -g tmate-server-host "tmate.ruf.uni-freiburg.de"
+set -g tmate-server-port 2222
+set -g tmate-server-rsa-fingerprint SHA256:pyT0YTJ+2c6AHD4QtUC1GEA9SFFYba74x2T1VZJ6zpc
+set -g tmate-server-ed25519-fingerprint SHA256:ZuTqO8YZrdgzjskHhfNd65es4HEx5rKBRZj/e/iBLrg
+set -g tmate-identity ""
diff --git a/satellit_installer/static_files/system-base/etc/vim/vimrc.local b/satellit_installer/static_files/system-base/etc/vim/vimrc.local
new file mode 100644
index 0000000..4bfb95d
--- /dev/null
+++ b/satellit_installer/static_files/system-base/etc/vim/vimrc.local
@@ -0,0 +1,10 @@
+runtime! defaults.vim
+let g:skip_defaults_vim = 1
+
+syntax on
+set showmatch
+set smartcase
+set incsearch
+set mouse=
+set autoindent
+set smartindent
diff --git a/satellit_installer/static_files/system-base/opt/openslx/bashrc.inc b/satellit_installer/static_files/system-base/opt/openslx/bashrc.inc
new file mode 100644
index 0000000..b5fa467
--- /dev/null
+++ b/satellit_installer/static_files/system-base/opt/openslx/bashrc.inc
@@ -0,0 +1,17 @@
+slxif="$( ip a s 2> /dev/null | grep -oPm1 '(?<=^[0-9]: )e[^:]+' )"
+slxip="$( ip -4 a s "$slxif" 2> /dev/null | grep -m1 '^\s*inet ' | awk '{print $2}' )"
+[ -z "$slxip" ] && slxip="$( ip -4 a | grep '^\s*inet '| grep -vFm1 ' 127.' | awk '{print $2}' )"
+slxip=${slxip%/*}
+[ -z "$slxip" ] && read -r _ _ slxip _ <<<"$SSH_CONNECTION"
+[ -z "$slxip" ] && slxip="noip???"
+slxcol=32
+slxchar='$'
+(( UID == 0 )) && slxcol=31
+(( UID == 0 )) && slxchar='#'
+PS1="\[\033[01;${slxcol}m\]\u\[\033[00m\]@\[\033[01;32m\]\h \[\033[00m\]($slxip)
+\[\033[01;34m\]\w\[\033[00m\] $slxchar "
+unset slxif slxip slxcol slxchar
+# We always want to run this as root; sudo is a noop in case we already are.
+alias tmate='sudo tmate'
+# Also expand aliases when using sudo
+alias sudo='sudo '
diff --git a/satellit_installer/static_files/system-base/opt/openslx/firstboot.sh b/satellit_installer/static_files/system-base/opt/openslx/firstboot.sh
new file mode 100755
index 0000000..fe75c1d
--- /dev/null
+++ b/satellit_installer/static_files/system-base/opt/openslx/firstboot.sh
@@ -0,0 +1,136 @@
+#!/bin/bash
+
+MY_PID=$$
+conf="/opt/openslx/config.install"
+
+# Logfile
+exec &>> /opt/openslx/firstboot.log
+
+perror() {
+ echo "[ERROR] $*"
+ [ "$MY_PID" != "$$" ] && kill "$MY_PID"
+
+ if ! grep -q "firstboot.sh has thrown an error" /etc/motd; then
+ cat <<-EOF >> /etc/motd
+
+ WARNING!
+
+ firstboot.sh has thrown an error!
+ Please read /opt/openslx/firstboot.log and take appropriate measures!
+ This server may not work correctly!
+
+ EOF
+ fi
+ exit 5
+}
+
+if ! [ -e "$conf" ]; then
+ # First time this script runs, it will delete the config at the end; this
+ # means this has to be the second bootup, after the user finished the
+ # firstrun.sh script on first login as "bwlp".
+ # Completely delete the script now, and also firstrun.sh
+ unlink "/opt/openslx/firstrun.sh"
+ unlink "/opt/openslx/firstboot.sh"
+ unlink "/etc/systemd/system/firstboot.service"
+ unlink "/etc/systemd/system/multi-user.target.wants/firstboot.service"
+ # Only now enable the web interface, so the user cannot login via browser
+ # before finishing the firstrun.sh script via ssh/tty login
+ systemctl enable lighttpd.service || perror "Konnte systemd-Service lighttpd nicht aktivieren!"
+ systemctl --no-block start lighttpd.service
+ # Also activate our issue that hints at the webif URL
+ mv /etc/issue.disabled /etc/issue
+ exit 0
+fi
+
+echo "+++ $(basename "$0") gestartet: $(date "+%Y-%m-%d %H:%m:%S")"
+
+[ -s "$conf" ] || perror "Config file $conf missing"
+bash -n "$conf" || perror "Config file $conf has errors"
+. "$conf"
+
+generate_password() {
+ tr -dc _A-Za-z0-9 < /dev/urandom 2> /dev/null | head -c 16
+}
+
+patchfiles() {
+ # <find> <replace> <file1> <file2> ... <fileN>
+ # Warning: does not escape!
+ local FIND="$1"
+ local REPLACE="$2"
+ shift 2
+ while [ $# -gt 0 ]; do
+ sed -i "s/${FIND}/${REPLACE}/g" "$1"
+ shift
+ done
+}
+
+echo "+++ Lösche alte ssh-Schlüssel ..."
+rm -f -- /etc/ssh/ssh_host_*key* 2>/dev/null
+
+echo "+++ Generating new sshd keys..."
+ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N "" -t rsa -q
+ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N "" -t dsa -q
+ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -N "" -t ecdsa -q
+ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -N "" -t ed25519 -q
+
+echo "+++ Generiere intern genutzte Passwörter (z.B. MySQL-Zugänge) neu ..."
+umask 0077
+
+MYSQL_SAT_NEW=$(generate_password)
+[ -z "$MYSQL_SAT_NEW" ] && perror "Error generating mysql password for dmsd"
+echo "SET PASSWORD FOR 'sat'@'localhost' = PASSWORD('$MYSQL_SAT_NEW');" | mysql -u root || perror "Neusetzen des sat-MySQL-Passworts fehlgeschlagen."
+
+MYSQL_OPENSLX_NEW=$(generate_password)
+[ -z "$MYSQL_OPENSLX_NEW" ] && perror "Error generating mysql password for openslx"
+echo "SET PASSWORD FOR 'openslx'@'localhost' = PASSWORD('$MYSQL_OPENSLX_NEW');" | mysql -u root || perror "Neusetzen des openslx-MySQL-Passworts fehlgeschlagen."
+
+echo "+++ Konfigurationsdateien werden aktualisiert..."
+
+# sat mysql pass
+# Patch dmsd
+patchfiles "%MYSQL_SAT_PASS%" "$MYSQL_SAT_NEW" "$DMSDDIR/config.properties"
+
+# openslx mysql pass
+# Patching openslx-mysql-userpass into slx-admin config:
+patchfiles "%MYSQL_OPENSLX_PASS%" "$MYSQL_OPENSLX_NEW" "$SLXADMINDIR/config.php"
+
+# taskmanager password
+TASKMANAGER_PASS=$(generate_password)
+patchfiles "%TM_OPENSLX_PASS%" "$TASKMANAGER_PASS" "$SLXADMINDIR/config.php" "$TASKMANDIR/config/config"
+
+echo "+++ Dienste werden aktiviert..."
+
+# Enable bwLehrpool related services
+for i in dmsd.service taskmanager.service; do
+ systemctl enable "$i" || perror "Konnte systemd-Service $i nicht aktivieren!"
+ systemctl --no-block start "$i"
+done
+
+# root ssh key
+echo ""
+echo "Erzeuge SSH Schlüsselpaar für root"
+echo ""
+
+KEY=~/.ssh/id_rsa
+rm -f -- "$KEY" "${KEY}.pub"
+ssh-keygen -q -N "" -f "$KEY" \
+ || echo "Achtung: Erzeugung Schlüsselpaar $KEY fehlgeschlagen."
+
+# Write MOTD
+cat > /etc/motd <<THEREDOC
+> *** bwLehrpool Satellitenserver, Version $VERSION ***
+> Eingerichtet am $(date)
+>
+> Wenn Sie sich als 'bwlp' eingeloggt haben, haben Sie nun folgende Optionen:
+> netsetup - Konfiguriert das Netzwerk-Interface neu (DHCP oder statisch)
+> sudo reboot - System neustarten
+> sudo poweroff - System herunterfahren
+>
+> Andere Modifikationen am System sind in der Regel nicht notwendig.
+>
+THEREDOC
+
+echo "+++ Daten des Firstrun-Scripts werden aufgeräumt..."
+unlink "$conf"
+
+exit 0
diff --git a/satellit_installer/static_files/system-base/opt/openslx/firstrun.sh b/satellit_installer/static_files/system-base/opt/openslx/firstrun.sh
new file mode 100755
index 0000000..1238cc5
--- /dev/null
+++ b/satellit_installer/static_files/system-base/opt/openslx/firstrun.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+
+cat <<-HEREDOC
+>
+> Willkommen zur Grundkonfiguration des bwLehrpool Satellitenservers.
+>
+> Diese einmalige Konfiguration dient dazu, das Passwort des System-Users
+> "bwlp" zu ändern (für Terminal, SSH), sowie ggf. die
+> Netzwerkkonfiguration des Servers anzupassen.
+>
+HEREDOC
+
+while ! passwd; do
+ echo " "
+ echo "> Das hat nicht geklappt. Bitte noch einmal versuchen:"
+ echo "> "
+done
+
+cat <<-SUPPE
+>
+> Das neue Passwort ist ab sofort gültig.
+>
+> Erzeuge SSH Schlüsselpaar
+>
+SUPPE
+
+KEY=~/.ssh/id_rsa
+
+rm -f -- "$KEY" "${KEY}.pub"
+ssh-keygen -q -N "" -f "$KEY" \
+ || echo "> Achtung: Erzeugung Schlüsselpaar $KEY fehlgeschlagen."
+
+cat <<-HERRR
+>
+> Nun können Sie festlegen, ob der Server seine IP-Konfiguration
+> per DHCP erhält, oder eine statische Konfiguration verwendet wird.
+>
+HERRR
+
+netsetup
+
+cat <<BLOCK
+>
+> Möchten Sie das Paket "unattended-upgrades" installieren, um
+> automatische Updates des Betriebsystems zu aktivieren?
+> Sonst müssen Sie das System regelmäßig manuell über die Konsole
+> oder die Webschnittstelle aktualisieren.
+>
+BLOCK
+choice=
+while ! [[ $choice =~ ^[jJyYnN] ]]; do
+ echo -n "Auswahl [J/N]: "
+ read -r choice
+done
+choice=${choice:0:1}
+choice=${choice^^}
+
+if [ "$choice" != "N" ]; then
+ # Install
+ echo "> Installiere Paket unattended-upgrades"
+ if sudo apt update \
+ && sudo apt install -y unattended-upgrades; then
+ echo "> Automatische updates eingerichtet. Für Informationen zu"
+ echo "> möglichen Anpassungen der automatischen Updates"
+ else
+ echo "> "
+ echo "> Fehler beim Installieren des Pakets für die automatischen Updates."
+ echo "> Bitte sorgen Sie dafür, dass der Satellitenserver einen Paket-Mirror"
+ echo "> erreichen kann. Für weitere Informationen zu diesem Thema"
+ fi
+else
+ echo "> "
+ echo "> Falls Sie das Einspielen von System-Updates automatisieren wollen,"
+fi
+
+cat <<YONDERDOC
+>
+> lesen Sie bitte den zugehörigen Artikel
+> https://www.bwlehrpool.de/wiki/doku.php/satellite/system_updates
+> (auch zu finden im Web-Interface: System-Status -> System updates)
+>
+> Damit ist die Einrichtung abgeschlossen. Die weitere Konfiguration des
+> bwLehrpool-Systems erfolgt über die Webschnittstelle, die über die
+> IP-Addresse oder den Hostnamen des Servers erreichbar ist.
+>
+> Der Server wird jetzt zum Abschluss der Installation neugestartet.
+> Drücken Sie Enter, um sofort neuzustarten.
+>
+YONDERDOC
+
+sed -i "/opt.openslx.firstrun.sh/d" ~/.profile
+
+for _ in {1..15}; do
+ echo -n "."
+ read -r -t 1 -s && break
+done
+echo "."
+
+sudo reboot
diff --git a/satellit_installer/static_files/system-base/usr/local/bin/finalize b/satellit_installer/static_files/system-base/usr/local/bin/finalize
new file mode 100755
index 0000000..1be85e2
--- /dev/null
+++ b/satellit_installer/static_files/system-base/usr/local/bin/finalize
@@ -0,0 +1,21 @@
+#!/bin/dash
+
+# Funny dash has a funny 'kill' builtin, which we
+# do not want to use.
+KILL=$(which kill)
+
+EIGENEPID=$(ps -o ppid $$|fgrep -v PPID)
+
+# kill every bash in reach, but not the parent('s parent):
+for i in $(ps axo pid,comm|grep bash|cut -d " " -f 2); do
+ [ $EIGENEPID != $i ] && $KILL -SIGKILL $i 2>/dev/null
+done
+
+# Now, empty root's ~/.bash_history:
+>~/.bash_history
+
+# Now we delete the script - necessary only once.
+rm -f "$_" 2>/dev/null
+
+exit
+
diff --git a/satellit_installer/static_files/system-base/usr/local/bin/netsetup b/satellit_installer/static_files/system-base/usr/local/bin/netsetup
new file mode 100755
index 0000000..a824739
--- /dev/null
+++ b/satellit_installer/static_files/system-base/usr/local/bin/netsetup
@@ -0,0 +1,205 @@
+#!/bin/bash
+
+if [ "$UID" != 0 ]; then
+ exec sudo "$0" "$@"
+ exit 1
+fi
+
+DATUM=$(date +%Y%m%d_%H%M%S)
+INTERFACES="/etc/network/interfaces"
+ETHALIAS=$( ifconfig -a | grep -oEm1 '^e\w+' )
+RESOLV="/etc/resolv.conf"
+HOSTNAMEFILE="/etc/hostname"
+SKRIPT=$(readlink -f "$0")
+ERR=0
+
+
+write_banner() {
+ echo
+ echo "Dieses Skript konfiguriert das Netzwerk-Interface."
+ echo
+ echo "Wenn Sie die Netzwerkkonfiguration ändern, sollten Sie anschließend"
+ echo "den Server rebooten."
+ echo
+}
+
+
+detect_config() {
+ if grep -q -E "^[[:space:]]*iface[[:space:]]+${ETHALIAS}[[:space:]]+inet[[:space:]]+dhcp" "$INTERFACES"; then
+ # dhcp detected, we presume
+ TYPE=dhcp-basierte
+ WUNSCH=statische
+ TOUCHE_TYPE=d
+ TOUCHE_DESIR=s
+ else
+ TYPE=statische
+ WUNSCH=dhcp-basierte
+ TOUCHE_TYPE=s
+ TOUCHE_DESIR=d
+ fi
+}
+
+ask_config() {
+ echo
+ echo "Es ist aktuell eine $TYPE IP-Adresse konfiguriert."
+ echo
+ echo "Wollen Sie eine $WUNSCH IP konfigurieren (${TOUCHE_DESIR}),"
+ echo "möchten Sie die $TYPE IP neu konfigurieren (${TOUCHE_TYPE}),"
+ echo "oder möchten Sie gar nichts tun (leere Eingabe)?"
+ echo
+ echo -n "Ihre Wahl? [${TOUCHE_DESIR}/${TOUCHE_TYPE}/nichts]: "
+ read CONFIG_ME
+ [ "$CONFIG_ME" == "" ] && exit 0
+}
+
+decide_action() {
+ case "$CONFIG_ME" in
+ ${TOUCHE_DESIR}*) backup_configs
+ if [ "$WUNSCH" == "statische" ]; then
+ enter_values_static
+ write_config_static
+ else
+ write_config_dyn
+ fi
+ ;;
+ ${TOUCHE_TYPE}*) backup_configs
+ if [ "$TYPE" == "statische" ]; then
+ enter_values_static
+ write_config_static
+ else
+ write_config_dyn
+ fi
+ ;;
+ *) echo; echo
+ echo "Ihre eingegebene Option $CONFIG_ME wurde nicht erkannt - Neustart."
+ echo
+ sleep 1
+ exec "$SKRIPT"
+ ;;
+ esac
+}
+
+backup_configs() {
+ if [ -f "$INTERFACES" ]; then
+ cp -p "$INTERFACES" "$INTERFACES.${DATUM}" || \
+ { echo "Konnte Datei $INTERFACES nicht nach $INTERFACES.$DATUM sichern - Abbruch."; \
+ exit 1 ; }
+ cp -p "$RESOLV" "$RESOLV.${DATUM}" || \
+ { echo "Konnte Datei $RESOLV nicht nach $RESOLV.$DATUM sichern - Abbruch."; \
+ exit 1 ; }
+ fi
+}
+
+restore_configs() {
+ cp -p "$INTERFACES.$DATUM" "$INTERFACES"
+ cp -p "$RESOLV.{DATUM}" "$RESOLV"
+}
+
+write_config_static() {
+ cat > "$INTERFACES" <<-HIER
+ # This file was written by the satellite auto installer.
+ # If any problems arise, copy $INTERFACES.${DATUM}.
+ # The loopback network interface
+ auto lo
+ iface lo inet loopback
+
+ # Primary network interface
+ auto $ETHALIAS
+ iface $ETHALIAS inet static
+ address $IPADRESS
+ gateway $GATEWAY
+ netmask $NETMASK
+ HIER
+
+ echo "# This file was written by the satellite server install script." > "$RESOLV"
+ echo "# If any problems arise, copy $RESOLV.${DATUM}." >> "$RESOLV"
+ [ -n "$DOMAIN" ] && echo "domain $DOMAIN" >> "$RESOLV"
+ [ -n "$SEARCH" ] && echo "search $SEARCH" >> "$RESOLV"
+ [ -n "$PRIMARYDNS" ] && echo "nameserver $PRIMARYDNS" >> "$RESOLV"
+ [ -n "$SECONDARYDNS" ] && echo "nameserver $SECONDARYDNS" >> "$RESOLV"
+
+ echo "$HOSTNAME" > "$HOSTNAMEFILE"
+
+ [ -n "$DOMAIN" ] && DOMAIN=".${DOMAIN}"
+ sed "s/127.0.1.1.*/127.0.1.1\t${HOSTNAME}${DOMAIN}\t${HOSTNAME}/g" -i /etc/hosts --in-place=.alt
+
+}
+
+write_config_dyn() {
+ cat > "$INTERFACES" <<-HIER
+ # This file was written by the satellite auto installer.
+ # If any problems arise, copy $INTERFACES.${DATUM}.
+ # The loopback network interface
+ auto lo
+ iface lo inet loopback
+
+ # Primary network interface
+ auto $ETHALIAS
+ iface $ETHALIAS inet dhcp
+ # Leaving /etc/resolv alone; pump/dhclient/whatever will take care of that.
+ HIER
+}
+
+enter_values_static() {
+ OLDHOSTNAME=$(hostname)
+ unset ENTRY
+ while true; do
+ echo
+ echo -n "IP-Adresse: "
+ read IPADRESS
+ echo -n "Gateway: "
+ read GATEWAY
+ echo -n "Netzmaske - leere Eingabe für 255.255.255.0: "
+ read NETMASK
+ [ -z "$NETMASK" ] && NETMASK=255.255.255.0
+ echo -n "Domain - leere Eingabe, wenn nicht erwünscht: "
+ read DOMAIN
+ echo -n "Search domain - leere Eingabe, wenn nicht erwünscht: "
+ read SEARCH
+ echo -n "Primärer Nameserver: "
+ read PRIMARYDNS
+ echo -n "Sekundärer Nameserver - Leere Eingabe, wenn nicht vorhanden: "
+ read SECONDARYDNS
+ echo -n "Hostname - leere Eingabe für bestehenden Hostname $OLDHOSTNAME: "
+ read HOSTNAME
+ [ "$HOSTNAME" == "" ] && HOSTNAME="$OLDHOSTNAME"
+ echo
+ echo "# IP-Adresse : $IPADRESS"
+ echo "# Gateway : $GATEWAY"
+ echo "# Netzmaske : $NETMASK"
+ echo "# Domain : $DOMAIN"
+ echo "# Search domain : $SEARCH"
+ echo "# Primärer Nameserver : $PRIMARYDNS"
+ echo "# Sekundärer Nameserver : $SECONDARYDNS"
+ echo "# Hostname : $HOSTNAME"
+ echo
+ while true; do
+ echo -n "Sind diese Eingaben korrekt? [J/n]: "
+ read ENTRY
+ echo
+ [[ -z "$ENTRY" || "$ENTRY" == j* || "$ENTRY" == J* ]] && return
+ if [[ "$ENTRY" == n* || "$ENTRY" == N* ]]; then
+ echo "Neustart der Eingabe..."
+ echo
+ break
+ fi
+ done
+ done
+}
+
+last_words() {
+ echo
+ echo "Einträge geschrieben... beende Skript."
+ echo
+}
+
+detect_config
+write_banner
+ask_config
+
+decide_action # do the stuff!
+
+last_words
+
+exit 0
+