-
Notifications
You must be signed in to change notification settings - Fork 6
/
mentoinit.sh
executable file
·113 lines (110 loc) · 2.97 KB
/
mentoinit.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
# File: mentoinit.sh
# Author: Zhang Xijin(mfs6174)
# Email: [email protected]
#
# Copyright (C) 2011 Zhang Xijin(mfs6174)
#
# This file is part of OwrtXD.
#
# OwrtXD is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OwrtXD is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OwrtXD. If not, see <http://www.gnu.org/licenses/>.
# This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 Generic License.
# http://creativecommons.org/licenses/by-nc/2.5/
# 未经作者授权,绝对不允许用做商业目的!
#!/bin/sh
sta="1"
echo "copying and setting config files..."
echo " option 'ipaddr' '$2'" >> conf/network.static
if [ "$sta" = "1" ]; then
cp conf/network.static /etc/config/network
dm="0"
else
cp conf/network /etc/config/
mv /usr/share/udhcpc/default.script /usr/share/udhcpc/default.script.back
cp conf/default.script /usr/share/udhcpc/
dm="1"
fi
mv /etc/config/dhcp /etc/config/dhcp.back
cp conf/dhcp /etc/config/
cp conf/firewall /etc/config/
cp conf/dropbear /etc/config/
cp conf/resolv.conf /etc/
cp /etc/resolv.conf /etc/resolv.conf.org
if [ "$6" = "0" ]; then
cp /etc/rc.local /etc/rc.local.back
sed -i '/exit 0/i\\start.sh' /etc/rc.local
fi
echo "copying and setting bin files..."
if [ "$sta" = "1" ]; then
cp mentohust/mento.xd /usr/sbin/mento
df=""
dv="0.00"
else
cp mentohust/mento /usr/sbin/mento
cp -r mentohust/mentohust /etc/
df="/etc/mentohust"
dv="4.60"
fi
chmod +x /usr/sbin/mento
opkg install packages/libpcap.ipk
echo "generating config and start.sh..."
echo "[MentoHUST]
MaxFail=30
Username=$3
Password=$4
Nic=eth1.1
IP=$2
Mask=
Gateway=$5
DNS=0.0.0.0
PingHost=61.134.1.5
Timeout=8
EchoInterval=30
RestartWait=15
StartMode=1
DhcpMode=$dm
DaemonMode=2
ShowNotify=5
Version=$dv
DataFile=$df
">mentohust/mentohust.conf
if [ "$dm" = "1" ]; then
echo "DhcpScript=udhcpc -r $2 -i eth1.1" >> mentohust/mentohust.conf
echo "#!/bin/sh
ifconfig eth1.1 down
ifconfig eth1.1 up
ifconfig eth1.1 hw ether $1
route add default gw $5
chmod +w /etc/resolv.conf
cp /etc/resolv.conf.org /etc/resolv.conf
chmod 444 /etc/resolv.conf
mento
">start.sh
else
echo "DhcpScript=" >> mentohust/mentohust.conf
echo "#!/bin/sh
ifconfig eth1.1 down
ifconfig eth1.1 up
ifconfig eth1.1 $2 netmask 255.255.255.0
route add default gw $5
ifconfig eth1.1 hw ether $1
chmod +w /etc/resolv.conf
cp /etc/resolv.conf.org /etc/resolv.conf
chmod 444 /etc/resolv.conf
mento
">start.sh
fi
cp mentohust/mentohust.conf /etc/
chmod +x start.sh
cp start.sh /usr/sbin/
echo "done! just run start.sh to start"