-
Notifications
You must be signed in to change notification settings - Fork 235
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·226 lines (206 loc) · 7.44 KB
/
install.sh
File metadata and controls
executable file
·226 lines (206 loc) · 7.44 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/sh
source /koolshare/scripts/base.sh
alias echo_date='echo 【$(TZ=UTC-8 date -R +%Y年%m月%d日\ %X)】:'
MODEL=
UI_TYPE=ASUSWRT
FW_TYPE_CODE=
FW_TYPE_NAME=
DIR=$(cd $(dirname $0); pwd)
module=${DIR##*/}
get_model(){
local ODMPID=$(nvram get odmpid)
local PRODUCTID=$(nvram get productid)
if [ -n "${ODMPID}" ];then
MODEL="${ODMPID}"
else
MODEL="${PRODUCTID}"
fi
}
get_fw_type() {
local KS_TAG=$(nvram get extendno|grep koolshare)
if [ -d "/koolshare" ];then
if [ -n "${KS_TAG}" ];then
FW_TYPE_CODE="2"
FW_TYPE_NAME="koolshare官改固件"
else
FW_TYPE_CODE="4"
FW_TYPE_NAME="koolshare梅林改版固件"
fi
else
if [ "$(uname -o|grep Merlin)" ];then
FW_TYPE_CODE="3"
FW_TYPE_NAME="梅林原版固件"
else
FW_TYPE_CODE="1"
FW_TYPE_NAME="华硕官方固件"
fi
fi
}
platform_test(){
local LINUX_VER=$(uname -r|awk -F"." '{print $1$2}')
if [ -d "/koolshare" -a -f "/usr/bin/skipd" -a "${LINUX_VER}" -eq "26" ];then
echo_date 机型:"${MODEL} ${FW_TYPE_NAME} 符合安装要求,开始安装插件!"
else
exit_install 1
fi
}
get_ui_type(){
# default value
[ "${MODEL}" == "RT-AC86U" ] && local ROG_RTAC86U=0
[ "${MODEL}" == "GT-AC2900" ] && local ROG_GTAC2900=1
[ "${MODEL}" == "GT-AC5300" ] && local ROG_GTAC5300=1
[ "${MODEL}" == "GT-AX11000" ] && local ROG_GTAX11000=1
[ "${MODEL}" == "GT-AXE11000" ] && local ROG_GTAXE11000=1
local KS_TAG=$(nvram get extendno|grep koolshare)
local EXT_NU=$(nvram get extendno)
local EXT_NU=$(echo ${EXT_NU%_*} | grep -Eo "^[0-9]{1,10}$")
local BUILDNO=$(nvram get buildno)
[ -z "${EXT_NU}" ] && EXT_NU="0"
# RT-AC86U
if [ -n "${KS_TAG}" -a "${MODEL}" == "RT-AC86U" -a "${EXT_NU}" -lt "81918" -a "${BUILDNO}" != "386" ];then
# RT-AC86U的官改固件,在384_81918之前的固件都是ROG皮肤,384_81918及其以后的固件(包括386)为ASUSWRT皮肤
ROG_RTAC86U=1
fi
# GT-AC2900
if [ "${MODEL}" == "GT-AC2900" ] && [ "{FW_TYPE_CODE}" == "3" -o "{FW_TYPE_CODE}" == "4" ];then
# GT-AC2900从386.1开始已经支持梅林固件,其UI是ASUSWRT
ROG_GTAC2900=0
fi
# GT-AX11000
if [ "${MODEL}" == "GT-AX11000" -o "${MODEL}" == "GT-AX11000_BO4" ] && [ "{FW_TYPE_CODE}" == "3" -o "{FW_TYPE_CODE}" == "4" ];then
# GT-AX11000从386.2开始已经支持梅林固件,其UI是ASUSWRT
ROG_GTAX11000=0
fi
# ROG UI
if [ "${ROG_GTAC5300}" == "1" -o "${ROG_RTAC86U}" == "1" -o "${ROG_GTAC2900}" == "1" -o "${ROG_GTAX11000}" == "1" -o "${ROG_GTAXE11000}" == "1" ];then
# GT-AC5300、RT-AC86U部分版本、GT-AC2900部分版本、GT-AX11000部分版本、GT-AXE11000全部版本,骚红皮肤
UI_TYPE="ROG"
fi
# TUF UI
if [ "${MODEL}" == "TUF-AX3000" ];then
# 官改固件,橙色皮肤
UI_TYPE="TUF"
fi
}
exit_install(){
local state=$1
case $state in
1)
echo_date "本插件适用于【koolshare merlin armv7l 384/386】固件平台!"
echo_date "你的固件平台不能安装!!!"
echo_date "本插件支持机型/平台:https://github.com/koolshare/armsoft#armsoft"
echo_date "退出安装!"
rm -rf /tmp/${module}* >/dev/null 2>&1
exit 1
;;
0|*)
rm -rf /tmp/${module}* >/dev/null 2>&1
exit 0
;;
esac
}
install_ui(){
# intall different UI
get_ui_type
if [ "${UI_TYPE}" == "ROG" ];then
echo_date "安装ROG皮肤!"
sed -i '/asuscss/d' /koolshare/webs/Module_${module}.asp >/dev/null 2>&1
fi
if [ "${UI_TYPE}" == "TUF" ];then
echo_date "安装TUF皮肤!"
sed -i '/asuscss/d' /koolshare/webs/Module_${module}.asp >/dev/null 2>&1
sed -i 's/3e030d/3e2902/g;s/91071f/92650F/g;s/680516/D0982C/g;s/cf0a2c/c58813/g;s/700618/74500b/g;s/530412/92650F/g' /koolshare/webs/Module_${module}.asp >/dev/null 2>&1
fi
if [ "${UI_TYPE}" == "ASUSWRT" ];then
echo_date "安装ASUSWRT皮肤!"
sed -i '/rogcss/d' /koolshare/webs/Module_${module}.asp >/dev/null 2>&1
fi
}
install_now(){
# default value
local TITLE="Kids_Protect"
local DESCR="KP: Kids Protect,互联网内容过滤,保护未成年人上网~"
local PLVER=$(cat ${DIR}/version)
# stop first
local ENABLE=$(dbus get ${module}_enable)
if [ "${ENABLE}" == "1" -a -f "/koolshare/koolproxy/kp_config.sh" ];then
echo_date "安装前先关闭${TITLE}插件,以保证更新成功!"
sh /koolshare/koolproxy/kp_config.sh stop >/dev/null 2>&1
fi
# remove some file first
find /koolshare/init.d -name "*koolproxy*" | xargs rm -rf >/dev/null 2>&1
# remove old files, do not remove user.txt incase of upgrade
rm -rf /koolshare/bin/${module} >/dev/null 2>&1
rm -rf /koolshare/scripts/KoolProxy* >/dev/null 2>&1
rm -rf /koolshare/webs/Module_${module}.asp >/dev/null 2>&1
rm -rf /koolshare/res/icon-${module}.png >/dev/null 2>&1
rm -rf /koolshare/${module}/*.sh >/dev/null 2>&1
rm -rf /koolshare/${module}/data/dnsmasq.adblock >/dev/null 2>&1
rm -rf /koolshare/${module}/data/gen_ca.sh >/dev/null 2>&1
rm -rf /koolshare/${module}/data/${module}_ipset.conf >/dev/null 2>&1
rm -rf /koolshare/${module}/data/openssl.cnf >/dev/null 2>&1
rm -rf /koolshare/${module}/data/serial >/dev/null 2>&1
rm -rf /koolshare/${module}/data/version >/dev/null 2>&1
rm -rf /koolshare/${module}/data/rules/*.dat >/dev/null 2>&1
rm -rf /koolshare/${module}/data/rules/daily.txt >/dev/null 2>&1
rm -rf /koolshare/${module}/data/rules/${module}.txt >/dev/null 2>&1
# isntall file
echo_date "安装插件相关文件..."
cd /tmp
mkdir -p /koolshare/${module}
mkdir -p /koolshare/${module}/data
mkdir -p /koolshare/${module}/data/rules
cp -rf /tmp/${module}/res/* /koolshare/res/
cp -rf /tmp/${module}/scripts/* /koolshare/scripts/
cp -rf /tmp/${module}/webs/* /koolshare/webs/
cp -rf /tmp/${module}/uninstall.sh /koolshare/scripts/uninstall_${module}.sh
if [ ! -f "/koolshare/koolproxy/data/rules/user.txt" ];then
cp -rf /tmp/koolproxy/koolproxy /koolshare/
else
mv /koolshare/koolproxy/data/rules/user.txt /tmp/user.txt.tmp
cp -rf /tmp/koolproxy/koolproxy /koolshare/
mv /tmp/user.txt.tmp /koolshare/koolproxy/data/rules/user.txt
fi
mkdir -p /tmp/upload
touch /tmp/upload/kp_log.txt
# Permissions
chmod 755 /koolshare/${module}/koolproxy >/dev/null 2>&1
chmod 755 /koolshare/${module}/kp_config.sh >/dev/null 2>&1
chmod 755 /koolshare/${module}/data/* >/dev/null 2>&1
chmod 755 /koolshare/scripts/* >/dev/null 2>&1
# make start up script link
if [ ! -L "/koolshare/init.d/S98koolproxy.sh" -a "/koolshare/koolproxy/kp_config.sh" ];then
ln -sf /koolshare/koolproxy/kp_config.sh /koolshare/init.d/S98koolproxy.sh
fi
if [ ! -L "/koolshare/init.d/N98koolproxy.sh" -a "/koolshare/koolproxy/kp_config.sh" ];then
ln -sf /koolshare/koolproxy/kp_config.sh /koolshare/init.d/N98koolproxy.sh
fi
# intall different UI
install_ui
# dbus value
echo_date "设置插件默认参数..."
dbus set ${module}_version="${PLVER}"
dbus set softcenter_module_${module}_version="${PLVER}"
dbus set softcenter_module_${module}_install="1"
dbus set softcenter_module_${module}_name="${module}"
dbus set softcenter_module_${module}_title="${TITLE}"
dbus set softcenter_module_${module}_description="${DESCR}"
# defalut value
[ -z "$(dbus get koolproxy_mode)" ] && dbus set koolproxy_mode=1
[ -z "$(dbus get koolproxy_acl_default)" ] && dbus set koolproxy_acl_default=1
# re-enable
if [ "${ENABLE}" == "1" -a -f "/koolshare/koolproxy/kp_config.sh" ];then
echo_date "安装完毕,重新启用${TITLE}插件!"
sh /koolshare/koolproxy/kp_config.sh restart
fi
# finish
echo_date "${TITLE}插件安装完毕!"
exit_install
}
install(){
get_model
get_fw_type
platform_test
install_now
}
install