-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathydbstat.sh
executable file
·48 lines (46 loc) · 1.05 KB
/
ydbstat.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
#!/bin/bash
if [[ "$1" != "start" && "$1" != "stop" && "$1" != "status" ]]
then
echo "Pass either start, stop or status as the first parameter"
exit
fi
if [[ "$1" == "start" ]]
then
if test -e ydbstat.pid
then
echo "Process is already running as $(cat ydbstat.pid)"
exit
elif [[ "$YOTTA_PROM_PORT" == "" ]]
then
read -p "Please enter the port you wish the Prometheus scraper ro run on? " port
if [[ "$port" =~ [[:digit:]]{4,5} ]]
then
export YOTTA_PROM_PORT=$port
else
echo "Port must be 4 or 5 digits only"
exit
fi
fi
./ydbstat.py &
echo $! > ydbstat.pid
elif [[ "$1" == "stop" ]]
then
if test -e ydbstat.pid
then
kill -9 $(cat ydbstat.pid)
rm -f ydbstat.pid
else
echo "Process is not running!!"
exit
fi
elif [[ "$1" == "status" ]]
then
if test -e ydbstat.pid
then
echo "Process is running as process $(cat ydbstat.pid)"
exit
else
echo "Process is not running!!"
exit
fi
fi