Add init script (from Bob)
authorMark Tearle <[email protected]>
Sat, 15 Nov 2014 04:21:50 +0000 (12:21 +0800)
committerMark Tearle <[email protected]>
Sat, 15 Nov 2014 04:21:50 +0000 (12:21 +0800)
.gitignore
bin/init.d/vendserver [new file with mode: 0755]
setup.cfg
setup.py

index 74ffd4e..3ca5eff 100644 (file)
@@ -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 (executable)
index 0000000..3390401
--- /dev/null
@@ -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
index cfd311f..97bb905 100644 (file)
--- 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
index eed3ea1..9611d59 100755 (executable)
--- 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",

UCC git Repository :: git.ucc.asn.au