summaryrefslogtreecommitdiffstats
path: root/satellit_installer/includes
diff options
context:
space:
mode:
authorSimon Rettberg2020-12-18 11:14:17 +0100
committerSimon Rettberg2020-12-18 11:14:17 +0100
commit771de25bbf64c13ec56721753d8c9625ced752cd (patch)
treeda06ec916aca33e21f99da2c22905c9b5ba40a59 /satellit_installer/includes
parent[SSPS] Fix vmware SCSI timeout increase (diff)
downloadsetup-scripts-771de25bbf64c13ec56721753d8c9625ced752cd.tar.gz
setup-scripts-771de25bbf64c13ec56721753d8c9625ced752cd.tar.xz
setup-scripts-771de25bbf64c13ec56721753d8c9625ced752cd.zip
[SSPS] Transform heredocs to regular files
Diffstat (limited to 'satellit_installer/includes')
-rw-r--r--satellit_installer/includes/10-script_dropper.inc47
-rw-r--r--satellit_installer/includes/50-install_bwSuite_server.inc65
-rw-r--r--satellit_installer/includes/70-write_tmate_config.inc12
3 files changed, 10 insertions, 114 deletions
diff --git a/satellit_installer/includes/10-script_dropper.inc b/satellit_installer/includes/10-script_dropper.inc
index efae442..62d1b58 100644
--- a/satellit_installer/includes/10-script_dropper.inc
+++ b/satellit_installer/includes/10-script_dropper.inc
@@ -1,9 +1,11 @@
patch_profile() {
- if grep -q "/root/installer/firstrun.sh" /root/.profile; then
+ local script="/root/installer/firstrun_script.sh"
+ [ -x "$script" ] || perror "Firstrun script not found ($script)"
+ if grep -qF "$script" /root/.profile; then
echo "# first_run script already in root's .profile, doing nothing."
else
echo "# Patching root's .profile"
- echo "/root/installer/firstrun_script.sh" >> /root/.profile
+ echo "$script" >> /root/.profile
fi
}
@@ -14,46 +16,9 @@ drop_script() {
chmod 0600 /root/installer/config
}
-drop_keychanger_rclocal() {
- if grep -q -F "/root/installer/rclocal_script.sh" /etc/rc.local; then
- echo "# ssh key changer already in rc.local; doing nothing."
- else
- echo
- echo "# Patching rc.local..."
- cp -p /etc/rc.local /etc/rc.local.sik
- cat > /etc/rc.local <<-HIERDOK
- #!/bin/bash
- echo "rc.local created: $(date "+%Y-%m-%d %H:%m:%S")" >> /root/init.log
- echo "Starting /root/installer/rclocal_script.sh..." >> /root/init.log
- /root/installer/rclocal_script.sh
- exit 0
- HIERDOK
- chmod +x /etc/rc.local
- fi
- # WTF? Why forking?
- cat > /etc/systemd/system/rc-local.service <<-DORTDOK
- [Unit]
- Description=/etc/rc.local Compatibility
- ConditionFileIsExecutable=/etc/rc.local
- After=network.target mysql.service
-
- [Service]
- Type=forking
- ExecStart=/etc/rc.local start
- TimeoutSec=0
- RemainAfterExit=yes
- SysVStartPriority=99
-
- [Install]
- WantedBy=multi-user.target
- DORTDOK
-
- systemctl daemon-reload
- systemctl reenable rc-local || perror "Could not enable systemd service rc-local!"
-}
-
drop_firstrun_script () {
patch_profile
drop_script
- drop_keychanger_rclocal
+ systemctl daemon-reload
+ systemctl enable firstboot.service || perror "Could not enable firstboot service"
}
diff --git a/satellit_installer/includes/50-install_bwSuite_server.inc b/satellit_installer/includes/50-install_bwSuite_server.inc
index 85a8904..2b89126 100644
--- a/satellit_installer/includes/50-install_bwSuite_server.inc
+++ b/satellit_installer/includes/50-install_bwSuite_server.inc
@@ -1,71 +1,14 @@
-config_bwSuite_server() {
- # $1: Path to server directory
- cat > "$1/config.properties" <<-EOF
- vmstore.path = /srv/openslx/nfs
- db.uri = jdbc:mysql://localhost/sat?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&characterSetResults=utf8&connectionCollation=utf8mb4_unicode_ci
- db.username = sat
- db.password = %MYSQL_SAT_PASS%
- db.location-table = openslx.location
- master.address = bwlp-masterserver.ruf.uni-freiburg.de
- EOF
-
- chown root:images "$1/config.properties"
- chmod 0640 "$1/config.properties"
-}
-
-install_bwSuite_service() {
- # $1: Path to server directory
- cat > "/etc/systemd/system/dmsd.service" <<-EOF
- [Unit]
- Description=DMSD is the Dozentenmodul server daemon
- Wants=mysql.service
- After=mysql.service
-
- [Service]
- User=dmsd
- Group=images
- WorkingDirectory=$1
- ExecStart=$1/dmsd.sh
- Restart=always
- RestartSec=5
- SyslogIdentifier=dmsd
- StandardOutput=syslog
- StandardError=syslog
-
- [Install]
- WantedBy=multi-user.target
- EOF
- cat > "$1/dmsd.sh" <<-EOF
- #!/bin/sh
-
- KB=\$($(which grep) ^MemTotal /proc/meminfo | $(which awk) '{print \$2}')
- [ -z "\$KB" ] && KB=600000
- if [ "\$KB" -gt 4096000 ]; then
- MB=\$(( \$KB / ( 1024 * 3 ) + 667 ))
- else
- MB=\$(( \$KB / ( 1024 * 2 ) ))
- fi
- if [ "\$MB" -gt 2000 ] && ! $(which java) -version 2>&1 | $(which grep) -q '64-Bit'; then
- MB=2000
- fi
- [ "\$MB" -lt 190 ] && MB=190
- [ "\$MB" -gt 4500 ] && MB=4500
-
- exec $(which java) -Xmx\${MB}M -jar dmsd.jar
- EOF
- chmod +x "$1/dmsd.sh"
-}
-
install_bwSuite_server() {
# $1: directory to install server to
echo "# Installing server part of bwSuite... "
- mkdir -p "$1" 2>/dev/null
+ mkdir -p "$1" || perror "Cannot create $1"
install -m 0644 -p -o root -g root "$BASEDIR/static_files/dmsd.jar" "$1/dmsd.jar" \
|| perror "Could not install dmsd.jar"
chown -R root:root "$1"
chmod -R go-w "$1"
- config_bwSuite_server "$1"
- install_bwSuite_service "$1"
+ install_files "dmsd"
+ chown root:images "$1/config.properties"
+ chmod 0640 "$1/config.properties"
}
diff --git a/satellit_installer/includes/70-write_tmate_config.inc b/satellit_installer/includes/70-write_tmate_config.inc
deleted file mode 100644
index bd68ef4..0000000
--- a/satellit_installer/includes/70-write_tmate_config.inc
+++ /dev/null
@@ -1,12 +0,0 @@
-write_tmate_config() {
- echo -n "# Writing tmate config... "
- [ -d /root/.tmate.conf ] && mv /root/.tmate.conf.old # Unnecessary here, but...
- cat > /root/.tmate.conf <<-JUSTANOTHERDOC
- set -g tmate-server-host "tmate.ruf.uni-freiburg.de"
- set -g tmate-server-port 2222
- set -g tmate-server-rsa-fingerprint "d7:d7:06:d0:b6:0d:75:a1:ad:ec:69:18:b3:a3:c0:4a"
- set -g tmate-server-ecdsa-fingerprint "4f:c9:81:f1:1a:20:7d:6f:97:12:f2:a9:0f:f4:c5:6c"
- set -g tmate-identity ""
- JUSTANOTHERDOC
- echo "done."
-}