diff --git a/src/install/debian/compat b/src/install/debian/compat index 45a4fb75..b4de3947 100644 --- a/src/install/debian/compat +++ b/src/install/debian/compat @@ -1 +1 @@ -8 +11 diff --git a/src/install/debian/lsc.install b/src/install/debian/lsc.install index 83ea2cea..8e3e37f6 100644 --- a/src/install/debian/lsc.install +++ b/src/install/debian/lsc.install @@ -8,9 +8,9 @@ etc/logback.xml etc/lsc lib/* usr/lib/lsc ## sample sample/* usr/share/doc/lsc -## init -etc/init.d/lsc etc/init.d -etc/default/lsc etc/default +## systemd +etc/default/lsc-sync etc/default +etc/default/lsc-async etc/default ## nagios bin/check_lsc* var/lib/lsc/nagios diff --git a/src/install/debian/lsc.postinst b/src/install/debian/lsc.postinst index 571d5177..924f96b6 100644 --- a/src/install/debian/lsc.postinst +++ b/src/install/debian/lsc.postinst @@ -18,12 +18,6 @@ sed -i 's:^CFG_DIR.*:CFG_DIR="/etc/lsc":' /usr/bin/lsc /usr/bin/lsc-agent /usr/b sed -i 's:^LIB_DIR.*:LIB_DIR="/usr/lib/lsc":' /usr/bin/lsc /usr/bin/lsc-agent /usr/bin/hsqldb sed -i "s:^LOG_DIR.*:LOG_DIR=\"${lsc_logdir}\":" /usr/bin/lsc /usr/bin/lsc-agent /usr/bin/hsqldb sed -i 's:^VAR_DIR.*:VAR_DIR="/var/lsc":' /usr/bin/hsqldb -## init -sed -i 's:^LSC_BIN.*:LSC_BIN="/usr/bin/lsc":' /etc/default/lsc -sed -i 's:^LSC_CFG_DIR.*:LSC_CFG_DIR="/etc/lsc":' /etc/default/lsc -sed -i 's:^LSC_USER.*:LSC_USER="lsc":' /etc/default/lsc -sed -i 's:^LSC_GROUP.*:LSC_GROUP="lsc":' /etc/default/lsc -sed -i 's:^LSC_PID_FILE.*:LSC_PID_FILE="/var/run/lsc.pid":' /etc/default/lsc # Copy sample configuration for a fresh install [ -f /etc/lsc/lsc.xml ] || cp /usr/share/doc/lsc/lsc.xml-sample /etc/lsc/lsc.xml diff --git a/src/install/debian/rules b/src/install/debian/rules index 5aafa88f..0c88dc43 100644 --- a/src/install/debian/rules +++ b/src/install/debian/rules @@ -7,3 +7,21 @@ dh $@ override_dh_compress: + +override_dh_testdir: +## systemd + cp -f lib/systemd/system/lsc-async.service debian/ + cp -f lib/systemd/system/lsc-async@.service debian/ + cp -f lib/systemd/system/lsc-sync.service debian/ + cp -f lib/systemd/system/lsc-sync.timer debian/ + cp -f lib/systemd/system/lsc-sync@.service debian/ + cp -f etc/default/lsc-async debian/lsc-async.default + cp -f etc/default/lsc-sync debian/lsc-sync.default + dh_testdir + +override_dh_installsystemd: + dh_installsystemd --no-start --no-enable --no-stop-on-upgrade --name=lsc-async + dh_installsystemd --no-start --no-enable --no-stop-on-upgrade --name=lsc-async@ + dh_installsystemd --no-start --no-enable --no-stop-on-upgrade --name=lsc-sync + dh_installsystemd --no-start --no-enable --no-stop-on-upgrade --name=lsc-sync@ + dh_installsystemd --name=lsc-sync.timer diff --git a/src/install/etc/default/lsc b/src/install/etc/default/lsc-async similarity index 61% rename from src/install/etc/default/lsc rename to src/install/etc/default/lsc-async index 39994e94..9d3e6432 100644 --- a/src/install/etc/default/lsc +++ b/src/install/etc/default/lsc-async @@ -3,17 +3,14 @@ # (http://www.lsc-project.org). #==================================================================== -# LSC installation -LSC_BIN="/usr/local/lsc/bin/lsc" -LSC_CFG_DIR="/usr/local/lsc/etc" -LSC_USER="" -LSC_GROUP="" -LSC_PID_FILE="/var/run/lsc.pid" -LSC_TASKS="all" -LSC_PARAMS="" - # JMX LSC_JMXPORT="1099" # JAVA #JAVA_HOME=/usr/java/jdk/jre + +LSC_CONFIG_DIR="/etc/lsc" +#LSC_SYNC_TASKS="" +LSC_ASYNC_TASKS="-a all" +#LSC_CLEAN_TASKS="" +LSC_EXTRA_ARGS="" diff --git a/src/install/etc/default/lsc-sync b/src/install/etc/default/lsc-sync new file mode 100644 index 00000000..db657057 --- /dev/null +++ b/src/install/etc/default/lsc-sync @@ -0,0 +1,16 @@ +#==================================================================== +# Configuration for LSC init script +# (http://www.lsc-project.org). +#==================================================================== + +# JMX +LSC_JMXPORT="1099" + +# JAVA +#JAVA_HOME=/usr/java/jdk/jre + +LSC_CONFIG_DIR="/etc/lsc" +LSC_SYNC_TASKS="-s all" +#LSC_ASYNC_TASKS="" +LSC_CLEAN_TASKS="-c all" +LSC_EXTRA_ARGS="" diff --git a/src/install/etc/init.d/lsc b/src/install/etc/init.d/lsc deleted file mode 100755 index 2d67a3f9..00000000 --- a/src/install/etc/init.d/lsc +++ /dev/null @@ -1,382 +0,0 @@ -#!/bin/bash - -#==================================================================== -# Start/stop script for LSC -# (http://www.lsc-project.org). -# -# chkconfig: 2345 27 73 -# description: LSC -# -### BEGIN INIT INFO -# Provides: lsc -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Should-Start: $network $time -# Should-Stop: $network $time -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: LSC -# Description: LSC init script provided -### END INIT INFO -# -# ==LICENSE NOTICE== -# -# Copyright (c) 2008-2013, LSC Project -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -#    * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -#     * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -#     * Neither the name of the LSC Project nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# ==LICENSE NOTICE== -# -# (C) 2008-2013 LSC Project -# Clement OUDOT -#==================================================================== - -#==================================================================== -# Default parameters (if /etc/default/{script_name} is not present) -#==================================================================== -# LSC installation -LSC_BIN="/usr/bin/lsc" -LSC_CFG_DIR="/etc/lsc" -LSC_USER="lsc" -LSC_GROUP="lsc" -LSC_PID_FILE="/var/run/lsc.pid" -LSC_TASKS="all" -LSC_PARAMS="" - -# JMX -LSC_JMXPORT=1099 - -# JAVA -JAVA_HOME="" - -# Script specific -PROG_NAME=`basename $0 | sed 's/^[KS][0-9][0-9]//'` # For nice messages -OS=`uname -s` # To adapt message printing -MYUID=`id -u` # For UNIX compatibility => modify this command -MYGID=`id -g` # For UNIX compatibility => modify this command -PS_COMMAND="ps -efww" # This ensures full width for ps output but doesn't work on Solaris - use "ps -ef" -NOHUP=`which nohup` - -#==================================================================== -# Message function -#==================================================================== -message() { - # $1: syslog level - # $2: message - - # Log to syslog - logger -p "$1" -t $PROG_NAME -i "$2" - - # Output to console - if [ "$1" = "alert" ] - then - echo "$PROG_NAME: $2">&2 - else - echo "$PROG_NAME: $2">&1 - fi -} - -#==================================================================== -# Load specific parameters -#==================================================================== -if [ -f /etc/default/$PROG_NAME ] -then - . /etc/default/$PROG_NAME - message "info" "[INFO] Using /etc/default/$PROG_NAME for configuration" -else - message "info" "[INFO] Using built-in configuration - this may cause some problems" -fi - -#==================================================================== -# Initiate 'su' command -#==================================================================== -if [ "$LSC_USER" -a $MYUID -eq 0 ] -then - SU="su -s /bin/bash $LSC_USER -c " -fi - -#==================================================================== -# Initial checks -#==================================================================== - -# Make sure the pidfile directory exists with correct permissions -piddir=`dirname "$LSC_PID_FILE"` -if [ ! -d "$piddir" ]; then - mkdir -p "$piddir" -fi - -touch $LSC_PID_FILE -[ -z "$LSC_USER" ] || chown -R "$LSC_USER" "$LSC_PID_FILE" -[ -z "$LSC_GROUP" ] || chgrp -R "$LSC_GROUP" "$LSC_PID_FILE" - -# Rights to execute binaries -for i in "$LSC_BIN" "$NOHUP" -do - if [ ! -x $i ] - then - message "alert" "[ALERT] Can't execute $i" - exit 1 - fi -done - -# Export JAVA_HOME -if [ "z" != "z${JAVA_HOME}" ]; then - export JAVA_HOME=$JAVA_HOME -fi - -#==================================================================== -# Functions -#==================================================================== -start_lsc() { - - # Exit 0 if lsc is already running - # LSB compliance - lsc_status - - if [ $? -eq 0 ] - then - message "info" "[OK] LSC is already running" - exit 0 - fi - - # Start message - message "info" "[INFO] Launching LSC..." - - # Export JMX PORT - if [ $LSC_JMXPORT -ne 0 ] - then - message "info" "[OK] Using LSC JMX port $LSC_JMXPORT" - export LSC_JMXPORT=$LSC_JMXPORT - fi - - # LSC parameters - LSC_PARAMS="-a $LSC_TASKS -f $LSC_CFG_DIR $LSC_PARAMS" - - if [ -z "$SU" ] - then - $NOHUP $LSC_BIN $LSC_PARAMS 1>/dev/null 2>&1 & - else - $NOHUP $SU "$LSC_BIN $LSC_PARAMS" 1>/dev/null 2>&1 & - fi - - # Register PID - PID=$! - - # Wait for java process to launch - for i in `seq 1 60` - do - LSC_PID=`ps --ppid $PID -o 'pid='` - if [ -z $LSC_PID ] - then - message "info" "[INFO] Waiting ${i}s for LSC java process to launch" - sleep 1 - fi - done - - if [ -z $LSC_PID ] - then - message "alert" "[ALERT] Unable to launch LSC" - exit 1 - fi - - - # We get the PID of the java process - # which is the direct children if no $SU - # or the 2nd children if $SU - - if [ -z "$SU" ] - then - LSC_PID=`ps --ppid $PID -o 'pid='` - else - LSC_PID=`ps --ppid $PID -o 'pid='` - LSC_PID=`ps --ppid $LSC_PID -o 'pid='` - fi - - message "info" "[OK] Register LSC PID $LSC_PID" - echo $LSC_PID > $LSC_PID_FILE - - # Presence of PID file - if [ ! -r $LSC_PID_FILE ] - then - message "alert" "[ALERT] No PID file for LSC" - exit 1 - fi - - sleep 2 - - # Is LSC launched? - PID=`cat $LSC_PID_FILE` - if [ ! -e /proc/$PID ] - then - message "alert" "[ALERT] LSC not running" - exit 1 - else - message "info" "[OK] LSC started" - fi -} - -stop_lsc() { - - # Bypas lsc is already stopped - lsc_status - - if [ $? -ne 0 ] - then - message "info" "[OK] LSC is already stopped" - else - - # Stop message - message "info" "[INFO] Halting LSC..." - - # Presence of PID file - if [ ! -r $LSC_PID_FILE ] - then - message "error" "[ERROR] Can't read LSC PID file" - return 1 - else - PID=`cat $LSC_PID_FILE` - - kill $PID - - sleep 2 - - if [ -e /proc/$PID ] - then - message "alert" "[ALERT] LSC still running" - exit 1 - else - message "info" "[OK] LSC stopped" - - fi - - fi - - fi - -} - -lsc_status() { - - PID=`cat $LSC_PID_FILE` - - if [ -z $PID ] - then - return 1 - fi - - if [ ! -e /proc/$PID ] - then - return 1 - else - return 0 - fi -} - -display_status() { - - # Get status - lsc_status - - status=$? - - if [ $status -eq 0 ] - then - PID=`cat $LSC_PID_FILE` - - message "info" "[INFO] Process LSC is running (PID $PID)" - - if [ $LSC_JMXPORT -ne 0 ] - then - message "info" "[INFO] Process LSC is using JMX port $LSC_JMXPORT" - fi - fi - - if [ $status -eq 1 ] - then - message "info" "[INFO] Process LSC is not running" - fi - - if [ $status -eq 2 ] - then - message "info" "[INFO] Unable to determine LSC status" - fi - - exit $status -} - -configtest() { - # Start message - message "info" "[INFO] Launching LSC configuration test..." - - if [ -z "$SU" ] - then - $LSC_BIN -v -f $LSC_CFG_DIR 1>/dev/null 2>&1 - else - $SU "$LSC_BIN -v -f $LSC_CFG_DIR 1>/dev/null 2>&1" - fi - - if [ $? -eq 0 ] - then - message "info" "[OK] LSC configuration test successful" - else - message "alert" "[ALERT] LSC configuration test failed" - exit 1 - fi -} - -#==================================================================== -# Action switch -#==================================================================== -case $1 in - start) - configtest - start_lsc - ;; - stop) - stop_lsc - ;; - restart) - configtest - stop_lsc - start_lsc - ;; - status) - display_status - ;; - configtest) - configtest - ;; - *) - echo "Usage: $0 {start|stop|forcestop|restart|status|configtest}" - exit 1 - ;; -esac - -#==================================================================== -# Exit -#==================================================================== -exit 0 - diff --git a/src/install/lib/systemd/system/lsc-async.service b/src/install/lib/systemd/system/lsc-async.service new file mode 100644 index 00000000..4ada5055 --- /dev/null +++ b/src/install/lib/systemd/system/lsc-async.service @@ -0,0 +1,27 @@ +[Unit] +Description=LSC server +After=network.target + +[Service] +Type=forking +User=lsc +Group=lsc +PIDFile=/var/run/lsc.pid +Environment="LSC_CONFIG_DIR=/etc/lsc" +Environment="LSC_ASYNC_TASKS=-a all" +Environment="LSC_EXTRA_ARGS=" +Environment="LSC_JMXPORT=" +EnvironmentFile=-/etc/default/lsc-async +ExecStartPre=/usr/bin/lsc -v -f ${LSC_CONFIG_DIR} +ExecStart=/usr/bin/lsc -f ${LSC_CONFIG_DIR} ${LSC_ASYNC_TASKS} ${LSC_EXTRA_ARGS} + +PrivateTmp=true +PrivateDevices=true +ProtectSystem=strict +ProtectKernelTunables=yes +ProtectControlGroups=yes +ReadWritePaths=/var/log/lsc +UMask=0007 + +[Install] +WantedBy=multi-user.target diff --git a/src/install/lib/systemd/system/lsc-async@.service b/src/install/lib/systemd/system/lsc-async@.service new file mode 100644 index 00000000..f8b8b47b --- /dev/null +++ b/src/install/lib/systemd/system/lsc-async@.service @@ -0,0 +1,27 @@ +[Unit] +Description=LSC server for specific instance %I +After=network.target + +[Service] +Type=forking +User=lsc +Group=lsc +PIDFile=/var/run/lsc.pid +Environment="LSC_CONFIG_DIR=/etc/lsc" +Environment="LSC_ASYNC_TASKS=-a all" +Environment="LSC_EXTRA_ARGS=" +Environment="LSC_JMXPORT=" +EnvironmentFile=-/etc/default/lsc-%i +ExecStartPre=/usr/bin/lsc -v -f ${LSC_CONFIG_DIR} +ExecStart=/usr/bin/lsc -f ${LSC_CONFIG_DIR} ${LSC_ASYNC_TASKS} ${LSC_EXTRA_ARGS} + +PrivateTmp=true +PrivateDevices=true +ProtectSystem=strict +ProtectKernelTunables=yes +ProtectControlGroups=yes +ReadWritePaths=/var/log/lsc +UMask=0007 + +[Install] +WantedBy=multi-user.target diff --git a/src/install/lib/systemd/system/lsc-sync.service b/src/install/lib/systemd/system/lsc-sync.service new file mode 100644 index 00000000..a6039e45 --- /dev/null +++ b/src/install/lib/systemd/system/lsc-sync.service @@ -0,0 +1,23 @@ +[Unit] +Description=Run LSC jobs on demand +After=network.target + +[Service] +Type=oneshot +User=lsc +Group=lsc +Environment="LSC_CONFIG_DIR=/etc/lsc" +Environment="LSC_SYNC_TASKS=-s all" +Environment="LSC_CLEAN_TASKS=-c all" +Environment="LSC_EXTRA_ARGS=" +EnvironmentFile=-/etc/default/lsc-sync +ExecStartPre=/usr/bin/lsc -v -f ${LSC_CONFIG_DIR} +ExecStart=/usr/bin/lsc -f ${LSC_CONFIG_DIR} ${LSC_SYNC_TASKS} ${LSC_CLEAN_TASKS} ${LSC_EXTRA_ARGS} + +PrivateTmp=true +PrivateDevices=true +ProtectSystem=strict +ProtectKernelTunables=yes +ProtectControlGroups=yes +ReadWritePaths=/var/log/lsc +UMask=0007 diff --git a/src/install/lib/systemd/system/lsc-sync.timer b/src/install/lib/systemd/system/lsc-sync.timer new file mode 100644 index 00000000..96809c88 --- /dev/null +++ b/src/install/lib/systemd/system/lsc-sync.timer @@ -0,0 +1,5 @@ +[Unit] +Description=Periodically run LSC + +[Timer] +OnCalendar= *:30:00 diff --git a/src/install/lib/systemd/system/lsc-sync@.service b/src/install/lib/systemd/system/lsc-sync@.service new file mode 100644 index 00000000..899232d6 --- /dev/null +++ b/src/install/lib/systemd/system/lsc-sync@.service @@ -0,0 +1,23 @@ +[Unit] +Description=Run LSC specific instance %I +After=network.target + +[Service] +Type=oneshot +User=lsc +Group=lsc +Environment="LSC_CONFIG_DIR=/etc/lsc" +Environment="LSC_SYNC_TASKS=-s all" +Environment="LSC_CLEAN_TASKS=-c all" +Environment="LSC_EXTRA_ARGS=" +EnvironmentFile=-/etc/default/lsc-%i +ExecStartPre=/usr/bin/lsc -v -f ${LSC_CONFIG_DIR} +ExecStart=/usr/bin/lsc -f ${LSC_CONFIG_DIR} ${LSC_SYNC_TASKS} ${LSC_CLEAN_TASKS} ${LSC_EXTRA_ARGS} + +PrivateTmp=true +PrivateDevices=true +ProtectSystem=strict +ProtectKernelTunables=yes +ProtectControlGroups=yes +ReadWritePaths=/var/log/lsc +UMask=0007 diff --git a/src/install/lsc-core.spec b/src/install/lsc-core.spec index 19e4b0d8..3350dca4 100644 --- a/src/install/lsc-core.spec +++ b/src/install/lsc-core.spec @@ -33,6 +33,11 @@ URL: https://lsc-project.org Source: %{lsc_name}-core-%{lsc_version}-dist.zip BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +%if 0%{?fedora}%{?el9} +BuildRequires: systemd-rpm-macros +%else +BuildRequires: systemd +%endif Requires(pre): coreutils Requires: which @@ -64,11 +69,12 @@ mkdir -p %{buildroot}/usr/%{_lib}/lsc mkdir -p %{buildroot}/etc/lsc mkdir -p %{buildroot}/etc/lsc/sql-map-config.d mkdir -p %{buildroot}/etc/cron.d -mkdir -p %{buildroot}/etc/init.d mkdir -p %{buildroot}/etc/default mkdir -p %{buildroot}/usr/share/doc/lsc/bin mkdir -p %{buildroot}%{lsc_logdir} mkdir -p %{buildroot}/var/lib/lsc/nagios +mkdir -p %{buildroot}%{_unitdir} +mkdir -p %{buildroot}%{_sysconfdir}/default # Copy files ## bin @@ -89,9 +95,14 @@ cp -a lib/* %{buildroot}/usr/%{_lib}/lsc cp -a sample/ %{buildroot}/usr/share/doc/lsc ## cron cp -a etc/cron.d/lsc.cron %{buildroot}/etc/cron.d/lsc -## init -cp -a etc/init.d/lsc %{buildroot}/etc/init.d/lsc -cp -a etc/default/lsc %{buildroot}/etc/default/lsc +## systemd +cp -a etc/default/lsc-async %{buildroot}%{_sysconfdir}/default/lsc-async +cp -a etc/default/lsc-sync %{buildroot}%{_sysconfdir}/default/lsc-sync +install -p -m 0644 lib/systemd/system/lsc-async.service %{buildroot}%{_unitdir}/ +install -p -m 0644 lib/systemd/system/lsc-async@.service %{buildroot}%{_unitdir}/ +install -p -m 0644 lib/systemd/system/lsc-sync.service %{buildroot}%{_unitdir}/ +install -p -m 0644 lib/systemd/system/lsc-sync@.service %{buildroot}%{_unitdir}/ +install -p -m 0644 lib/systemd/system/lsc-sync.timer %{buildroot}%{_unitdir}/ ## nagios cp -a bin/check_lsc* %{buildroot}/var/lib/lsc/nagios @@ -107,24 +118,12 @@ sed -i 's:^CFG_DIR.*:CFG_DIR="/etc/lsc":' %{buildroot}/usr/bin/lsc %{buildroot}/ sed -i 's:^LIB_DIR.*:LIB_DIR="/usr/%{_lib}/lsc":' %{buildroot}/usr/bin/lsc %{buildroot}/usr/bin/lsc-agent %{buildroot}/usr/bin/hsqldb sed -i 's:^LOG_DIR.*:LOG_DIR="%{lsc_logdir}":' %{buildroot}/usr/bin/lsc %{buildroot}/usr/bin/lsc-agent %{buildroot}/usr/bin/hsqldb sed -i 's:^VAR_DIR.*:VAR_DIR="/var/lsc":' %{buildroot}/usr/bin/hsqldb -## init -sed -i 's:^LSC_BIN.*:LSC_BIN="/usr/bin/lsc":' %{buildroot}/etc/default/lsc -sed -i 's:^LSC_CFG_DIR.*:LSC_CFG_DIR="/etc/lsc":' %{buildroot}/etc/default/lsc -sed -i 's:^LSC_USER.*:LSC_USER="lsc":' %{buildroot}/etc/default/lsc -sed -i 's:^LSC_GROUP.*:LSC_GROUP="lsc":' %{buildroot}/etc/default/lsc -sed -i 's:^LSC_PID_FILE.*:LSC_PID_FILE="/var/run/lsc.pid":' %{buildroot}/etc/default/lsc %post -#================================================= -# Post Installation -#================================================= - -# Do this at first install -if [ $1 -eq 1 ] -then - # Set lsc as service - /sbin/chkconfig --add lsc -fi +%systemd_post lsc-async.service +%systemd_post lsc-async@.service +%systemd_post lsc-sync.service +%systemd_post lsc-sync@.service # Always do this # Create user and group if needed @@ -137,6 +136,10 @@ getent passwd %{lsc_user} > /dev/null 2>&1 || useradd --system --gid %{lsc_group ln -sf /usr/%{_lib}/lsc/ /usr/share/doc/lsc/%{_lib} ln -sf /usr/bin/lsc /usr/share/doc/lsc/bin/ +%preun +%systemd_preun lsc-async.service +%systemd_preun lsc-sync.service + %postun #================================================= # Post uninstallation @@ -166,11 +169,16 @@ rm -rf %{buildroot} %defattr(-, root, root, 0755) %config(noreplace) /etc/lsc/ %config(noreplace) /etc/cron.d/lsc -%config(noreplace) /etc/default/lsc +%config(noreplace) /etc/default/lsc-sync +%config(noreplace) /etc/default/lsc-async /usr/bin/lsc /usr/bin/lsc-agent /usr/bin/hsqldb -/etc/init.d/lsc +%{_unitdir}/lsc-async.service +%{_unitdir}/lsc-async@.service +%{_unitdir}/lsc-sync.service +%{_unitdir}/lsc-sync@.service +%{_unitdir}/lsc-sync.timer /usr/%{_lib}/lsc/ /usr/share/doc/lsc %{lsc_logdir} diff --git a/src/main/assembly/dist.xml b/src/main/assembly/dist.xml index 97d97559..7e925bed 100644 --- a/src/main/assembly/dist.xml +++ b/src/main/assembly/dist.xml @@ -136,18 +136,29 @@ 0755 - + - src/install/etc/init.d - lsc - etc/init.d - 0755 + src/install/lib/systemd/system + + lsc-async.service + lsc-async@.service + lsc-sync.service + lsc-sync@.service + lsc-sync.timer + + lib/systemd/system + 0644 0755 + src/install/etc/default - lsc + + lsc + lsc-sync + lsc-async + etc/default 0644 0755