-
Notifications
You must be signed in to change notification settings - Fork 6
/
system_up
executable file
·103 lines (98 loc) · 2.83 KB
/
system_up
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
#
# system_up
# Patricia Lindner
# Aug 4, 2014
#
# This program can be used to determine whether the entire ION system is up or individual
# subsections.
function USAGE {
echo
echo "System_Up: Interplanetary Overlay Network system started script"
echo "USAGE:"
echo " system_up [-A] [-i \"{p|w} ion\"] [-b \"{p|w} bp\"] [-l \"{p|w} ltp\'] [-D \"{p|w} dtpc\"] [-c \"{p|w} cfdp\"]"
echo
echo " -A Run all checks without polling"
echo " -W [time] Run all checks with polling. Optional timeout time."
echo
echo " -i \"{p|w} [ion]\" Determine if ion subsystem is running. Optional timeout ion."
echo " -b \"{p|w} [bp]\" Determine if bp subsystem is running. Optional timeout bp."
echo " -l \"{p|w} [ltp]\" Determine if ltp subsystem is running. Optional timeout ltp."
echo " -D \"{p|w} [dtpc]\" Determine if dtpc subsystem is running. Optional timeout dtpc."
echo " -c \"{p|w} [cfdp]\" Determine if cfdp subsystem is running. Optional timeout cfdp"
}
function CHECK_ARGS {
OPTARG_NUM=`echo "$1" | wc -w`
if [ "$OPTARG_NUM" -gt 2 ]; then
echo "Illegal number of parameters = $OPTARG_NUM"
echo "See \"system_up -h\" for help"
exit 0
fi
}
# check for all the options
ret_val=0
while getopts ":AW:i:b:l:D:c:h" options; do
case $options in
A ) echo "Now checking ion"
echo "t w" | ionadmin
ret_val=$((ret_val+=$?))
echo "Now checking bp"
echo "t w" | bpadmin
ret_val=$((ret_val+=$?))
echo "Now checking ltp"
echo "t w" | ltpadmin
ret_val=$((ret_val+=$?))
echo "Now checking dtpc"
echo "t w" | dtpcadmin
ret_val=$((ret_val+=$?))
echo "Now checking cfdp"
echo "t w" | cfdpadmin
ret_val=$((ret_val+=$?))
;;
W ) echo "Now checking ion"
echo "t p ${OPTARG}" | ionadmin
ret_val=$((ret_val+=$?))
echo "Now checking bp"
echo "t p ${OPTARG}" | bpadmin
ret_val=$((ret_val+=$?))
echo "Now checking ltp"
echo "t p ${OPTARG}" | ltpadmin
ret_val=$((ret_val+=$?))
echo "Now checking dtpc"
echo "t p ${OPTARG}" | dtpcadmin
ret_val=$((ret_val+=$?))
echo "Now checking cfdp"
echo "t p ${OPTARG}" | cfdpadmin
ret_val=$((ret_val+=$?))
;;
i ) echo "Now checking ion"
CHECK_ARGS $OPTARG
echo "t ${OPTARG}" | ionadmin
ret_val=$((ret_val+=$?));;
b ) echo "Now checking bp"
CHECK_ARGS $OPTARG
echo "t ${OPTARG}" | bpadmin
ret_val=$((ret_val+=$?));;
l ) echo "Now checking ltp"
CHECK_ARGS $OPTARG
echo "t ${OPTARG}" | ltpadmin
ret_val=$((ret_val+=$?));;
D ) echo "Now checking dtpc"
CHECK_ARGS $OPTARG
echo "t ${OPTARG}" | dtpcadmin
ret_val=$((ret_val+=$?));;
c ) echo "Now checking cfdp"
CHECK_ARGS $OPTARG
echo "t ${OPTARG}" | cfdpadmin
ret_val=$((ret_val+=$?));;
h ) USAGE
exit 1;;
\? ) USAGE
exit 1;;
* ) USAGE
exit 1;;
esac
done
echo
echo "ION system started script completed."
exit $ret_val