-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprepare_vm.sh
93 lines (69 loc) · 2.01 KB
/
prepare_vm.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
#!/bin/sh
if [ ! -z "$1" ]; then
uci set system.@system[0].hostname="$1"
uci commit system
/etc/init.d/system reload
fi
if [ ! -z "$2" ]; then
if [ "$2" = "dhcp" ]; then
uci set network.lan.proto="dhcp"
uci set network.lan.ifname="eth0"
uci set network.wan.ifname="eth1"
uci set network.wan6.ifname="eth1"
uci commit network
/etc/init.d/network restart
/etc/init.d/dnsmasq restart 2>/dev/null
#uci add_list umdns.@umdns[-1].network="wan"
#uci commit umdns
#/etc/init.d/umdns reload
else
uci set network.lan.ipaddr="$2"
uci commit network
uci set dhcp.lan='dhcp'
uci set dhcp.lan.interface="lan"
uci set dhcp.lan.start='100'
uci set dhcp.lan.limit='150'
uci set dhcp.lan.leasetime='12h'
uci commit dhcp
/etc/init.d/network restart
/etc/init.d/dnsmasq restart 2>/dev/null
fi
fi
if [ ! -z "$3" ]; then
uci set network.lan2='interface'
uci set network.lan2.proto="static"
uci set network.lan2.type="bridge"
uci set network.lan2.ifname='eth2'
uci set network.lan2.ipaddr="$3"
uci set network.lan2.netmask='255.255.255.0'
uci commit network
uci set dhcp.lan2='dhcp'
uci set dhcp.lan2.interface="lan2"
uci set dhcp.lan2.start='100'
uci set dhcp.lan2.limit='150'
uci set dhcp.lan2.leasetime='12h'
uci commit dhcp
/etc/init.d/network restart
/etc/init.d/dnsmasq restart 2>/dev/null
/etc/init.d/odhcpd restart
uci add_list firewall.@zone[0].network='lan2'
uci commit firewall
/etc/init.d/firewall reload 2>/dev/null
fi
opkg update
opkg install umdns uhttpd-mod-ubus kmod-mac80211-hwsim
[ ! -d /etc/umdns ] && mkdir -p /etc/umdns
cat <<EOT > /etc/umdns/autodiscovery.json
{
"http_80": { "service": "_http._tcp.local", "port": 80, "txt": [ "daemon=uhttpd-mod-ubus"] }
}
EOT
uci add_list umdns.@umdns[-1].network="wan"
uci commit umdns
/etc/init.d/umdns reload
uci set uhttpd.main.ubus_cors='1'
uci commit uhttpd
/etc/init.d/uhttpd reload
/etc/init.d/network restart
ubus call umdns reload
ubus call umdns update