# 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"
%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
+++ /dev/null
-[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
# Source function library and configuration
# plc_reload is defined here
-. /etc/plc.d/functions
+source /etc/plc.d/functions
# Verbosity
verbose=0
))
nsteps=${#steps[@]}
-usage()
-{
+function usage() {
echo "Usage: $0 [OPTION]... [COMMAND] [STEP]..."
echo " -v Be verbose"
echo " -h This message"
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
RETVAL=0
-start ()
-{
+function start () {
for step in "${steps[@]}" ; do
if [ -x /etc/plc.d/$step ] ; then
/etc/plc.d/$step start
done
}
-stop ()
-{
+function stop () {
for i in $(seq 1 $nsteps) ; do
step=${steps[$(($nsteps - $i))]}
if [ -x /etc/plc.d/$step ] ; then
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/
--- /dev/null
+[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