Browse Source

change daemon and init script to create a separate directory for the init file so that the unpriviliged user can delete it

Helmut Pozimski 8 years ago
parent
commit
b02f141c26
8 changed files with 32 additions and 13 deletions
  1. 5 0
      Changelog
  2. 1 2
      TODO
  3. 7 0
      debian/changelog
  4. 1 1
      debian/compat
  5. 2 2
      debian/control
  6. 13 5
      debian/stdd.init
  7. 1 1
      setup.py
  8. 2 2
      stdd

+ 5 - 0
Changelog

@@ -1,3 +1,8 @@
+2015-08-02  Helmut Pozimski  <helmut@pozimski.eu>
+
+    changed the init script to create a separate directory for the PID file
+    create the PID file in the separate directory and rename it to stdd.pid
+
 2014-07-12  Helmut Pozimski  <helmut@pozimski.eu>
 
     converted tabs to spaces, pulled in changes to the daemon class from jwmud, fixed some errors reported by pycharm

+ 1 - 2
TODO

@@ -1,5 +1,4 @@
 * Add stdd.postrm?
-* Make it possible for the unprivileged user to remove the PID file
 * Check code with pylint and improve it
 * Make code pep8 clean
-* Change configuration file to json
+* Change configuration file to json

+ 7 - 0
debian/changelog

@@ -1,3 +1,10 @@
+stdd (0.9.3-1) unstable; urgency=low
+
+  * New upstream release
+  * Bump standards version, no changes needed
+
+ -- Helmut Pozimski <helmut@pozimski.eu>  Sun, 02 Aug 2015 11:46:00 +0200
+
 stdd (0.9.2-1) unstable; urgency=low
 
   * New upstream release

+ 1 - 1
debian/compat

@@ -1 +1 @@
-7
+9

+ 2 - 2
debian/control

@@ -4,8 +4,8 @@ Maintainer: Helmut Pozimski <helmut@pozimski.eu>
 Homepage: https://dev.intranet.helmut-pozimski.de/stdd
 Section: python
 Priority: optional
-Build-Depends: python (>= 2.6), debhelper (>= 7.4.3)
-Standards-Version: 3.9.5
+Build-Depends: python (>= 2.6), debhelper (>= 9)
+Standards-Version: 3.9.6
 
 Package: stdd
 Architecture: all

+ 13 - 5
debian/stdd.init

@@ -26,11 +26,19 @@ DAEMON_ARGS="-d -c /etc/stdd.conf -u $STDD_USER -g $STDD_GROUP"
 SCRIPTNAME=/etc/init.d/$NAME
 
 if [ -d /run ]; then
-	PIDFILE=/run/stdd
+	PID_DIR=/run/stdd
 else
-	PIDFILE=/var/run/stdd
+	PID_DIR=/var/run/stdd
 fi
 
+if [ ! -d $PID_DIR ];
+then
+	mkdir $PID_DIR
+	chown $STDD_USER.$STDD_GROUP $PID_DIR
+fi
+
+PID_FILE=$PID_DIR/stdd.pid
+
 # Exit if the package is not installed
 [ -x "$DAEMON" ] || exit 0
 
@@ -48,9 +56,9 @@ do_start()
 	#   0 if daemon has been started
 	#   1 if daemon was already running
 	#   2 if daemon could not be started
-	start-stop-daemon --status --quiet --pidfile $PIDFILE > /dev/null \
+	start-stop-daemon --status --quiet --pidfile $PID_FILE > /dev/null \
 	&& exit 1
-	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+	start-stop-daemon --start --quiet --pidfile $PID_FILE --exec $DAEMON -- \
 		$DAEMON_ARGS \
 		|| return 2
 }
@@ -65,7 +73,7 @@ do_stop()
 	#   1 if daemon was already stopped
 	#   2 if daemon could not be stopped
 	#   other if a failure occurred
-	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
+	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PID_FILE
 	RETVAL="$?"
 	return "$RETVAL"
 }

+ 1 - 1
setup.py

@@ -10,7 +10,7 @@ from distutils.core import setup
 
 setup(
     name="stdd",
-    version="0.9.2",
+    version="0.9.3",
     author_email="helmut@pozimski.eu",
     description="stdd, simple time display daemon",
     long_description=("stdd is a small daemon written in python which displays"

+ 2 - 2
stdd

@@ -108,9 +108,9 @@ else:
 
 if options.daemon is True:
     if os.access("/run", os.F_OK & os.W_OK) is True:
-        daemon = stddlib.daemon.Daemon("/run", "stdd")
+        daemon = stddlib.daemon.Daemon("/run/stdd", "stdd.pid")
     else:
-        daemon = stddlib.daemon.Daemon("/var/run", "stdd")
+        daemon = stddlib.daemon.Daemon("/var/run/stdd", "stdd.pid")
     daemon.Daemonize()
     daemon.Start()
     logger.info("daemon started")