-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocesscontrol.src
54 lines (49 loc) · 2.3 KB
/
processcontrol.src
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
USER=`ls -l ./|grep tmp\ -|awk '{print $3}'`
www=www-data
function stopStartRemoteRead() {
#arg1 any value, start process, will always stop if running
#arg2 is SingleUsefile
#arg3 is remote host
#arg4 is capfile
x=`ps -U $www -f|grep $2|grep echo\ $USER|grep -v grep|awk '{print $2}'`
[ "x$x" != "x" ] && kill -9 $x && /bin/echo -n "Killing pid $x. "
#while [ "$x" == "`ps -U $www|grep $2|grep echo\ $USER|grep -v grep|awk '{print $1}'`" ]; do
# sleep 1
#done
#/bin/echo -n "Killed pid $x. "
if [ $1 -ne 0 ]; then
ssh -o StrictHostKeyChecking=no -t -t -n -i /var/www/.ssh/$2 $3 echo $USER > $4 &
/bin/echo -n "Started pid $!."
fi
}
function stopStartScript() {
#arg1 any value, start process, will always stop if running
#arg2 is Script
x=`ps -U $www -f|grep "$2"|grep echo\ $USER|grep -v grep|awk '{print $2}'`
[ "x$x" != "x" ] && kill -9 $x && /bin/echo -n "Killing pid $x. "
#while [ "$x" == "`ps -U $www|grep "$2"|grep echo\ $USER|grep -v grep|awk '{print $1}'`" ]; do
# sleep 1
#done
#/bin/echo -n "Killed pid $x. "
if [ $1 -ne 0 ]; then
bash /opt/DiallingServer/$2 echo $USER &
/bin/echo -n "Started pid $!."
fi
}
function processcontrol() {
# Call by either the control buttons (if present) on the website or by the DiallingServer process.
OP=1
[ "x$A" == "xSTOP" ] && OP=0
[ "x$A" == "xSTART" ] && OP=1
case $P in
DIALLINGSERVER) stopStartScript $OP "DiallingServer.bash";;
PHONE1) stopStartScript $OP "runVSSP.bash 1 tor.dts.tprm.ca dist_9104 /var/www/.sip/pass_0009_dist_9104 1 2";;
PHONE2) stopStartScript $OP "runVSSP.bash 2 tor.dts.tprm.ca dist_9104 /var/www/.sip/pass_0009_dist_9104 1 2";;
PHONE3) stopStartScript $OP "runVSSP.bash 3 tor.dts.tprm.ca dist_9105 /var/www/.sip/pass_0010_dist_9105 1 2";;
PHONE4) stopStartScript $OP "runVSSP.bash 4 tor.dts.tprm.ca dist_9105 /var/www/.sip/pass_0010_dist_9105 1 2";;
PHONE5) stopStartScript $OP "runVSSP.bash 5 tor.dts.tprm.ca dist_9106 /var/www/.sip/pass_0011_dist_9106 1 2";;
PHONE6) stopStartScript $OP "runVSSP.bash 6 tor.dts.tprm.ca dist_9106 /var/www/.sip/pass_0011_dist_9106 1 2";;
CRAFTRECORDS) stopStartRemoteRead $OP idrsa [email protected] ./tmp/did.CRAFTS ;;
*) /bin/echo "Unknown instructions $P"
esac
}