summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2014-11-18 14:18:07 +0100
committerSimon Rettberg2014-11-18 14:18:07 +0100
commit0f3adf1b54a23fdc36e82a8e8ed1ef64646098d3 (patch)
tree660b85142c62cf5afffbc4d87d73f8293e7eea08
parentInclude for common java daemon respawning/start control (diff)
downloadsetup-scripts-0f3adf1b54a23fdc36e82a8e8ed1ef64646098d3.tar.gz
setup-scripts-0f3adf1b54a23fdc36e82a8e8ed1ef64646098d3.tar.xz
setup-scripts-0f3adf1b54a23fdc36e82a8e8ed1ef64646098d3.zip
[SSPS] Changed the way dmsd and syncdaemon are started and stopped.
Also added a few more patches to bashrc and vimrc
-rw-r--r--satellit_installer/includes/50-copyscripts.inc10
-rw-r--r--satellit_installer/includes/90-patch_misc_files.inc (renamed from satellit_installer/includes/90-set_prompt.inc)9
-rwxr-xr-xsatellit_installer/satellit_installer8
-rwxr-xr-xsatellit_installer/static_files/dmsd/control.sh34
-rwxr-xr-xsatellit_installer/static_files/dmsd/dmsd.sh23
-rw-r--r--satellit_installer/static_files/firstrun_script.sh5
-rwxr-xr-xsatellit_installer/static_files/syncdaemon/control.sh63
-rwxr-xr-xsatellit_installer/static_files/syncdaemon/syncdaemon.sh25
8 files changed, 117 insertions, 60 deletions
diff --git a/satellit_installer/includes/50-copyscripts.inc b/satellit_installer/includes/50-copyscripts.inc
index 317bf2c..b964e02 100644
--- a/satellit_installer/includes/50-copyscripts.inc
+++ b/satellit_installer/includes/50-copyscripts.inc
@@ -11,3 +11,13 @@ install_config_static_ip() {
cp "$BASEDIR/static_files/netsetup" /usr/local/sbin
echo "ok."
}
+
+install_javadaemon() {
+ cp -a "$BASEDIR/static_files/java-daemon.inc" "/opt/" || perror "Could not install java-daemon.inc"
+}
+
+install_pidtree() {
+ mkdir -p "/usr/local/bin"
+ cp -a "$BASEDIR/static_files/pidtree" "/usr/local/bin/" || perror "Could not install pidtree"
+}
+
diff --git a/satellit_installer/includes/90-set_prompt.inc b/satellit_installer/includes/90-patch_misc_files.inc
index 7528ad9..aaaceeb 100644
--- a/satellit_installer/includes/90-set_prompt.inc
+++ b/satellit_installer/includes/90-patch_misc_files.inc
@@ -1,4 +1,4 @@
-set_prompt() {
+patch_bashrc() {
echo "#"
echo "# As one of the last things here we will set a new prompt to distinguish"
echo "# the beLehrpool satellite server from other servers. To accomplish this"
@@ -12,4 +12,11 @@ set_prompt() {
echo 'PS1="\[\033[01;31m\]\u\[\033[00m\]@\[\033[01;32m\]\h \[\033[01;34m\]\w\[\033[00m\] # "' >> /root/.bashrc
echo " ok."
fi
+ # aliases, dircolors
+ sed -i -r 's/# *(alias|export LS|eval ")/\1/' /root/.bashrc
}
+
+patch_vim() {
+ sed -i -r 's/" *(syntax|set background|set showmatch|set smartcase|set incsearch)/\1/' /etc/vim/vimrc
+}
+
diff --git a/satellit_installer/satellit_installer b/satellit_installer/satellit_installer
index b34766d..ec5b1d4 100755
--- a/satellit_installer/satellit_installer
+++ b/satellit_installer/satellit_installer
@@ -137,13 +137,19 @@ install_tmpdelete
# block device timeout (sd*) from 30 to 180 using an udev rule.
set_vmware_device_timeout
-set_prompt
+# color prompt, aliases
+patch_bashrc
+# vim config
+patch_vim
setup_logging
# This part drops a script and anchors it's execution within root's .profile:
drop_firstrun_script
+install_javadaemon
+install_pidtree
+
# Activate 'purge_install' here - but be careful! This is for debugging purposes only!
# purge_install
diff --git a/satellit_installer/static_files/dmsd/control.sh b/satellit_installer/static_files/dmsd/control.sh
index 56050bb..2273ddd 100755
--- a/satellit_installer/static_files/dmsd/control.sh
+++ b/satellit_installer/static_files/dmsd/control.sh
@@ -1,25 +1,51 @@
#!/bin/sh
DIR="/opt/dmsd"
-JAR="bwLehrpoolSuite_Server"
MODE=$1
FLAG="$DIR/flag/run"
+STATUS="$DIR/flag/running"
if [ -z "$MODE" ]; then
echo "No option given!" >&2
exit 1
fi
+ispid () {
+ [ -n "$1" ] && [ -d "/proc/$1" ]
+}
+
+cd "$DIR" || exit 1
+
op_start () {
touch "$FLAG"
}
op_stop () {
+ echo "Stopping bwLehrpoolSuite Server..."
+ local PID=
+ local p=
+ local PROC=
+ # Delete run-flag
rm -f -- "$FLAG"
- for PID in $(ps ax | grep "java.*-jar.*${JAR}" | awk '{print $1}'); do
- kill "$PID"
- done
+ [ -r "$STATUS" ] && PID=$(cat "$STATUS")
+ ispid "$PID" || PID=
+ # If PID is still set, we can kill it....
+ if [ -n "$PID" ]; then
+ kill -TERM $(pidtree "$PID") 2>/dev/null
+ for p in 1 2 3 4 force error; do
+ ispid "$PID" || break
+ if [ "$p" == "error" ]; then
+ echo "...FAILED!"
+ exit 1
+ fi
+ echo "..."
+ sleep 1
+ [ "$p" == "force" ] && kill -9 "$PID"
+ done
+ fi
+ [ -r "$STATUS" ] && sleep 1
+ echo "OK!"
}
case "$MODE" in
diff --git a/satellit_installer/static_files/dmsd/dmsd.sh b/satellit_installer/static_files/dmsd/dmsd.sh
index 82c746a..b6a19f6 100755
--- a/satellit_installer/static_files/dmsd/dmsd.sh
+++ b/satellit_installer/static_files/dmsd/dmsd.sh
@@ -2,23 +2,12 @@
# This is a simple wrapper script for the Dozentenmodul server part
# Running as root from inittab
-FLAGDIR="/opt/dmsd/flag"
+DIR="/opt/dmsd"
+JAR="bwLehrpoolSuite_Server.jar"
+USER="dmsd"
+LOGTAG="dmsd"
+DISPLAYNAME="bwLehrpoolSuite Server"
-umask 0022
-mkdir -p "$FLAGDIR"
-chmod 0755 "$FLAGDIR"
-rm -f -- "${FLAGDIR}/running"
-
-while true; do
- if [ -e "${FLAGDIR}/run" ]; then
- /bin/su -s /bin/sh -c 'cd /opt/dmsd; java -Xmx80M -jar ./bwLehrpoolSuite_Server.jar 2>&1 | logger -t dmsd' dmsd &
- PID=$!
- echo $PID > "${FLAGDIR}/running"
- wait $PID
- rm -f -- "${FLAGDIR}/running"
- [ -e "${FLAGDIR}/run" ] && php /srv/openslx/www/slx-admin/api.php "event" "warning" "dozmod-server: Unexpected exit/crash."
- fi
- sleep 10
-done
+. "/opt/java-daemon.inc"
diff --git a/satellit_installer/static_files/firstrun_script.sh b/satellit_installer/static_files/firstrun_script.sh
index c1ac07a..bf5a3ed 100644
--- a/satellit_installer/static_files/firstrun_script.sh
+++ b/satellit_installer/static_files/firstrun_script.sh
@@ -90,6 +90,7 @@ cat > /etc/motd <<-THEREDOC
poweroff - System herunterfahren
Andere Modifikationen am System sind in der Regel nicht notwendig.
+
THEREDOC
echo "Konfigurationsdateien werden aktualisiert..."
@@ -111,7 +112,7 @@ echo "Dienste werden aktiviert..."
# inittab-entry dmsd:
if ! grep -q "dmsd.*respawn" /etc/inittab; then
- echo "dmsd:2345:respawn:$DMSDDIR/dmsd.sh" >> /etc/inittab
+ echo "dmsd:2:once:$DMSDDIR/dmsd.sh" >> /etc/inittab
fi
# inittab-entry taskmanager:
@@ -121,7 +122,7 @@ fi
# inittab-entry syncdaemon:
if ! grep -q "synd.*respawn" /etc/inittab; then
- echo "synd:2345:respawn:/opt/syncdaemon/syncdaemon.sh" >> /etc/inittab
+ echo "synd:2:once:/opt/syncdaemon/syncdaemon.sh" >> /etc/inittab
fi
echo
diff --git a/satellit_installer/static_files/syncdaemon/control.sh b/satellit_installer/static_files/syncdaemon/control.sh
index 0d5911b..37e8fd2 100755
--- a/satellit_installer/static_files/syncdaemon/control.sh
+++ b/satellit_installer/static_files/syncdaemon/control.sh
@@ -5,55 +5,84 @@ JAR="syncdaemon.jar"
MODE=$1
FLAG="$DIR/flag/run"
+STATUS="$DIR/flag/running"
if [ -z "$MODE" ]; then
echo "No option given!" >&2
exit 1
fi
-cd "$DIR"
+ispid () {
+ [ -n "$1" ] && [ -d "/proc/$1" ]
+}
+
+cd "$DIR" || exit 1
op_start () {
touch "$FLAG"
}
op_stop () {
+ echo "Stopping syncdaemon..."
+ local PID=
+ local p=
+ local PROC=
+ # Delete run-flag
rm -f -- "$FLAG"
- for PID in $(ps ax | grep "java.*-jar.*${JAR}" | awk '{print $1}'); do
- kill "$PID"
- done
+ [ -r "$STATUS" ] && PID=$(cat "$STATUS")
+ ispid "$PID" || PID=
+ # If PID is still set, we can kill it....
+ if [ -n "$PID" ]; then
+ kill -TERM $(pidtree "$PID") 2>/dev/null
+ for p in 1 2 3 4 force error; do
+ ispid "$PID" || break
+ if [ "$p" == "error" ]; then
+ echo "...FAILED!"
+ exit 1
+ fi
+ echo "..."
+ sleep 1
+ [ "$p" == "force" ] && kill -9 "$PID"
+ done
+ fi
+ [ -r "$STATUS" ] && sleep 1
+ echo "OK!"
}
op_checkconfig () {
- java -jar "$JAR" --checkconfig
+ java -Xmx64M -jar "$JAR" --checkconfig
RET=$?
exit "$RET"
}
op_import () {
- cat > "$DIR/config/identity.properties" <<-HIERDOCK
- ORGANIZATION_NAME=$1
- MODULUS=$2
- PRIVATE_EXPONENT=$3
- PUBLIC_EXPONENT=$4
- HIERDOCK
+ # --import <ORGANIZATIONNAME> <MODULUS> <PRIV_EXP> <PUB_EXP>
+ java -Xmx64M -jar "$JAR" --import "$@"
+ RET=$?
chmod 0600 "$DIR/config/identity.properties"
+ exit "$RET"
}
op_submitkey () {
- java -jar "$JAR" --submitkey "$@"
+ # --submitkey <IPADDRESS>
+ java -Xmx64M -jar "$JAR" --submitkey "$@"
RET=$?
exit "$RET"
}
op_updateaddress () {
- java -jar "$JAR" --updateaddress "$@"
+ # --updateaddress <IPADDRESS>
+ java -Xmx64M -jar "$JAR" --updateaddress "$@"
RET=$?
exit "$RET"
}
op_genid () {
- java -jar "$JAR" --genid
+ # --genid <ORGANIZANTIONNAME>
+ java -Xmx64M -jar "$JAR" --genid "$@"
+ RET=$?
+ chmod 0600 "$DIR/config/identity.properties"
+ exit "$RET"
}
case "$MODE" in
@@ -64,11 +93,11 @@ stop)
checkconfig)
op_checkconfig ;;
submitkey)
- op_submitkey ;;
+ op_submitkey "$@" ;;
updateaddress)
- op_updateaddress ;;
+ op_updateaddress "$@" ;;
genid)
- op_genid ;;
+ op_genid "$@" ;;
import)
shift
op_import "$@"
diff --git a/satellit_installer/static_files/syncdaemon/syncdaemon.sh b/satellit_installer/static_files/syncdaemon/syncdaemon.sh
index c5f0f77..0433fa1 100755
--- a/satellit_installer/static_files/syncdaemon/syncdaemon.sh
+++ b/satellit_installer/static_files/syncdaemon/syncdaemon.sh
@@ -1,24 +1,13 @@
#!/bin/sh
-# This is a simple wrapper script for the Dozentenmodul server part
+# This is a simple wrapper script for the Sync-Daemon
# Running as root from inittab
-FLAGDIR="/opt/syncdaemon/flag"
+DIR="/opt/syncdaemon"
+JAR="syncdaemon.jar"
+USER="syncdaemon"
+LOGTAG="syncdaemon"
+DISPLAYNAME="syncdaemon"
-umask 0022
-mkdir -p "$FLAGDIR"
-chmod 0755 "$FLAGDIR"
-rm -f -- "${FLAGDIR}/running"
-
-while true; do
- if [ -e "${FLAGDIR}/run" ]; then
- /bin/su -s /bin/sh -c 'cd /opt/syncdaemon; java -Xmx80M -jar ./syncdaemon.jar 2>&1 | logger -t syncdaemon' syncdaemon &
- PID=$!
- echo $PID > "${FLAGDIR}/running"
- wait $PID
- rm -f -- "${FLAGDIR}/running"
- [ -e "${FLAGDIR}/run" ] && php /srv/openslx/www/slx-admin/api.php event "warning" "syncdaemon: Unexpected exit/crash."
- fi
- sleep 10
-done
+. "/opt/java-daemon.inc"