diff options
author | Simon Rettberg | 2015-09-18 16:35:30 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-09-18 16:35:30 +0200 |
commit | e5e316c0e900968f787ad671db9abecde55d2df6 (patch) | |
tree | b44b1bc746bc5b95924945af5db275245b2b48be | |
parent | [SSPS] Remove obsolete files (diff) | |
download | setup-scripts-e5e316c0e900968f787ad671db9abecde55d2df6.tar.gz setup-scripts-e5e316c0e900968f787ad671db9abecde55d2df6.tar.xz setup-scripts-e5e316c0e900968f787ad671db9abecde55d2df6.zip |
[SSPS] Introduce upper and lower memory bounds for dmsd memory, move heredocs around
4 files changed, 82 insertions, 84 deletions
diff --git a/satellit_installer/includes/00-variables.inc b/satellit_installer/includes/00-variables.inc index 30b691c..96ba7bd 100644 --- a/satellit_installer/includes/00-variables.inc +++ b/satellit_installer/includes/00-variables.inc @@ -36,6 +36,6 @@ PACKAGELIST_WITH_RECOMMENDS=" ### http for static files: HTTP_BASE="http://files.bwlp.ks.uni-freiburg.de/install/" -HTTP_FILES="bwLehrpoolSuite_Server.jar db_openslx_dump.sql openslx_tftp.tar.gz" +HTTP_FILES="dmsd.jar db_openslx_dump.sql openslx_tftp.tar.gz" HTTP_FILES+=" taskmanager.tar.gz db_sat_dump.sql openslx.tar.gz" HTTP_FILES+=" slx-admin.tar.gz syslinux6.tar.gz syslinux4.tar.gz" diff --git a/satellit_installer/includes/50-install_bwSuite_server.inc b/satellit_installer/includes/50-install_bwSuite_server.inc index d3a6cd1..c783eeb 100644 --- a/satellit_installer/includes/50-install_bwSuite_server.inc +++ b/satellit_installer/includes/50-install_bwSuite_server.inc @@ -1,28 +1,62 @@ config_bwSuite_server() { # $1: Path to server directory - echo -n "# Writing configuration for bwSuite server..." - echo "vmstore.path = /srv/openslx/nfs" > "$1/config.properties" - echo "db.uri = jdbc:mysql://localhost/sat?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&characterSetResults=utf8&connectionCollation=utf8mb4_unicode_ci" >> "$1/config.properties" - echo "db.username = sat" >> "$1/config.properties" - echo "db.password = %MYSQL_SAT_PASS%" >> "$1/config.properties" - echo "master.address = bwlp-masterserver.ruf.uni-freiburg.de" >> "$1/config.properties" + 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% + master.address = bwlp-masterserver.ruf.uni-freiburg.de + EOF chown dmsd:images "$1/config.properties" - chmod 0640 "$1/config.properties" - echo "ok." + chmod 0600 "$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 + MB=\$(( \$KB / 1024 )) + [ "\$MB" -gt 2000 ] MB=2000 + [ "\$MB" -lt 190 ] MB=190 + + exec $(which java) -Xmx\${MB}M -jar dmsd.jar + EOF } install_bwSuite_server() { # $1: directory to install server to - echo -n "# Installing server part of bwSuite... " + echo "# Installing server part of bwSuite... " mkdir -p "$1" 2>/dev/null - mkdir -p "$1/flag" - cp -p "$BASEDIR/static_files/bwLehrpoolSuite_Server.jar" "$1/bwLehrpoolSuite_Server.jar" + 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" - touch "$1/flag/run" # Set run flag right from the start - chown -R dmsd: "$1/flag" - echo "ok." config_bwSuite_server "$1" + install_bwSuite_service "$1" } + diff --git a/satellit_installer/includes/50-install_taskmanager.inc b/satellit_installer/includes/50-install_taskmanager.inc index 3a0d59a..41ef56c 100644 --- a/satellit_installer/includes/50-install_taskmanager.inc +++ b/satellit_installer/includes/50-install_taskmanager.inc @@ -1,11 +1,32 @@ +install_taskmanager_service() { + # $1: directory to install taskmanager to + cat > /etc/systemd/system/taskmanager.service <<-SOMEWHEREDOC + [Unit] + Description=Taskmanager is a bwLehrpool service daemon + + [Service] + User=taskmanager + Group=taskmanager + WorkingDirectory=$1 + ExecStart=$(which java) -Xmx80M -jar taskmanager.jar + Restart=always + RestartSec=5 + SyslogIdentifier=taskmanager + StandardOutput=syslog + StandardError=syslog + + [Install] + WantedBy=multi-user.target + SOMEWHEREDOC +} + install_taskmanager() { - # $1: directory to install server to + # $1: directory to install taskmanager to echo -n "# Installing taskmanager... " mkdir -p "$1" 2>/dev/null - cp -p "$BASEDIR/static_files/taskmanager.sh" "$1" - # cp -p "$BASEDIR/static_files/Taskmanager.jar" "$1/Taskmanager.jar" unpack_tar_gz "$BASEDIR/static_files/taskmanager.tar.gz" "-C $1" - cp "$BASEDIR/static_files/slx-admin" /etc/cron.d/ + cp "$BASEDIR/static_files/slx-admin" /etc/cron.d/ # TODO: Find better place for this + install_taskmanager_service chown -R root:root "$1" echo "ok" } diff --git a/satellit_installer/static_files/rclocal_script.sh b/satellit_installer/static_files/rclocal_script.sh index 758a203..07a69d3 100644 --- a/satellit_installer/static_files/rclocal_script.sh +++ b/satellit_installer/static_files/rclocal_script.sh @@ -83,74 +83,17 @@ echo " ok." >> /root/init.log echo -n "Dienste werden aktiviert..." >> /root/init.log -if [ $(ps -p 1 -o comm=) = systemd ]; then - echo "Systemd erkannt (systemctl vorhanden)." >> /root/init.log - if [ ! -f /etc/systemd/system/dmsd.service ]; then - cat > /etc/systemd/system/dmsd.service <<-HEREDOC - [Unit] - Description=DMSD is the Dozentenmodul server daemon - - [Service] - ExecStartPre=/bin/sh -c "/bin/echo -n 'RAM='>/tmp/dmsd_environment; echo \$(( \$(/usr/bin/free -m | /bin/grep Mem|/usr/bin/tr -s ' '|/usr/bin/cut -f 2 -d ' ') / 3 ))>>/tmp/dmsd_environment" - EnvironmentFile=-/tmp/dmsd_environment - - User=dmsd - Group=images - WorkingDirectory=$DMSDDIR - ExecStart=$(which java) -Xmx\${RAM}M -jar bwLehrpoolSuite_Server.jar - Restart=always - RestartSec=5 - SyslogIdentifier=dmsd - StandardOutput=syslog - StandardError=syslog - - [Install] - WantedBy=multi-user.target - HEREDOC - echo "dmsd.service geschrieben." >> /root/init.log - fi - if [ ! -f /etc/systemd/system/taskmanager.service ]; then - cat > /etc/systemd/system/taskmanager.service <<-SOMEWHEREDOC - [Unit] - Description=Taskmanager is a bwLehrpool service daemon - - [Service] - User=taskmanager - Group=taskmanager - WorkingDirectory=$TASKMANDIR - ExecStart=$(which java) -Xmx80M -jar taskmanager.jar - Restart=always - RestartSec=5 - SyslogIdentifier=taskmanager - StandardOutput=syslog - StandardError=syslog - - [Install] - WantedBy=multi-user.target - SOMEWHEREDOC - echo "taskmanager.service geschrieben." >> /root/init.log - fi - for i in dmsd.service taskmanager.service; do - systemctl enable $i - [ $? -ne 0 ] && echo "Warnung - konnte systemd-Service $i nicht aktivieren!" >> /root/init.log - done -else - # No systemctl -> no systemd, so: 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 -fi +# 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 +done echo -n " ok." >> /root/init.log # Write MOTD -cat > /etc/motd <<-THEREDOC - *** bwLehrpool Satelliten-Server, Version $VERSION *** - Eingerichtet am $(date) +cat > /etc/motd <<THEREDOC + *** bwLehrpool Satelliten-Server, Version $VERSION *** + Eingerichtet am $(date) Wenn Sie sich als root eingeloggt haben, haben Sie nun folgende Optionen: netsetup - Konfiguriert das Netzwerk-Interface neu (DHCP oder statisch) |