Mercurial > feed-push
annotate init/feed-push.bash @ 34:030e8b24f8b7 draft default tip master
pretty print JSON in state file
Signed-off-by: Changaco <changaco ατ changaco δοτ net>
author | Changaco <changaco ατ changaco δοτ net> |
---|---|
date | Sun, 05 Aug 2012 15:18:28 +0200 |
parents | 75563016f269 |
children |
rev | line source |
---|---|
27
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
1 #!/bin/bash |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
2 |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
3 . /etc/rc.conf |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
4 . /etc/rc.d/functions |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
5 |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
6 daemon_bin="/usr/bin/feed-push" |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
7 daemon_name=$(basename $daemon_bin) |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
8 pid_file="/var/run/$daemon_name.pid" |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
9 PID=$(cat $pid_file 2>/dev/null) |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
10 |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
11 data_dir=/var/lib/$daemon_name |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
12 conf_dir=/etc/$daemon_name |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
13 |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
14 case "$1" in |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
15 start) |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
16 stat_busy "Starting $daemon_name daemon" |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
17 if [ -z "$PID" ]; then |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
18 $daemon_bin "$conf_dir" "$data_dir/state" --fork $pid_file |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
19 if [ $? -gt 0 ]; then |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
20 stat_fail |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
21 exit 1 |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
22 else |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
23 add_daemon $daemon_name |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
24 stat_done |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
25 fi |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
26 else |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
27 stat_fail |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
28 exit 1 |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
29 fi |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
30 ;; |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
31 |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
32 stop) |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
33 stat_busy "Stopping $daemon_name daemon" |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
34 [ ! -z "$PID" ] && kill $PID &> /dev/null |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
35 if [ $? -gt 0 ]; then |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
36 stat_fail |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
37 exit 1 |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
38 else |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
39 rm -f $pid_file &> /dev/null |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
40 rm_daemon $daemon_name |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
41 stat_done |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
42 fi |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
43 ;; |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
44 |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
45 restart) |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
46 $0 stop |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
47 sleep 1 |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
48 $0 start |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
49 ;; |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
50 |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
51 *) |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
52 echo "usage: $0 {start|stop|restart}" |
75563016f269
add systemd .service unit
Changaco <changaco ατ changaco δοτ net>
parents:
diff
changeset
|
53 esac |