forked from Shelnutt2/cuda-wine-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto-mator.sh
74 lines (66 loc) · 1.85 KB
/
auto-mator.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Script to automatically adjust the SLEEPTIME in gpu3 wrapper.
# Copyright 2010 Seth Shelnutt
# Copyright 2010 Bas Couwenberg <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
trap 'killz' INT
killz(){
wineserver -k
echo "Exiting, thank's for using auto-mator"
exit 0
}
fahcore_pid() {
if $(ps -C FahCore_15.exe -o pid=)
then
export PID=$(ps -C FahCore_15.exe -o pid=)
return true
elif $(ps -C FahCore_11.exe -o pid=)
then
export PID=$(ps -C FahCore_11.exe -o pid=)
return true
else
echo "No known FahCore found!"
return false
fi
}
export SLEEPTIME="3000000"
RUNGPU="nice -n 17 wine [email protected]"
eval $RUNGPU &
sleep 30
while [ fahcore_pid != true ]
do
sleep 30
done
while true
do
CPUP=$(top -bn 3 -p $PID | grep "FahCore" | awk -F" " '{ print $9 }')
CPUP1=$(echo $CPUP | awk -F" " '{ print $1 }')
CPUP2=$(echo $CPUP | awk -F" " '{ print $2 }')
CPUP3=$(echo $CPUP | awk -F" " '{ print $3 }')
CPU=$((($CPUP3 + $CPUP2 + $CPUP1) / 3))
if [ "$CPU" -le "25" ]
then
sleep 60
elif [ "$CPU" -le "8" ]
then
export SLEEPTIME=$(( $SLEEPTIME + 2500 ))
sleep 5
else
export SLEEPTIME=$(( $SLEEPTIME - 5000 ))
sleep 5
fi
done
exit 0