-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfirst-install
executable file
·87 lines (64 loc) · 1.83 KB
/
first-install
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
#!/bin/bash
### BEGIN INIT INFO
# Provides: first-install
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start OGN first install
### END INIT INFO
export PATH=$PATH:/usr/local/bin
export HOSTNAME=$(hostname -s)
fail () {
echo $@
exit 1
}
echo_failure () {
echo " [failed]"
}
launch () {
if [ "$1" = "-reload" ]
then
reload=YES
shift
fi
/usr/local/bin/httpi 2>/dev/null
configurelocation="https://ognconfig.onglide.com/files/v2.1/configure"
# remove any previous data from the webpage in case things break
mkdir /tmp/htdocs 2>/dev/null
touch /tmp/htdocs/index.html 2>/dev/null
chown -R ogn:ogn /tmp/htdocs
count=0
# make sure we have DNS
while ! host ognconfig.onglide.com;
do
echo "<h1>DNS is not resolving ognconfig.onglide.com properly please check your DNS server entry is reachable</h1>" > /tmp/htdocs/index.html
sleep 20
done
/usr/bin/curl -R -z /home/ogn/configure ${configurelocation} -o /home/ogn/configure 2>/dev/null
while [ $? -ne 0 -a $count -le 3 ];
do
count=$((count +1))
date >> /tmp/htdocs/index.html
echo " - unable to reach ognconfig.onglide.com<br/>" >> /tmp/htdocs/index.html
echo " - unable to reach ognconfig.onglide.com (retry # $count of 3)"
sleep 10
/usr/bin/curl -R -z /home/ogn/configure ${configurelocation} -o /home/ogn/configure 2>/dev/null
done
chmod +x /home/ogn/configure
chown ogn /home/ogn/configure
# make sure we don't litter root directory with junk
cd /home/ogn/rtlsdr-ogn
# run the configuration script
/usr/bin/perl /home/ogn/configure
}
start () {
launch $*
}
CMD=$1
shift
case "$CMD" in
(start) start $*;;
(stop) echo $*;;
(*) echo "Usage: $0 {start}";;
esac