From 2ddeadc34264844bb779af5cb178868228306bb4 Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Thu, 7 May 2020 11:34:18 +0200 Subject: #981 Add systemd unit file The ogAdmServer needs to be started after MySQL, because it queries the DB at the beginning to obtain the schedules. This commit adds a systemd unit file that force OpenGnsys service to start after MySQL service --- admin/Sources/Services/opengnsys.service | 25 +++++++++++++++++++++++++ installer/opengnsys_installer.sh | 2 ++ installer/opengnsys_update.sh | 14 ++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 admin/Sources/Services/opengnsys.service diff --git a/admin/Sources/Services/opengnsys.service b/admin/Sources/Services/opengnsys.service new file mode 100644 index 00000000..89b8c492 --- /dev/null +++ b/admin/Sources/Services/opengnsys.service @@ -0,0 +1,25 @@ +# OpenGnsys systemd service file + +[Unit] +Documentation=https://opengnsys.es/trac/wiki/En%3ADocumentacionUsuario +SourcePath=/etc/init.d/opengnsys +Description=LSB: OpenGnsys system services +Before=multi-user.target +Before=graphical.target +Requires=mysql.service +After=mysql.service + +[Install] +WantedBy=multi-user.target + +[Service] +Type=forking +Restart=no +TimeoutSec=5min +IgnoreSIGPIPE=no +KillMode=process +GuessMainPID=no +RemainAfterExit=yes +SuccessExitStatus=5 6 +ExecStart=/etc/init.d/opengnsys start +ExecStop=/etc/init.d/opengnsys stop diff --git a/installer/opengnsys_installer.sh b/installer/opengnsys_installer.sh index 2553ab76..cde604c3 100755 --- a/installer/opengnsys_installer.sh +++ b/installer/opengnsys_installer.sh @@ -1461,6 +1461,8 @@ function openGnsysConfigure() echoAndLog "${FUNCNAME}(): Copying init files." 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/opengnsys/admin/Sources/Services/opengnsys.default /etc/default/opengnsys # Deshabilitar servicios de BitTorrent si no están instalados. if [ ! -e /usr/bin/bttrack ]; then diff --git a/installer/opengnsys_update.sh b/installer/opengnsys_update.sh index 8ca4dfff..4f1ea042 100755 --- a/installer/opengnsys_update.sh +++ b/installer/opengnsys_update.sh @@ -977,6 +977,20 @@ function updateServerFiles() $STARTSERVICE NEWFILES="$NEWFILES /etc/init.d/opengnsys" fi + if ! diff -q \ + $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.service \ + /lib/systemd/system/opengnsys.service 2>/dev/null; then + echoAndLog "${FUNCNAME}(): updating new service file" + backupFile /lib/systemd/system/opengnsys.service + service="opengnsys" + $STOPSERVICE + cp -a \ + $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.service \ + /lib/systemd/system/opengnsys.service + systemctl daemon-reload + $STARTSERVICE + NEWFILES="$NEWFILES /lib/systemd/system/opengnsys.service" + fi if ! diff -q $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.default /etc/default/opengnsys >/dev/null; then echoAndLog "${FUNCNAME}(): updating new default file" backupFile /etc/default/opengnsys -- cgit v1.2.3-18-g5258