updated on Wed Jan 11 00:07:16 UTC 2012
[aur-mirror.git] / sks / sks.init
blob458fd917dbcacdb2d36b1920bc30a72daab7b577
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 # Reads config file
7 [ -r /etc/conf.d/sks ] && . /etc/conf.d/sks
9 DAEMON=/usr/bin/sks
10 SKSDBPID=/var/run/sks/sksdb.pid
11 SKSRECONPID=/var/run/sks/sksrecon.pid
13 # See if the daemon is there
14 test -e $DAEMON || exit 0
16 if [ ! -x $DAEMON ]; then
17 echo "ERROR: $DAEMON is not executable"
18 exit 1
21 case "$1" in
22 start)
23 stat_busy "Starting sks daemons:"
25 if [ "$initstart" != "yes" ]; then
26 stat_append " Not starting sks (as configured in /etc/conf.d/sks)"
27 stat_fail
28 exit 1
31 mkdir -p `dirname "$SKSDBPID"`
32 chown sks `dirname "$SKSDBPID"`
34 [ -d /var/lib/sks/DB ] || su -c "$DAEMON build" sks
36 stat_append " sksdb.."
38 su -c "$DAEMON db &>> /var/log/sks/dboutput.log &" sks
39 PID=$(pgrep -of "$DAEMON db")
40 echo "$PID" > $SKSDBPID
42 stat_append " sksrecon.."
44 su -c "$DAEMON recon &>> /var/log/sks/reconoutput.log &" sks
45 PID=$(pgrep -of "$DAEMON recon")
46 echo "$PID" > $SKSRECONPID
48 stat_done
51 stop)
52 stat_busy "Stopping sks daemons:"
54 stat_append "sksrecon"
55 if [ -f $SKSRECONPID ]; then
56 PID="$(cat $SKSRECONPID)"
58 if [ -n "$PID" ]; then
59 kill $PID 2> /dev/null
60 if [ $? -gt 0 ]; then
61 stat_append "[ERR]"
63 rm $SKSRECONPID
64 rm_daemon sksdb
65 stat_append ".."
66 else
67 stat_append "[ERR]"
70 stat_append "sksdb"
71 if [ -f $SKSDBPID ]; then
72 PID="$(cat $SKSDBPID)"
74 if [ -n "$PID" ]; then
75 kill $PID 2> /dev/null
76 if [ $? -gt 0 ]; then
77 stat_append "[ERR]"
79 rm $SKSDBPID
80 rm_daemon sksdb
81 stat_append ".."
82 else
83 stat_append "[ERR]"
86 stat_done
89 restart|force-reload)
90 $0 stop
91 sleep 1
92 $0 start
95 echo "Usage: $0 {start|stop|restart}"
96 exit 1
98 esac
100 exit 0