From: Mark Tearle Date: Sat, 15 Nov 2014 04:21:50 +0000 (+0800) Subject: Add init script (from Bob) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=6c5377a60fe093e2286d24393cf39d5c43bc1956;p=uccvend-vendserver.git Add init script (from Bob) --- diff --git a/.gitignore b/.gitignore index 74ffd4e..3ca5eff 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ dist build eggs parts -bin var sdist develop-eggs diff --git a/bin/init.d/vendserver b/bin/init.d/vendserver new file mode 100755 index 0000000..3390401 --- /dev/null +++ b/bin/init.d/vendserver @@ -0,0 +1,61 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: vendserver +# Required-Start: $syslog +# Required-Stop: $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: VendServer +# Description: Dispense2 Vending Machine / MIFARE Server +### END INIT INFO + +# Author: Bob Adamson + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games +DESC="VendServer" +NAME=vendserver +DAEMON="/usr/local/uccvend-vendserver/VendServer/VendServer.py" +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME +DAEMON_ARGS="" + +# Gracefully exit if the package has been removed. +test -x $DAEMON || exit 0 + +d_start() { + start-stop-daemon --start --quiet --pidfile $PIDFILE \ + --nicelevel 5 \ + --exec $DAEMON -- -d -sdaemon --pid-file=$PIDFILE \ + $DAEMON_ARGS +} + +d_stop() { + start-stop-daemon --stop --quiet --pidfile $PIDFILE \ + --name $NAME +} + +case "$1" in + start) + echo -n "Starting $DESC: $NAME" + d_start + echo "." + ;; + stop) + echo -n "Stopping $DESC: $NAME" + d_stop + echo "." + ;; + restart|force-reload) + echo -n "Restarting $DESC: $NAME" + d_stop + sleep 1 + d_start + echo "." + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/setup.cfg b/setup.cfg index cfd311f..97bb905 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,6 +2,6 @@ universal = 1 [install] -root=/usr/local/uccvend-vendserver -install-lib=/ -install-scripts=/ +root=/ +install-lib=/usr/local/uccvend-vendserver +install-scripts=/usr/local/uccvend-vendserver diff --git a/setup.py b/setup.py index eed3ea1..9611d59 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import os try: from setuptools import setup @@ -32,6 +33,13 @@ setup( ], package_dir={'VendServer': 'VendServer'}, + data_files = [ + ( + os.path.join('/etc', 'init.d'), + ['bin/init.d/vendserver', + ] + ) + ], include_package_data=True, install_requires=requirements, license="BSD",