From e0fa32ac08e2d8434943a230da7a4740d55d3a85 Mon Sep 17 00:00:00 2001 From: parmentelat Date: Mon, 10 Dec 2018 11:14:53 +0100 Subject: [PATCH] fixes to the service file; + former stub /etc/init.d/plc becomes /usr/bin/plc-ctl --- myplc.spec | 6 +++--- plc.service | 13 ------------- plc.init => systemd/plc-ctl | 17 +++++++---------- systemd/plc.service | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 26 deletions(-) delete mode 100644 plc.service rename plc.init => systemd/plc-ctl (96%) create mode 100644 systemd/plc.service diff --git a/myplc.spec b/myplc.spec index 95eb0d5..56e7aa4 100644 --- a/myplc.spec +++ b/myplc.spec @@ -129,8 +129,8 @@ chmod 755 ${RPM_BUILD_ROOT}/usr/bin/* # Install initscript echo "* Installing plc initscript" -install -D -m 755 plc.init ${RPM_BUILD_ROOT}/etc/init.d/plc -install -D -m 644 plc.service ${RPM_BUILD_ROOT}/usr/lib/systemd/system/plc.service +install -D -m 755 systemd/plc-ctl ${RPM_BUILD_ROOT}/usr/bin/plc-ctl +install -D -m 644 systemd/plc.service ${RPM_BUILD_ROOT}/usr/lib/systemd/system/plc.service # Install initscripts echo "* Installing plc.d initscripts" @@ -242,7 +242,7 @@ fi %files %defattr(-,root,root,-) # Host startup script and configuration file -/etc/init.d/plc +/usr/bin/plc-ctl /etc/plc.d /etc/planetlab /etc/plc_sliceinitscripts diff --git a/plc.service b/plc.service deleted file mode 100644 index 0246411..0000000 --- a/plc.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=PLC Service -After=network.target - -[Service] -Type=simple -ExecStart=/etc/init.d/plc start -ExecStop=/etc/init.d/plc stop -ExecReload=/etc/init.d/plc reload -TimeoutSec=300 - -[Install] -WantedBy=multi-user.target diff --git a/plc.init b/systemd/plc-ctl similarity index 96% rename from plc.init rename to systemd/plc-ctl index 1488194..415be31 100755 --- a/plc.init +++ b/systemd/plc-ctl @@ -9,7 +9,7 @@ # Source function library and configuration # plc_reload is defined here -. /etc/plc.d/functions +source /etc/plc.d/functions # Verbosity verbose=0 @@ -46,8 +46,7 @@ done | sort -n | cut -d' ' -f2 )) nsteps=${#steps[@]} -usage() -{ +function usage() { echo "Usage: $0 [OPTION]... [COMMAND] [STEP]..." echo " -v Be verbose" echo " -h This message" @@ -86,8 +85,8 @@ done if [ $verbose -eq 0 ] ; then touch /var/log/boot.log chmod 600 /var/log/boot.log - exec 1>>/var/log/boot.log - exec 2>>/var/log/boot.log + exec 1>> /var/log/boot.log + exec 2>> /var/log/boot.log fi # Get command @@ -110,8 +109,7 @@ fi RETVAL=0 -start () -{ +function start () { for step in "${steps[@]}" ; do if [ -x /etc/plc.d/$step ] ; then /etc/plc.d/$step start @@ -124,8 +122,7 @@ start () done } -stop () -{ +function stop () { for i in $(seq 1 $nsteps) ; do step=${steps[$(($nsteps - $i))]} if [ -x /etc/plc.d/$step ] ; then @@ -158,7 +155,7 @@ case "$command" in if [ -z "$cpfile" ] ; then echo "PLC: checkpoint requires a filename as an argument" exit 1 - fi + fi cpdir=$(mktemp -d tmp.XXXXXX) cd $cpdir mkdir -p ./etc/planetlab/ diff --git a/systemd/plc.service b/systemd/plc.service new file mode 100644 index 0000000..b06c1e4 --- /dev/null +++ b/systemd/plc.service @@ -0,0 +1,14 @@ +[Unit] +Description=PLC Service +After=network.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/plc-ctl start +RemainAfterExit=true +ExecStop=/usr/bin/plc-ctl stop +ExecReload=/usr/bin/plc-ctl reload +StandardOutput=journal + +[Install] +WantedBy=multi-user.target -- 2.43.0