updated on Mon Jan 23 12:00:23 UTC 2012
[aur-mirror.git] / foldingathome-smp / foldingathome-smp.rc.d
blob7957a1e594f649a9fc994dfad9e0043d8f2bbafb
1 #!/bin/bash
2 #/etc/rc.d/foldingathome-smp
4 # Starts the Folding@Home-SMP client in the background
6 . /etc/rc.conf
7 . /etc/rc.d/functions
8 . /etc/conf.d/foldingathome-smp
10 PID=`pidof -o %PPID /opt/fah-smp/fah6`
11 case "$1" in
12 start)
13 stat_busy "Starting Folding@Home-SMP"
14 if [ -z "$PID" ]; then
15 if [ ! -z "$FAH_USER" ] ; then
16 if [ ! -d "/opt/fah-smp/$FAH_USER" ] ; then
17 mkdir /opt/fah-smp/$FAH_USER
18 if [ -f /opt/fah-smp/client.cfg ] ; then
19 cp /opt/fah-smp/client.cfg "/opt/fah-smp/$FAH_USER/client.cfg"
21 chown -R $FAH_USER /opt/fah-smp/$FAH_USER
22 if [ ! -z "$FAH_GRP" ] ; then
23 chgrp -R $FAH_GRP /opt/fah-smp/$FAH_USER
24 else
25 chgrp -R users /opt/fah-smp/$FAH_USER
28 cd /opt/fah-smp/$FAH_USER
29 su $FAH_USER -c "/opt/fah-smp/fah6 -smp $FAH_CLIENT_FLAGS &> /opt/fah-smp/$FAH_USER/myfah.log" &
30 else
31 cd /opt/fah-smp
32 /opt/fah-smp/fah6 -smp $FAH_CLIENT_FLAGS &> /opt/fah-smp/myfah.log &
35 if [ ! -z "$PID" -o $? -gt 0 ]; then
36 stat_fail
37 else
38 add_daemon foldingathome-smp
39 stat_done
43 stop)
44 stat_busy "Stopping Folding@Home-SMP"
45 [ ! -z "$PID" ]&& kill $PID &> /dev/null
46 if [ $? -gt 0 ]; then
47 stat_fail
48 else
49 rm_daemon foldingathome-smp
50 stat_done
54 restart)
55 $0 stop
56 sleep 1
57 $0 start
61 echo $"Usage: $0 {start|stop|restart}"
62 esac