From 6c5377a60fe093e2286d24393cf39d5c43bc1956 Mon Sep 17 00:00:00 2001 From: Mark Tearle Date: Sat, 15 Nov 2014 12:21:50 +0800 Subject: [PATCH] Add init script (from Bob) --- .gitignore | 1 - bin/init.d/vendserver | 61 +++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 6 ++--- setup.py | 8 ++++++ 4 files changed, 72 insertions(+), 4 deletions(-) create mode 100755 bin/init.d/vendserver 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", -- 2.20.1