summaryrefslogtreecommitdiffstats
path: root/satellit_installer/static_files/netsetup
diff options
context:
space:
mode:
authorSimon Rettberg2020-12-17 15:08:14 +0100
committerSimon Rettberg2020-12-17 15:08:14 +0100
commitb5c3eb9e01b09367935f558a57633b68a65a1a21 (patch)
treeb6c322f3089192124779b9d7a29c8365eb39533f /satellit_installer/static_files/netsetup
parent[SSPS] slx-cert: Put hostname in SAN too, chromium requires this (diff)
downloadsetup-scripts-b5c3eb9e01b09367935f558a57633b68a65a1a21.tar.gz
setup-scripts-b5c3eb9e01b09367935f558a57633b68a65a1a21.tar.xz
setup-scripts-b5c3eb9e01b09367935f558a57633b68a65a1a21.zip
[SSPS] Refactor static_files: Submodules with tree
Add submodules (aka directories) to static_files, named according to what component they are for. Add function "install_files" to copy the contents of one of those modules to the root directory. This should make the resulting setup more obvious and require less manual copying of files everywhere.
Diffstat (limited to 'satellit_installer/static_files/netsetup')
-rwxr-xr-xsatellit_installer/static_files/netsetup200
1 files changed, 0 insertions, 200 deletions
diff --git a/satellit_installer/static_files/netsetup b/satellit_installer/static_files/netsetup
deleted file mode 100755
index 6616c50..0000000
--- a/satellit_installer/static_files/netsetup
+++ /dev/null
@@ -1,200 +0,0 @@
-#!/bin/bash
-
-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
-