Mercurial > feed-push
comparison init/feed-push.bash @ 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 | |
children |
comparison
equal
deleted
inserted
replaced
26:ee5a5a7a9f72 | 27:75563016f269 |
---|---|
1 #!/bin/bash | |
2 | |
3 . /etc/rc.conf | |
4 . /etc/rc.d/functions | |
5 | |
6 daemon_bin="/usr/bin/feed-push" | |
7 daemon_name=$(basename $daemon_bin) | |
8 pid_file="/var/run/$daemon_name.pid" | |
9 PID=$(cat $pid_file 2>/dev/null) | |
10 | |
11 data_dir=/var/lib/$daemon_name | |
12 conf_dir=/etc/$daemon_name | |
13 | |
14 case "$1" in | |
15 start) | |
16 stat_busy "Starting $daemon_name daemon" | |
17 if [ -z "$PID" ]; then | |
18 $daemon_bin "$conf_dir" "$data_dir/state" --fork $pid_file | |
19 if [ $? -gt 0 ]; then | |
20 stat_fail | |
21 exit 1 | |
22 else | |
23 add_daemon $daemon_name | |
24 stat_done | |
25 fi | |
26 else | |
27 stat_fail | |
28 exit 1 | |
29 fi | |
30 ;; | |
31 | |
32 stop) | |
33 stat_busy "Stopping $daemon_name daemon" | |
34 [ ! -z "$PID" ] && kill $PID &> /dev/null | |
35 if [ $? -gt 0 ]; then | |
36 stat_fail | |
37 exit 1 | |
38 else | |
39 rm -f $pid_file &> /dev/null | |
40 rm_daemon $daemon_name | |
41 stat_done | |
42 fi | |
43 ;; | |
44 | |
45 restart) | |
46 $0 stop | |
47 sleep 1 | |
48 $0 start | |
49 ;; | |
50 | |
51 *) | |
52 echo "usage: $0 {start|stop|restart}" | |
53 esac |