summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Rößler2015-02-25 14:58:13 +0100
committerChristian Rößler2015-02-25 14:58:13 +0100
commit28b92f337f7dbd4a3c7fce77416d18927100d97f (patch)
treed02218a3ae697357a704727bee08bc6b2af748f2
parent[SSPS] Begun moving div. functions to rc.local (diff)
downloadsetup-scripts-28b92f337f7dbd4a3c7fce77416d18927100d97f.tar.gz
setup-scripts-28b92f337f7dbd4a3c7fce77416d18927100d97f.tar.xz
setup-scripts-28b92f337f7dbd4a3c7fce77416d18927100d97f.zip
[SSPS] More functions moved to rc.local-started script [untested, keep care!]
-rw-r--r--satellit_installer/includes/10-script_dropper.inc18
-rw-r--r--satellit_installer/static_files/firstrun_script.sh122
-rw-r--r--satellit_installer/static_files/rclocal_script.sh128
3 files changed, 144 insertions, 124 deletions
diff --git a/satellit_installer/includes/10-script_dropper.inc b/satellit_installer/includes/10-script_dropper.inc
index c1ccd7b..2178863 100644
--- a/satellit_installer/includes/10-script_dropper.inc
+++ b/satellit_installer/includes/10-script_dropper.inc
@@ -11,9 +11,10 @@ drop_script() {
mkdir -p "/root/installer"
# So we know all the paths and the mysql password
cat "${BASEDIR}/includes/00-dirs.inc" "${CONFIGDIR}/config" > "/root/installer/config"
- chmod 0600 "/root/installer/config"
- cp "${BASEDIR}/static_files/firstrun_script.sh" "/root/installer/firstrun.sh"
- chmod u+x "/root/installer/firstrun.sh"
+ chmod 0600 /root/installer/config
+ cp "${BASEDIR}/static_files/firstrun_script.sh" "${BASEDIR}/static_files/rclocal_script.sh" /root/installer/
+ chmod u+x /root/installer/firstrun.sh /root/installer/rclocal_script.sh
+
}
drop_keychanger_rclocal() {
@@ -24,16 +25,17 @@ drop_keychanger_rclocal() {
echo "# Patching rc.local..."
cp -p /etc/rc.local /etc/rc.local.sik
cat > /etc/rc.local <<-HIERDOK
- echo
- echo "Deleting old ssh keys..."
+ #!/bin/bash
+ echo "rc.local started: $(date "+%Y-%m-%d %H:%m:%S")" >> /root/init.log
+ echo "Deleting old ssh keys..." >> /root/init.log
rm -f /etc/ssh/ssh_host_*key* 2>/dev/null
- echo "... done."
+ echo -n "... done."
- echo "Generating new ssh keys..."
+ echo "Generating new ssh keys..." >> /root/init.log
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 "... done."
+ echo -n "... done." >> /root/init.log
mv /etc/rc.local.sik /etc/rc.local
HIERDOK
chmod +x /etc/rc.local
diff --git a/satellit_installer/static_files/firstrun_script.sh b/satellit_installer/static_files/firstrun_script.sh
index 0dee034..92a3151 100644
--- a/satellit_installer/static_files/firstrun_script.sh
+++ b/satellit_installer/static_files/firstrun_script.sh
@@ -1,43 +1,5 @@
#!/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.
@@ -51,95 +13,23 @@ 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:2:once:$DMSDDIR/dmsd.sh" >> /etc/inittab
-fi
-
-# inittab-entry taskmanager:
-if ! grep -q "tman.*respawn" /etc/inittab; then
- echo "tman:2345:respawn:$TASKMANDIR/taskmanager.sh" >> /etc/inittab
-fi
-
-# inittab-entry syncdaemon:
-if ! grep -q "synd.*respawn" /etc/inittab; then
- echo "synd:2:once:/opt/syncdaemon/syncdaemon.sh" >> /etc/inittab
-fi
-
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
+cat <<YONDERDOC
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.
+Bitte überprüfen Sie die Logdatei /root/init.log auf eventuelle Fehler!
+
Der Server wird sich jetzt neustarten.
-HEREDOC
+YONDERDOC
sleep 4
-unlink "/root/installer/firstrun.sh"
-reboot
+sed -i "/firstrun.sh/d" /root/.profile
+reboot
diff --git a/satellit_installer/static_files/rclocal_script.sh b/satellit_installer/static_files/rclocal_script.sh
new file mode 100644
index 0000000..7370b22
--- /dev/null
+++ b/satellit_installer/static_files/rclocal_script.sh
@@ -0,0 +1,128 @@
+#!/bin/bash
+
+echo "$(basename $0) gestartet: $(date "+%Y-%m-%d %H:%m:%S")" >> /root/init.log
+
+if [ ! -r "/root/installer/config" ]; then
+ echo "Installationsfehler: Keine firstrun-config gefunden! Tue nichts..." >> /root/init.log
+ exit 0
+fi
+
+source "/root/installer/config" || { echo "Fehler beim Sourcen der firstrun-config." >> /root/init.log; exit 1; }
+
+if [ -z "$MYSQL_ROOT_PASS" ]; then
+ echo "Installationsfehler: WARNUNG: Aktuelles MySQL-root-Passwort nicht bekannt!" >> /root/init.log
+ exit 1
+fi
+
+MY_PID=$$
+perror() {
+ echo "$@" >> /root/init.log
+ [ "$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
+}
+
+echo "Lösche alte ssh-Schlüssel ..." >> /root/init.log
+rm -f /etc/ssh/ssh_host_*key* 2>/dev/null
+echo -n "... done."
+
+echo "Generating new ssh keys..." >> /root/init.log
+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 -n "... done." >> /root/init.log
+
+export LANG=de_DE.UTF-8
+
+echo "Generiere intern genutzte Passwörter (z.B. MySQL-Zugänge) neu ..." >> /root/init.log
+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
+
+echo "Konfigurationsdateien werden aktualisiert..." >> /root/init.log
+
+# 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 -n " ok." >> /root/init.log
+
+echo "Dienste werden aktiviert..." >> /root/init.log
+
+# inittab-entry dmsd:
+if ! grep -q "dmsd.*respawn" /etc/inittab; then
+ echo "dmsd:2:once:$DMSDDIR/dmsd.sh" >> /etc/inittab
+fi
+
+# inittab-entry taskmanager:
+if ! grep -q "tman.*respawn" /etc/inittab; then
+ echo "tman:2345:respawn:$TASKMANDIR/taskmanager.sh" >> /etc/inittab
+fi
+
+# inittab-entry syncdaemon:
+if ! grep -q "synd.*respawn" /etc/inittab; then
+ echo "synd:2:once:/opt/syncdaemon/syncdaemon.sh" >> /etc/inittab
+fi
+
+echo -n " ok." >> /root/init.log
+
+# 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
+
+sed -i "/rclocal_script.sh/d" /etc/rc.local
+unlink "/root/installer/config" 2>/dev/null
+unlink "/root/installer/rclocal_script.sh"
+
+exit 0
+