changeset 27:75563016f269 draft

add systemd .service unit Signed-off-by: Changaco <changaco ατ changaco δοτ net>
author Changaco <changaco ατ changaco δοτ net>
date Sat, 04 Aug 2012 18:33:17 +0200
parents ee5a5a7a9f72
children 022c785c98bd
files init/feed-push.bash init/feed-push.service rc.d/feed-push setup
diffstat 4 files changed, 68 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
new file mode 100755
--- /dev/null
+++ b/init/feed-push.bash
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+daemon_bin="/usr/bin/feed-push"
+daemon_name=$(basename $daemon_bin)
+pid_file="/var/run/$daemon_name.pid"
+PID=$(cat $pid_file 2>/dev/null)
+
+data_dir=/var/lib/$daemon_name
+conf_dir=/etc/$daemon_name
+
+case "$1" in
+    start)
+        stat_busy "Starting $daemon_name daemon"
+        if [ -z "$PID" ]; then
+            $daemon_bin "$conf_dir" "$data_dir/state" --fork $pid_file
+            if [ $? -gt 0 ]; then
+                stat_fail
+                exit 1
+            else
+                add_daemon $daemon_name
+                stat_done
+            fi
+        else
+            stat_fail
+            exit 1
+        fi
+        ;;
+
+    stop)
+        stat_busy "Stopping $daemon_name daemon"
+        [ ! -z "$PID" ] && kill $PID &> /dev/null
+        if [ $? -gt 0 ]; then
+            stat_fail
+            exit 1
+        else
+            rm -f $pid_file &> /dev/null
+            rm_daemon $daemon_name
+            stat_done
+        fi
+        ;;
+
+    restart)
+        $0 stop
+        sleep 1
+        $0 start
+        ;;
+
+    *)
+        echo "usage: $0 {start|stop|restart}"
+esac
new file mode 100644
--- /dev/null
+++ b/init/feed-push.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Feed Push daemon
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/run/feed-push.pid
+ExecStart=/usr/bin/feed-push /etc/feed-push /var/lib/feed-push/state --fork /run/feed-push.pid
+ExecStop=/bin/rm /run/feed-push.pid
+
+[Install]
+WantedBy=multi-user.target
deleted file mode 100755
--- a/rc.d/feed-push
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/bash
-
-. /etc/rc.conf
-. /etc/rc.d/functions
-
-daemon_bin="/usr/bin/feed-push"
-daemon_name=$(basename $daemon_bin)
-pid_file="/var/run/$daemon_name.pid"
-PID=$(cat $pid_file 2>/dev/null)
-
-data_dir=/var/lib/$daemon_name
-conf_dir=/etc/$daemon_name
-
-case "$1" in
-    start)
-        stat_busy "Starting $daemon_name daemon"
-        if [ -z "$PID" ]; then
-            $daemon_bin "$conf_dir" "$data_dir/state" --fork $pid_file
-            if [ $? -gt 0 ]; then
-                stat_fail
-                exit 1
-            else
-                add_daemon $daemon_name
-                stat_done
-            fi
-        else
-            stat_fail
-            exit 1
-        fi
-        ;;
-
-    stop)
-        stat_busy "Stopping $daemon_name daemon"
-        [ ! -z "$PID" ] && kill $PID &> /dev/null
-        if [ $? -gt 0 ]; then
-            stat_fail
-            exit 1
-        else
-            rm -f $pid_file &> /dev/null
-            rm_daemon $daemon_name
-            stat_done
-        fi
-        ;;
-
-    restart)
-        $0 stop
-        sleep 1
-        $0 start
-        ;;
-
-    *)
-        echo "usage: $0 {start|stop|restart}"
-esac
--- a/setup
+++ b/setup
@@ -27,7 +27,9 @@ confdir="${DESTDIR}etc/$progname"
 if [ "$action" == install ]; then
 	install -v -m 755 -D $progname "$_PREFIX/bin/$progname"
 	install_dir examples "$_PREFIX/share/$progname"
-	[ -d /etc/rc.d ] && install_dir rc.d "${DESTDIR}etc" && install -vd "$confdir"
+	install -vd "$confdir"
+	install -v -m 755 -D init/$progname.bash "${DESTDIR}etc/rc.d/$progname"
+	install -v -m 644 -D init/$progname.service "${DESTDIR}usr/lib/systemd/system/$progname.service"
 elif [ "$action" == uninstall ]; then
 	remove "$_PREFIX/bin/$progname"
 	remove "$_PREFIX/share/$progname/examples"