From f6e87d351413b9b2b3a09ffd54d71ebc4280222a Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Tue, 16 Jun 2020 10:57:41 +0200 Subject: #981 Use new ogServer systemd unit file This commit adapts installer, updater and init scripts to work with new ogServer systemd unit file. --- admin/Sources/Services/opengnsys.init | 13 ------------- installer/opengnsys_installer.sh | 6 ++++++ installer/opengnsys_update.sh | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/admin/Sources/Services/opengnsys.init b/admin/Sources/Services/opengnsys.init index ef5a5b8c..8917e2b5 100755 --- a/admin/Sources/Services/opengnsys.init +++ b/admin/Sources/Services/opengnsys.init @@ -22,10 +22,7 @@ CLIENTLOGDIR=$BASEDIR/log/clients # Servidor de OpenGnsys # SERVERNAME=ogAdmServer -SERVERDAEMON=$BASEDIR/sbin/$SERVERNAME SERVERCFG=$BASEDIR/etc/$SERVERNAME.cfg -SERVERLOG=$BASEDIR/log/$SERVERNAME.log -SERVERDAEMON_OPTIONS="-f $SERVERCFG -l $SERVERLOG" # # Servidor de Repositorio @@ -76,9 +73,7 @@ config() { case "$OSDISTRIB" in ubuntu|debian|linuxmint) INITFUNCTIONS=/lib/lsb/init-functions - DAEMONSTART="start-stop-daemon --start --quiet --background --exec" EXTRAOPTS="--" - DAEMONSTOP="start-stop-daemon --stop --quiet --oknodo --name" ACTIONMSG="log_daemon_msg" SUCCESSMSG="log_end_msg 0" FAILMSG="log_end_msg 1" @@ -90,9 +85,7 @@ config() { ;; centos|fedora) INITFUNCTIONS=/etc/init.d/functions - DAEMONSTART="daemon" ENDOPTS="&" - DAEMONSTOP="killproc" ACTIONMSG="echo -n" SUCCESSMSG="eval ( success; echo )" FAILMSG="eval ( failure; echo )" @@ -133,9 +126,6 @@ arranca_demonios() { fi # Arrancar los servicios indicados. if [ $RUN_OGADMSERVER = "yes" ]; then - $ACTIONMSG "Iniciando demonio: $SERVERNAME" - $DAEMONSTART $SERVERDAEMON $EXTRAOPTS $SERVERDAEMON_OPTIONS $ENDOPTS - [ $? = 0 ] && $SUCCESSMSG || $FAILMSG # Para SetBootmode desde el cliente $ACTIONMSG "Iniciando demonio: $SERVERAUXNAME" # faucet $SERVERAUXPORT --daemon --in bash -c "$SERVERAUXDAEMON" # NUEVO @@ -175,9 +165,6 @@ para_demonios() { $ACTIONMSG "Parando demonio: $REPOAUXNAME" pkill faucet [ $? -le 1 ] && $SUCCESSMSG || $FAILMSG - $ACTIONMSG "Parando demonio: $SERVERNAME" - $DAEMONSTOP $SERVERNAME - [ $? = 0 ] && $SUCCESSMSG || $FAILMSG } config diff --git a/installer/opengnsys_installer.sh b/installer/opengnsys_installer.sh index b95e6ad7..ec0d3c74 100755 --- a/installer/opengnsys_installer.sh +++ b/installer/opengnsys_installer.sh @@ -1480,6 +1480,8 @@ function openGnsysConfigure() cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.service \ /lib/systemd/system/opengnsys.service + cp -a $WORKDIR/ogServer-$BRANCH/cfg/ogserver.service \ + /lib/systemd/system/ogserver.service cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.default /etc/default/opengnsys # Deshabilitar servicios de BitTorrent si no están instalados. if [ ! -e /usr/bin/bttrack ]; then @@ -1559,6 +1561,10 @@ EOT $STARTSERVICE fi + # Enable and start ogServer systemd service + service="ogserver" + $ENABLESERVICE; $STARTSERVICE + echoAndLog "${FUNCNAME}(): Creating ogClient config files." sed -i -e "s/127\.0\.0\.1/$OPENGNSYS_SERVERIP/g" \ $INSTALL_TARGET/client/ogClient/cfg/ogclient.json diff --git a/installer/opengnsys_update.sh b/installer/opengnsys_update.sh index 29cdb910..ffe262d8 100755 --- a/installer/opengnsys_update.sh +++ b/installer/opengnsys_update.sh @@ -1092,6 +1092,25 @@ function ogServerCompilation() grep -q "APITOKEN=" $INSTALL_TARGET/etc/ogAdmServer.cfg || \ $INSTALL_TARGET/bin/settoken -f + if ! diff -q \ + "$WORKDIR"/ogServer-"$BRANCH"/cfg/ogserver.service \ + /lib/systemd/system/ogserver.service 2>/dev/null; then + service="opengnsys" + $STOPSERVICE + echoAndLog "${FUNCNAME}(): updating new service file" + backupFile /lib/systemd/system/ogserver.service + service="ogadmserver" + $STOPSERVICE + cp -a \ + "$WORKDIR"/ogServer-"$BRANCH"/cfg/ogserver.service \ + /lib/systemd/system/ogserver.service + systemctl daemon-reload + $STARTSERVICE + service="opengnsys" + $STARTSERVICE + NEWFILES="$NEWFILES /lib/systemd/system/ogserver.service" + fi + return $error } -- cgit v1.2.3-18-g5258