updated on Thu Jan 26 00:18:00 UTC 2012
[aur-mirror.git] / swapspace / swapspace
blob3f6d3f62df47c3d15e10801707acfa021662cb74
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 SWAPSPACE_ARGS="-q -d -p /var/run/swapspace.pid"
7 PIDFILE=/var/run/swapspace.pid
8 PID=$(cat $PIDFILE 2> /dev/null)
9 if ! readlink -q /proc/$PID/exe | grep -q \^/usr/sbin/swapspace; then
10 PID=
11 rm -f $PIDFILE
14 [ -r /etc/conf.d/swapspace ] && . /etc/conf.d/swapspace
16 PID=$(get_pid swapspace)
18 case "$1" in
19 start)
20 stat_busy "Starting swapspace"
21 [[ -z $PID ]] && /usr/sbin/swapspace $SWAPSPACE_ARGS
22 if [[ $? -gt 0 ]]; then
23 stat_fail
24 else
25 add_daemon swapspace
26 stat_done
29 stop)
30 stat_busy "Stopping swapspace"
31 [[ ! -z $PID ]] && kill $PID &> /dev/null
32 if [[ $? -gt 0 ]]; then
33 stat_fail
34 else
35 rm_daemon swapspace
36 stat_done
39 restart)
40 $0 stop
41 $0 start
43 status)
44 stat_busy "Checking swapspace status..."
45 ck_status swapspace
48 echo "usage: $0 {start|stop|restart|status}"
49 esac