summaryrefslogtreecommitdiffstats
path: root/satellit_installer/static_files/system/root/installer/rclocal_script.sh
diff options
context:
space:
mode:
Diffstat (limited to 'satellit_installer/static_files/system/root/installer/rclocal_script.sh')
-rwxr-xr-xsatellit_installer/static_files/system/root/installer/rclocal_script.sh44
1 files changed, 20 insertions, 24 deletions
diff --git a/satellit_installer/static_files/system/root/installer/rclocal_script.sh b/satellit_installer/static_files/system/root/installer/rclocal_script.sh
index 07da0ee..78bf23c 100755
--- a/satellit_installer/static_files/system/root/installer/rclocal_script.sh
+++ b/satellit_installer/static_files/system/root/installer/rclocal_script.sh
@@ -2,7 +2,7 @@
MY_PID=$$
perror() {
- echo "$@" >> /root/init.log
+ echo "[ERROR] $*"
[ "$MY_PID" != "$$" ] && kill "$MY_PID"
if ! grep -q "rclocal_script.sh has thrown an error" /etc/motd; then
@@ -19,11 +19,14 @@ perror() {
exit 5
}
-echo "$(basename $0) gestartet: $(date "+%Y-%m-%d %H:%m:%S")" >> /root/init.log
+# Logfile
+exec &> /root/init.log
-[ -r "/root/installer/config" ] || perror "Installationsfehler: Keine firstrun-config gefunden!"
+echo "+++ $(basename "$0") gestartet: $(date "+%Y-%m-%d %H:%m:%S")"
-source "/root/installer/config" || { echo "Fehler beim Sourcen der firstrun-config." >> /root/init.log; exit 1; }
+[ -r "/root/installer/config" ] || perror "Installationsfehler: Keine firstrun-config gefunden!"
+
+source "/root/installer/config" || perror "Fehler beim Sourcen der firstrun-config."
generate_password() {
tr -dc _A-Za-z0-9 < /dev/urandom | head -c 16
@@ -41,20 +44,18 @@ patchfiles() {
done
}
-echo -n "Lösche alte ssh-Schlüssel ..." >> /root/init.log
-rm -f /etc/ssh/ssh_host_*key* 2>/dev/null
-echo " done."
+echo "+++ Lösche alte ssh-Schlüssel ..."
+rm -f -- /etc/ssh/ssh_host_*key* 2>/dev/null
-echo -n "Generating new ssh keys..." >> /root/init.log
+echo "+++ Generating new ssh 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 "... 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
+echo "+++ Generiere intern genutzte Passwörter (z.B. MySQL-Zugänge) neu ..."
umask 0077
MYSQL_SAT_NEW=$(generate_password)
@@ -63,7 +64,7 @@ echo "SET PASSWORD FOR 'sat'@'localhost' = PASSWORD('$MYSQL_SAT_NEW');" | mysql
MYSQL_OPENSLX_NEW=$(generate_password)
echo "SET PASSWORD FOR 'openslx'@'localhost' = PASSWORD('$MYSQL_OPENSLX_NEW');" | mysql -u root || perror "Neusetzen des openslx-MySQL-Passworts fehlgeschlagen."
-echo -n "Konfigurationsdateien werden aktualisiert..." >> /root/init.log
+echo "+++ Konfigurationsdateien werden aktualisiert..."
# sat mysql pass
# Patch dmsd
@@ -77,15 +78,12 @@ patchfiles "%MYSQL_OPENSLX_PASS%" "$MYSQL_OPENSLX_NEW" "$WWWDIR/slx-admin/co
TASKMANAGER_PASS=$(generate_password)
patchfile "%TM_OPENSLX_PASS%" "$TASKMANAGER_PASS" "$WWWDIR/slx-admin/config.php" "$TASKMANDIR/config/config"
-echo " ok." >> /root/init.log
-
-echo "Dienste werden aktiviert..." >> /root/init.log
+echo "+++ Dienste werden aktiviert..."
# Enable bwLehrpool related services
for i in dmsd.service taskmanager.service; do
- systemctl enable $i
- [ $? -ne 0 ] && echo "Warnung - konnte systemd-Service $i nicht aktivieren!" >> /root/init.log
- systemctl start $i
+ systemctl enable "$i" || echo "Warnung - konnte systemd-Service $i nicht aktivieren!"
+ systemctl --no-block start "$i"
done
# Write MOTD
@@ -102,12 +100,10 @@ Andere Modifikationen am System sind in der Regel nicht notwendig.
THEREDOC
-# Write version to /etc/sat_version
-echo "$VERSION" > /etc/sat_version
+echo "+++ Daten des Firstrun-Scripts werden aufgeräumt..."
+unlink "/root/installer/config"
+unlink "/root/installer/rclocal_script.sh"
+unlink "/etc/systemd/system/firstboot.service"
+unlink "/etc/systemd/system/multi-user.target.wants/firstboot.service"
-sed -i "/rclocal_script.sh/d" /etc/rc.local
-unlink "/root/installer/config" 2>/dev/null
-unlink "/root/installer/rclocal_script.sh" 2>/dev/null
-mv /etc/rc.local.sik /etc/rc.local
exit 0
-