-
Notifications
You must be signed in to change notification settings - Fork 80
/
init_router
43 lines (31 loc) · 890 Bytes
/
init_router
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
#!/bin/bash
# run following command to reset router
# $: ssh [email protected] <<< "$(cat init_router)"
set -e
if [ ! -d /tmp/mnt/sda1/entware.bak ]; then
echo 'not exist /tmp/mnt/sda1/entware.bak, init_router not continuing.'
exit
fi
[ -e /opt/etc/toggle_proxy.sh ] && sh /opt/etc/toggle_proxy.sh disable
date=$(date '+%Y-%m-%d_%H-%M-%S')
mv /tmp/mnt/sda1/entware /tmp/mnt/sda1/entware_bak_$date
# recreate a new entware directory.
cp -a /tmp/mnt/sda1/entware.bak /tmp/mnt/sda1/entware
rm -f /opt/var/lock/opkg.lock
cat <<'HEREDOC' > /jffs/scripts/services-start
#!/bin/sh
RC='/opt/etc/init.d/rc.unslung'
i=30
until [ -x "$RC" ] ; do
i=$(($i-1))
if [ "$i" -lt 1 ] ; then
logger "Could not start Entware"
exit
fi
sleep 1
done
$RC start
HEREDOC
rm -f /jffs/scripts/wan-start /jffs/scripts/dhcpc-event
echo '[0m[33mRouter will reboot ...[0m'
reboot