-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathext_init.sh
More file actions
91 lines (81 loc) · 1.49 KB
/
ext_init.sh
File metadata and controls
91 lines (81 loc) · 1.49 KB
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
#!/bin/sh
MOUNT="/opt"
INITD="$MOUNT/etc/init.d"
LOCKFILE="/var/lock/init_sh"
HOSTFILE="/etc/hosts"
export PATH=$MOUNT/bin:$MOUNT/sbin:/sbin:/usr/sbin:/bin:/usr/bin
whait_for_init_finish() {
logger "Waiting for init to finish"
COUNT=10
while [ true ]; do
if [ ! -f $HOSTFILE ]; then
logger "Waiting for $HOSTFILE"
sleep 1
COUNT=$((COUNT-1))
if [ $COUNT = 0 ]; then
logger "Waiting for $HOSTFILE failed. Exiting"
exit 1
fi
else
break
fi
done
COUNT=15
while [ true ]; do
if [ -f $LOCKFILE ]; then
logger "Waiting for $LOCKFILE to be removed"
sleep 1
COUNT=$((COUNT-1))
if [ $COUNT = 0 ]; then
logger "Waiting for $LOCKFILE failed. Exiting"
exit 1
fi
else
break
fi
done
# extra 2 seconds to sleep
sleep 2
}
do_mount() {
/bin/mount -o bind "/media/DISK_A1/opt" /opt
if [ $? -ne 0 ] ; then
logger "Mount /media/DISK_A1/opt to /opt FAILED! WTF?"
exit 1
fi
}
do_umount() {
/bin/umount /opt
}
if [ -f $LOCKFILE ]; then
logger "$LOCKFILE exists"
fi
if [ ! -f $HOSTFILE ]; then
logger "$HOSTFILE does not exist"
fi
case "$1" in
start)
whait_for_init_finish
do_mount
/opt/etc/init.d/rc.unslung start
;;
stop)
/opt/etc/init.d/rc.unslung stop
sleep 1
do_umount
;;
restart)
# Do nothing wait for /bin/init.sh to finish. All initialization is done from mount script
;;
link_up)
;;
ppp_up)
;;
link_down)
;;
ppp_down)
;;
*)
echo "Usage: $0 {start|stop|restart|link_up|link_down|ppp_up|ppp_down}"
;;
esac