summaryrefslogtreecommitdiffstats
path: root/satellit_installer/static_files/dropped_script
diff options
context:
space:
mode:
authorSimon Rettberg2014-10-22 19:13:05 +0200
committerSimon Rettberg2014-10-22 19:13:05 +0200
commit0d8dded26c5c1934eb1f4dd85228595c6eb43a0a (patch)
treee43874c96bd0e4404c4f47809ffbba2c97b87dc0 /satellit_installer/static_files/dropped_script
parentAdd open-vm-tools (diff)
downloadsetup-scripts-0d8dded26c5c1934eb1f4dd85228595c6eb43a0a.tar.gz
setup-scripts-0d8dded26c5c1934eb1f4dd85228595c6eb43a0a.tar.xz
setup-scripts-0d8dded26c5c1934eb1f4dd85228595c6eb43a0a.zip
Outsource and translate firstrun.sh, rename variables
- Moved the firstrun script to a static file to make its handling easier (no more escaping hell) - firstrun.sh is now in German, as it will be run by the end user - Also renamed some variables to better fit their purpose (LOGDIR, INSTALLDIR)
Diffstat (limited to 'satellit_installer/static_files/dropped_script')
-rw-r--r--satellit_installer/static_files/dropped_script155
1 files changed, 155 insertions, 0 deletions
diff --git a/satellit_installer/static_files/dropped_script b/satellit_installer/static_files/dropped_script
new file mode 100644
index 0000000..8ffc948
--- /dev/null
+++ b/satellit_installer/static_files/dropped_script
@@ -0,0 +1,155 @@
+#!/bin/bash
+
+if [ ! -r "/root/installer/config" ]; then
+ echo "Keine firstrun-config gefunden! Tue nichts..."
+ exit 0
+fi
+
+source "/root/installer/config" || { echo "Fehler beim Sourcen der firstrun-config."; exit 1; }
+
+if [ -z "$MYSQL_ROOT_PASS" ]; then
+ echo "WARNUNG: Aktuelles MySQL-root-Passwort nicht bekannt!"
+ echo "**** Installationsfehler ****"
+ exit 1
+fi
+
+MY_PID=$$
+perror() {
+ echo "$@"
+ [ "$MY_PID" != "$$" ] && kill "$MY_PID"
+ exit 5
+}
+
+generate_password() {
+ tr -dc _A-Za-z0-9 < /dev/urandom | head -c 16
+}
+
+patchfiles() {
+ # <find> <replace> <file1> <file2> ... <fileN>
+ # Warning: does not escape!
+ FIND=$1
+ REPLACE=$2
+ shift 2
+ while [ $# -gt 0 ]; do
+ sed -i "s/${FIND}/${REPLACE}/g" "$1"
+ shift
+ done
+}
+
+export LANG=de_DE.UTF-8
+
+cat <<-HEREDOC
+Willkommen zur Grundkonfiguration des bwLehrpool-Satellitenservers.
+
+Diese einmalige Konfiguration dient dazu, das root-Passwort des Servers
+zu ändern, sowie ggf. die Netzwerkkonfiguration des Servers anzupassen.
+
+Aus Sicherheitsgründen ist es dringend zu empfehlen, das root-Passwort
+im Produktivbetrieb zu ändern!
+
+HEREDOC
+
+passwd
+
+echo
+echo "Nun werden einige intern genutzte Passwörter (z.B. MySQL-Zugänge) neu"
+echo "generiert....."
+umask 0077
+
+MYSQL_ROOT_NEW=$(generate_password)
+mysqladmin -u root -p"${MYSQL_ROOT_PASS}" password "${MYSQL_ROOT_NEW}" || perror "Neusetzen des root-MySQL-Passworts fehlgeschlagen"
+# Just in case...
+sed -i "s/^MYSQL_ROOT_PASS=.*\$/${MYSQL_ROOT_NEW}/g" "/root/installer/config"
+
+MYSQL_BWLEHRPOOL_NEW=$(generate_password)
+echo "SET PASSWORD FOR 'bwLehrpool'@'localhost' = PASSWORD('$MYSQL_BWLEHRPOOL_NEW');" | mysql -u root -p"${MYSQL_ROOT_NEW}" || perror "Neusetzen des bwLehrpool-MySQL-Passworts fehlgeschlagen"
+
+MYSQL_OPENSLX_NEW=$(generate_password)
+echo "SET PASSWORD FOR 'openslx'@'localhost' = PASSWORD('$MYSQL_OPENSLX_NEW');" | mysql -u root -p"${MYSQL_ROOT_NEW}" || perror "Neusetzen des openslx-MySQL-Passworts fehlgeschlagen"
+
+MYSQL_SYSMAINT_NEW=$(generate_password)
+echo "SET PASSWORD FOR 'debian-sys-maint'@'localhost' = PASSWORD('$MYSQL_SYSMAINT_NEW');" | mysql -u root -p"${MYSQL_ROOT_NEW}" || perror "Neusetzen des debian-sys-maint-Passworts fehlgeschlagen"
+
+# Store mysql root pass in root's home
+echo "$MYSQL_ROOT_NEW" > /root/mysqlpass
+chmod 600 /root/mysqlpass
+
+# No more going back
+unlink "/root/installer/config" 2>/dev/null
+sed -i "/firstrun.sh/d" /root/.profile
+
+# Write MOTD
+cat > /etc/motd <<-THEREDOC
+ *** bwLehrpool Satelliten-Server ***
+ Eingerichtet am $(date)
+
+ Wenn Sie sich als root eingeloggt haben, haben Sie nun folgende Optionen:
+ netsetup - Konfiguriert das Netzwerk-Interface neu (DHCP oder statisch)
+ reboot - System neustarten
+ poweroff - System herunterfahren
+
+ Andere Modifikationen am System sind in der Regel nicht notwendig.
+THEREDOC
+
+echo "Konfigurationsdateien werden aktualisiert..."
+
+# bwLehrpool mysql pass
+# Patch dmsd, syncdaemon, vmchooser-query-script
+patchfiles "%MYSQL_BWLEHRPOOL_PASS%" "$MYSQL_BWLEHRPOOL_NEW" "$DMSDDIR/Server_Config.ini" "/opt/syncdaemon/config/mysql.properties" "/srv/openslx/www/vmchooser/list.php"
+# Pureftpd
+patchfiles 'MYSQLPassword.*$' "MYSQLPassword $MYSQL_BWLEHRPOOL_NEW" "/etc/pure-ftpd/db/mysql.conf"
+
+# openslx mysql pass
+# Patching openslx-mysql-userpass into slx-admin config:
+patchfiles "%MYSQL_OPENSLX_PASS%" "$MYSQL_OPENSLX_NEW" "$WWWDIR/slx-admin/config.php"
+
+# Patching debian-sys-maint password into /etc/mysql/debian.cnf:
+patchfiles 'password *=.*$' "password = $MYSQL_SYSMAINT_NEW" "/etc/mysql/debian.cnf"
+
+echo "Dienste werden aktiviert..."
+
+# inittab-entry dmsd:
+if ! grep -q "dmsd.*respawn" /etc/inittab; then
+ echo "dmsd:2345:respawn:$DMSDDIR/dmsd.sh" >> /etc/inittab
+fi
+
+# inittab-entry taskmanager:
+if ! grep -c "tman.*respawn" /etc/inittab; then
+ echo "tman:2345:respawn:$TASKMANDIR/taskmanager.sh" >> /etc/inittab
+fi
+
+# inittab-entry syncdaemon:
+if ! grep -c "synd.*respawn" /etc/inittab; then
+ echo "synd:2345:respawn:/opt/syncdaemon/syncdaemon.sh" >> /etc/inittab
+fi
+
+echo
+echo "Neue SSH host keys werden generiert"
+echo "(Beim nächsten Verbinden mit dem Satelliten-Server werden Sie möglicherweise"
+echo "eine entsprechende Warnung erhalten)"
+echo
+
+rm -f /etc/ssh/ssh_host_*key* 2>/dev/null
+
+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
+
+echo "Abschließend können Sie festlegen, ob der Server seine IP-Konfiguration"
+echo "per DHCP erhält, oder eine statische Konfiguration verwendet wird."
+/usr/local/sbin/netsetup
+
+cat <<HEREDOC
+
+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 sich jetzt neustarten.
+
+HEREDOC
+
+sleep 4
+unlink "/root/installer/firstrun.sh"
+reboot
+