updated on Tue Jan 10 04:01:21 UTC 2012
[aur-mirror.git] / foldingathome-gpu-nvidia / foldingathome-gpu.rc.d
blobd5b2be3fbe710c8a56ff6c582c10a3da98bf43ef
1 #!/bin/bash
2 #/etc/rc.d/foldingathome-gpu
4 # Starts the Folding@Home-GPU client in the background
6 . /etc/rc.conf
7 . /etc/rc.d/functions
8 . /etc/conf.d/foldingathome-gpu
10 PID=`pidof -o %PPID Folding@home-Win32-gpu.exe`
12 function pause(){
13 read -s -n 1 -p "Press any key to continue . . ."
14 echo
17 function checkconfigs(){
18 if [ "$FAH_GPUS" -ge 1 ]; then
19 if [ -f /opt/fah-gpu/alpha/client.cfg ]; then
20 echo "Client 1 is configured, ok to go."
21 else
22 echo "Client 1 needs to be configured!"
23 pause
24 cd /opt/fah-gpu/alpha
25 WINEPREFIX=/opt/fah-gpu/ wine /opt/fah-gpu/Folding@home-Win32-gpu.exe -configonly $GPU_TYPE
28 if [ "$FAH_GPUS" -ge 2 ]; then
29 if [ -f /opt/fah-gpu/bravo/client.cfg ]; then
30 echo "Client 2 is configured, ok to go."
31 else
32 echo "Client 2 needs to be configured!"
33 echo "Copying client.cfg from client 1"
34 cp /opt/fah-gpu/alpha/client.cfg /opt/fah-gpu/bravo/
35 cd /opt/fah-gpu/bravo && cat client.cfg | sed "s/machineid=2/machineid=3/g" > client.cfg
38 if [ "$FAH_GPUS" -ge 3 ]; then
39 if [ -f /opt/fah-gpu/charlie/client.cfg ]; then
40 echo "Client 3 is configured, ok to go."
41 else
42 echo "Client 3 needs to be configured!"
43 echo "Copying client.cfg from client 1"
44 cp /opt/fah-gpu/alpha/client.cfg /opt/fah-gpu/charlie/
45 cd /opt/fah-gpu/charlie && cat client.cfg | sed "s/machineid=2/machineid=4/g" > client.cfg
48 if [ "$FAH_GPUS" -ge 4 ]; then
49 if [ -f /opt/fah-gpu/delta/client.cfg ]; then
50 echo "Client 4 is configured, ok to go."
51 else
52 echo "Client 4 needs to be configured!"
53 echo "Copying client.cfg from client 1"
54 cp /opt/fah-gpu/alpha/client.cfg /opt/fah-gpu/delta/
55 cd /opt/fah-gpu/delta && cat client.cfg | sed "s/machineid=2/machineid=5/g" > client.cfg
58 if [ "$FAH_GPUS" -ge 5 ];then
59 if [ -f /opt/fah-gpu/echo/client.cfg ]; then
60 echo "Client 5 is configured, ok to go."
61 else
62 echo "Client 5 needs to be configured!"
63 echo "Copying client.cfg from client 1"
64 cp /opt/fah-gpu/alpha/client.cfg /opt/fah-gpu/echo/
65 cd /opt/fah-gpu/echo && cat client.cfg | sed "s/machineid=2/machineid=6/g" > client.cfg
68 if [ "$FAH_GPUS" -ge 6 ];then
69 if [ -f /opt/fah-gpu/foxtrot/client.cfg ]; then
70 echo "Client 6 is configured, ok to go."
71 else
72 echo "Client 6 needs to be configured!"
73 echo "Copying client.cfg from client 1"
74 cp /opt/fah-gpu/alpha/client.cfg /opt/fah-gpu/foxtrot/
75 cd /opt/fah-gpu/foxtrot && cat client.cfg | sed "s/machineid=2/machineid=7/g" > client.cfg
78 if [ "$FAH_GPUS" -ge 7 ];then
79 if [ -f /opt/fah-gpu/golf/client.cfg ]; then
80 echo "Client 7 is configured, ok to go."
81 else
82 echo "Client 7 needs to be configured!"
83 echo "Copying client.cfg from client 1"
84 cp /opt/fah-gpu/alpha/client.cfg /opt/fah-gpu/golf/
85 cd /opt/fah-gpu/golf && cat client.cfg | sed "s/machineid=2/machineid=8/g" > client.cfg
88 if [ "$FAH_GPUS" -ge 8 ];then
89 if [ -f /opt/fah-gpu/hotel/client.cfg ]; then
90 echo "Client 8 is configured, ok to go."
91 else
92 echo "Client 8 needs to be configured!"
93 echo "Copying client.cfg from client 1"
94 cp /opt/fah-gpu/alpha/client.cfg /opt/fah-gpu/hotel/
95 cd /opt/fah-gpu/hotel && cat client.cfg | sed "s/machineid=2/machineid=9/g" > client.cfg
98 if [ "$FAH_GPUS" -ge 9 ]; then
99 echo "You have too many GPUs set!"
103 function runem(){
104 if [ "$FAH_GPUS" -ge 1 ]; then
105 cd /opt/fah-gpu/alpha
106 WINEPREFIX=/opt/fah-gpu/ wine /opt/fah-gpu/Folding@home-Win32-gpu.exe $GPU_TYPE -gpu 0 $FAH_CLIENT_FLAGS >> /dev/null 2>&1 &
107 sleep 1
109 if [ "$FAH_GPUS" -ge 2 ]; then
110 cd /opt/fah-gpu/bravo
111 WINEPREFIX=/opt/fah-gpu/ wine /opt/fah-gpu/Folding@home-Win32-gpu.exe $GPU_TYPE -gpu 1 $FAH_CLIENT_FLAGS >> /dev/null 2>&1 &
112 sleep 1
114 if [ "$FAH_GPUS" -ge 3 ]; then
115 cd /opt/fah-gpu/charlie
116 WINEPREFIX=/opt/fah-gpu/ wine /opt/fah-gpu/Folding@home-Win32-gpu.exe $GPU_TYPE -gpu 2 $FAH_CLIENT_FLAGS >> /dev/null 2>&1 &
117 sleep 1
119 if [ "$FAH_GPUS" -ge 4 ]; then
120 cd /opt/fah-gpu/delta
121 WINEPREFIX=/opt/fah-gpu/ wine /opt/fah-gpu/Folding@home-Win32-gpu.exe $GPU_TYPE -gpu 3 $FAH_CLIENT_FLAGS >> /dev/null 2>&1 &
122 sleep 1
124 if [ "$FAH_GPUS" -ge 5 ]; then
125 cd /opt/fah-gpu/echo
126 WINEPREFIX=/opt/fah-gpu/ wine /opt/fah-gpu/Folding@home-Win32-gpu.exe $GPU_TYPE -gpu 4 $FAH_CLIENT_FLAGS >> /dev/null 2>&1 &
127 sleep 1
129 if [ "$FAH_GPUS" -ge 6 ]; then
130 cd /opt/fah-gpu/foxtrot
131 WINEPREFIX=/opt/fah-gpu/ wine /opt/fah-gpu/Folding@home-Win32-gpu.exe $GPU_TYPE -gpu 5 $FAH_CLIENT_FLAGS >> /dev/null 2>&1 &
132 sleep 1
134 if [ "$FAH_GPUS" -ge 7 ]; then
135 cd /opt/fah-gpu/golf
136 WINEPREFIX=/opt/fah-gpu/ wine /opt/fah-gpu/Folding@home-Win32-gpu.exe $GPU_TYPE -gpu 6 $FAH_CLIENT_FLAGS >> /dev/null 2>&1 &
137 sleep 1
139 if [ "$FAH_GPUS" -ge 8 ]; then
140 cd /opt/fah-gpu/hotel
141 WINEPREFIX=/opt/fah-gpu/ wine /opt/fah-gpu/Folding@home-Win32-gpu.exe $GPU_TYPE -gpu 7 $FAH_CLIENT_FLAGS >> /dev/null 2>&1 &
142 sleep 1
146 case "$1" in
147 start)
148 stat_busy "Starting Folding@Home-GPU"
149 if [ -z "$PID" ]; then
150 if [ -d /opt/fah-gpu/drive_c ]; then
151 checkconfigs
152 runem
153 else
154 echo "WinePrefix non-existent, creating WinePrefix"
155 pause
156 cd /opt/fah-gpu
157 WINEPREFIX=/opt/fah-gpu wineboot
158 echo "WinePrefix has been created, restarting daemon."
159 pause
160 /etc/rc.d/foldingathome-gpu start
164 if [ ! -z "$PID" -o $? -gt 0 ]; then
165 stat_fail
166 else
167 add_daemon foldingathome-gpu
168 stat_done
173 stop)
174 stat_busy "Stopping Folding@Home-GPU"
175 [ ! -z "$PID" ]&& WINEPREFIX=/opt/fah-gpu wineserver -k &> /dev/null
176 if [ $? -gt 0 ]; then
177 stat_fail
178 else
179 rm_daemon foldingathome-gpu
180 stat_done
184 restart)
185 $0 stop
186 sleep 1
187 $0 start
191 echo $"Usage: $0 {start|stop|restart}"
192 esac