forked from cj13579/tvmonkey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_check.sh
executable file
·153 lines (138 loc) · 3.69 KB
/
config_check.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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
# SCRIPT: config_check.sh
#
# PURPOSE: Configuraton checking script.
#
# Author: Chris Blake
APP_HOME="$( cd "$( dirname "$0" )" && pwd )"
# Source the applications configs
. $APP_HOME/tvmonkey.config
function main ()
{
echo "Checking watch locataion..."
sleep 1
if [[ -d $MOV_DIR ]] ; then
echo "$MOV_DIR exists.";
fi
echo ""
echo "Checking transmission command..."
sleep 1
if [[ -n "$TR_CMD" ]] ; then
x=$($TR_CMD --list)
if [[ $? == "0" ]] ; then
echo "Transmission connection command is fine."
else
echo "Error in Transmission connection command."
fi
fi
echo ""
echo "Checking connections to XBMC libraries..."
sleep 1
if [[ -n "$LIBRARY" ]] ; then
i=0
for x in $LIBRARY
do
let i++;
done
echo "There are $i XBMC libraries defined. Checking that we can see them..."
sleep 1
for LIB in $LIBRARY
do
x=$(ping -c 1 $LIB)
y=$(echo $x | cut --only-delimited --delimiter=' ' --fields=24-25)
if [[ $y = '1 received,' ]] ; then
echo "$LIB seems to be up. I can ping it..."
else
echo "$LIB is unreachable. Check it is up..."
fi
done
fi
echo ""
echo "Checking FlexGet config file..."
sleep 1
if [[ -f $FLEXCONF ]] ; then
if [[ -w $FLEXCONF ]] ; then
echo "We can read and write to the file."
echo "Checking that FlexGet likes the file..."
echo
sleep 1
x=$(flexget --check -c $FLEXCONF 2>&1 | tee -a flexresult)
cat flexresult | while read series
do
x=$(echo $series | cut --only-delimited --delimiter=' ' --fields=3)
if [[ "$x" = "INFO" ]] ; then
show=$(echo $series | cut --only-delimited --delimiter=' ' --fields=6-99)
echo "$show and is fine..."
elif [[ "$x" = "WARN" ]] ; then
show=$(echo $series | cut --only-delimited --delimiter=' ' --fields=6-99)
echo "$show and has warnings..."
else
show=$(echo $series | cut --only-delimited --delimiter=' ' --fields=6-99)
echo "$show and has errors in it..."
fi
done
if [[ -f flexresult ]] ; then
x=$(rm flexresult)
fi
elif [[ -r $FLEXCONF ]] ; then
echo "Seems like we can only read this file."
echo "You won't be able to edit this via the Web Interface.."
echo ""
echo "Checking the FlexGet likes the file..."
sleep 1
x=$(flexget --check -c $FLEXCONF 2>&1 | tee -a flexresult)
cat flexresult | while read series
do
x=$(echo $series | cut --only-delimited --delimiter=' ' --fields=3)
if [[ "$x" = "INFO" ]] ; then
show=$(echo $series | cut --only-delimited --delimiter=' ' --fields=6-99)
echo "$show and is fine..."
elif [[ "$x" = "WARN" ]] ; then
show=$(echo $series | cut --only-delimited --delimiter=' ' --fields=6-99)
echo "$show and has warnings..."
else
show=$(echo $series | cut --only-delimited --delimiter=' ' --fields=6-99)
echo "$show and has errors in it..."
fi
done
if [[ -f flexresult ]] ; then
x=$(rm flexresult)
fi
else
echo "Unable to find or read this file."
fi
fi
}
function show_help ()
{
echo ""
echo ""
echo "+--------------------------------------------------------------+"
echo "| You are currently using TVMonkey config checker version: 0.1 |"
echo "+--------------------------------------------------------------+"
echo ""
echo "Usage: $0 [OPTION] ."
echo "-i or --interactive : Use this option to run the program and have messages shown to the screen."
echo "use -h or --info to show this information."
echo ""
}
if [ "$#" -eq "1" ] ; then
for arg in "$@"
do
case "$arg" in
-h | --info )
show_help
exit 0
;;
-i | --interactive)
sleep 2
main
;;
*)
echo "Usage: $0 [OPTION]. Use $0 -h or --info for more information"
;;
esac
done
else
echo "Usage: $0 [OPTION]. Use $0 -h or --info for more information."
fi