/
stop.sh
executable file
·65 lines (51 loc) · 1.03 KB
/
stop.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
#!/bin/bash
pidFile='pids.pid'
servicePidFile='services.pid'
servicePortFile="./servicePorts"
httpPortFile="./httpPorts"
temp="./temp"
if [[ -f ${servicePortFile} ]];
then
# delete pidfile
rm ${servicePortFile}
else
echo "port file wasn't found. Aborting..."
fi
if [[ -f ${httpPortFile} ]];
then
# delete pidfile
rm ${httpPortFile}
else
echo "port file wasn't found. Aborting..."
fi
if [[ -f ${pidFile} ]];
then
#read file in reverse with tac to kill in order sensor -> station -> service
pids=`tac ${pidFile}`
#kill all pids
for pid in "${pids[@]}"
do
kill ${pid}
done
# delete pidfile
rm ${pidFile}
else
echo "Process file wasn't found. Aborting..."
fi
sleep 4
rm -r $temp
rm -r *tcp*
if [[ -f ${servicePidFile} ]];
then
#read file in reverse with tac to kill in order sensor -> station -> service
pids=`tac ${servicePidFile}`
#kill all pids
for pid in "${pids[@]}"
do
kill ${pid}
done
# delete pidfile
rm ${servicePidFile}
else
echo "Process file wasn't found. Aborting..."
fi