summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Rößler2014-10-22 15:54:24 +0200
committerChristian Rößler2014-10-22 15:54:24 +0200
commit7a6ce983d55f466986ee4028033b5cc28520551a (patch)
treec63783e60f6e2a0d9d56672f07cbf67ef3619b13
parent[SSPS] Added exit codes to control.sh scripts (diff)
downloadsetup-scripts-7a6ce983d55f466986ee4028033b5cc28520551a.tar.gz
setup-scripts-7a6ce983d55f466986ee4028033b5cc28520551a.tar.xz
setup-scripts-7a6ce983d55f466986ee4028033b5cc28520551a.zip
[SSPS] Netsetup expanded, now also dyn IP, to be tested.
-rw-r--r--satellit_installer/includes/50-copyscripts.inc2
-rwxr-xr-xsatellit_installer/static_files/netsetup (renamed from satellit_installer/static_files/config_static_ip)135
2 files changed, 102 insertions, 35 deletions
diff --git a/satellit_installer/includes/50-copyscripts.inc b/satellit_installer/includes/50-copyscripts.inc
index 1882158..f4ecbd8 100644
--- a/satellit_installer/includes/50-copyscripts.inc
+++ b/satellit_installer/includes/50-copyscripts.inc
@@ -7,6 +7,6 @@ install_tmpdelete() {
install_config_static_ip() {
echo -n "# Copying config_static_ip to /usr/local/sbin... "
mkdir -p /usr/local/sbin 2>/dev/null
- cp "$BASEDIR/static_files/config_static_ip" /usr/local/sbin
+ cp "$BASEDIR/static_files/netsetup" /usr/local/sbin
echo "ok."
}
diff --git a/satellit_installer/static_files/config_static_ip b/satellit_installer/static_files/netsetup
index 17a572f..cb94ad0 100755
--- a/satellit_installer/static_files/config_static_ip
+++ b/satellit_installer/static_files/netsetup
@@ -3,21 +3,70 @@
DATUM=$(date +%Y%m%d_%H%M%S)
INTERFACES="/etc/network/interfaces"
RESOLV="/etc/resolv.conf"
+SKRIPT=$(readlink -f "$0")
ERR=0
+write_banner() {
+ echo
+ echo "Dieses Skript konfiguriert statische oder dynamische IP-Adressen."
+ echo "Wenn Sie unsicher sind, können Sie es auch später ausführen. Sie"
+ echo "finden dieses Skript unter $SKRIPT."
+ echo
+ echo "Bitte bedenken Sie, daß Sie das Netzwerk entweder von Hand neu"
+ echo "starten müssen (oder einfach rebooten), wenn Sie die Netzwerk-"
+ echo "konfiguration verändern."
+ echo
+ echo "Es wurde übrigens eine $TYPE IP-Adresse vorgefunden."
+ echo
+}
+
+
+detect_config() {
+ if [ "$(grep -c "iface eth. inet dhcp" /etc/network/interfaces)" -gt 0 ]; then
+ # dhcp detected, we presume
+ TYPE=dhcp-basierte
+ WUNSCH=statische
+ else
+ TYPE=statische
+ WUNSCH=dhcp-basierte
+ fi
+}
+
ask_config() {
echo
- echo "This script configures a static IP adress."
- echo "If you are unsure you can execute it later; you will find this script"
- echo "at /usr/local/sbin/${0}."
- echo "Please keep in mind you will have to reinitialize the network by hand then"
- echo "(or simply reboot)."
+ echo "Es wurde eine $TYPE IP-Adresse vorgefunden."
+ echo "Wollen Sie eine $WUNSCH IP konfigurieren (y),"
+ echo "hat sich das Skript geirrt, und Sie benötigen doch eine $TYPE IP (x),"
+ echo "oder möchten Sie gar nichts tun (a oder leere Eingabe)?"
echo
- echo -n "If you want to configure a static IP adress, press y, any other key to abort: "
+ echo -n "Ihre Wahl - y, x oder a: "
read -n 1 config_me
- ech
- echo
- [ "$config_me" != "y" ] && exit 0
+ if [ "$config_me" == "y" -o "$config_me" == "y" ]; then exit 0; fi
+}
+
+decide_action() {
+ case "$config_me" in
+ y) backup_configs
+ if [ "$WUNSCH" == "statische" ]; then
+ enter_values_static
+ write_config_static
+ else
+ write_config_dyn
+ fi
+ ;;
+ x) backup_configs
+ if [ "$TYPE" == "statische" ]; then
+ enter_values_static
+ write_config_static
+ else
+ write_config_dyn
+ fi
+ ;;
+ *) echo "Ihre eingegebene Option $config_me wurde nicht erkannt - Neustart."
+ exec "$SKRIPT"
+ ;;
+
+
}
backup_configs() {
@@ -36,7 +85,42 @@ restore_configs() {
cp -p "$RESOLV.{DATUM}" "$RESOLV"
}
-enter_values() {
+write_config_static() {
+ echo "# This file was written by the satellite auto installer." > "$INTERFACES"
+ echo "# If any problems arise, copy $INTERFACES.${DATUM}." >> "$INTERFACES"
+ echo "# The loopback network interface" >> "$INTERFACES"
+ echo "auto lo" >> "$INTERFACES"
+ echo "iface lo inet loopback" >> "$INTERFACES"
+ echo "" >> "$INTERFACES"
+ echo "# Primary network interface" >> "$INTERFACES"
+ echo "auto eth0" >> "$INTERFACES"
+ echo "iface eth0 inet static" >> "$INTERFACES"
+ echo "address $ipadress" >> "$INTERFACES"
+ echo "gateway $gateway" >> "$INTERFACES"
+ echo "netmask $netmask" >> "$INTERFACES"
+
+ 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"
+ echo "nameserver $primarydns" >> "$RESOLV"
+ [ -n "$secondarydns" ] && echo "nameserver $secondarydns" >> "$RESOLV"
+}
+
+write_config_dyn() {
+ echo "# This file was written by the satellite auto installer." > "$INTERFACES"
+ echo "# If any problems arise, copy $INTERFACES.${DATUM}." >> "$INTERFACES"
+ echo "# The loopback network interface" >> "$INTERFACES"
+ echo "auto lo" >> "$INTERFACES"
+ echo "iface lo inet loopback" >> "$INTERFACES"
+ echo "" >> "$INTERFACES"
+ echo "# Primary network interface" >> "$INTERFACES"
+ echo "auto eth0" >> "$INTERFACES"
+ echo "iface eth0 inet dhcpauto eth0" >> "$INTERFACES"
+ # Leaving /etc/resolv alone; pump/dhclient/whatever will take care of that.
+}
+
+enter_values_static() {
while [ "$entry" != "y" ] && [ "$entry" != "Y" ]; do
echo
echo -n "IP-Adress: "
@@ -67,31 +151,14 @@ enter_values() {
read -n 1 entry
echo
done
+ write_config_static
}
-write_configs() {
- echo "# This file was written by the satellite auto installer." > "$INTERFACES"
- echo "# If any problems arise, copy $INTERFACES.${DATUM}." >> "$INTERFACES"
- echo "# The loopback network interface" >> "$INTERFACES"
- echo "auto lo" >> "$INTERFACES"
- echo "iface lo inet loopback" >> "$INTERFACES"
- echo "" >> "$INTERFACES"
- echo "# Primary network interface" >> "$INTERFACES"
- echo "auto eth0" >> "$INTERFACES"
- echo "iface eth0 inet static" >> "$INTERFACES"
- echo "address $ipadress" >> "$INTERFACES"
- echo "gateway $gateway" >> "$INTERFACES"
- echo "netmask $netmask" >> "$INTERFACES"
+detect_config
+write_banner
+ask_config
- 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"
- echo "nameserver $primarydns" >> "$RESOLV"
- [ -n "$secondarydns" ] && echo "nameserver $secondarydns" >> "$RESOLV"
-}
+decide_action # do the stuff!
+
+exit
-ask_config
-enter_values
-backup_configs
-write_configs