-
Notifications
You must be signed in to change notification settings - Fork 10
/
install.sh
166 lines (134 loc) · 5.15 KB
/
install.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
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
#!/bin/sh
#----------------------------------------------------------------
# Shell Name:install
# Description:Plug-in install script
# Author:Starry
# E-mail: [email protected]
# Time:2016-11-06 02:30 CST
# Version: 1.6.11.07
# Copyright © 2016 Misstar Tools. All rights reserved.
#----------------------------------------------------------------*/
clear
echo ""
echo "---------------------------------------------------------------"
echo ' __ __ _ _______ _ '
echo ' | \/ (_) _ |__ __| | | '
echo ' | \ / |_ ___ ___| |_ __ _ _ __ | | ___ ___ | |___ '
echo ' | |\/| | / __/ __| __/ _` | `__| | |/ _ \ / _ \| / __| '
echo ' | | | | \__ \__ \ || (_| | | | | (_) | (_) | \__ \ '
echo ' |_| |_|_|___/___/\__\__,_|_| |_|\___/ \___/|_|___/ '
echo "---------------------------------------------------------------"
echo "欢迎使用小米路由Misstar Tools工具箱"
echo "当前版本:2.17.05.21"
echo "此版本为MT2.0终结版,由honglt分流"
echo "问题反馈&技术交流QQ:199789"
## Check The Router Hardware Model
model=$(cat /proc/xiaoqiang/model)
if [ "$model" == "R2D" -o "$model" == "R1D" -o "$model" == "R3D" -o "$model" == "R3P" -o "$model" == "R3" -o "$model" == "R1CM" -o "$model" == "R3G" ];then
echo "本工具箱作折腾、学习、研究之用,请勿用于非法用途,对路由器安全有高要求的请不要安装!"
else
echo "对不起,本工具箱暂时只支持小米R1D,R2D,R3,Mini路由器。"
exit
fi
echo -n "[按任意键继续,按Ctrl+C 退出安装]:"
read continue
mount -o remount,rw /
rm -rf /usr/share/datacenter/文件共享说明.jpg >/dev/null 2>&1
if [ "$model" == "R1D" -o "$model" == "R2D" -o "$model" == "R3D" ];then
MIWIFIPATH="/etc"
elif [ "$model" == "R3" -o "$model" == "R3P" -o "$model" == "R3G" ];then
if [ $(df|grep -Ec '\/extdisks\/sd[a-z][0-9]?$') -eq 0 ];
then
MIWIFIPATH="/etc"
else
echo "检测到外部存储,请选择安装位置:"
while :
do
echo "1,内置存储(推荐) 2,U盘/移动硬盘(如果内置存储满,请选择这个)"
read location
if [ "$location" == '1' ] ;then
MIWIFIPATH="/etc"
break
elif [ "$location" == '2' ] ; then
MIWIFIPATH=$(df|awk '/\/extdisks\/sd[a-z][0-9]?$/{print $6;exit}')
break
fi
done
fi
elif [ "$model" == "R1CM" ];then
if [ $(df|grep -Ec '\/extdisks\/sd[a-z][0-9]?$') -eq 0 ];then
echo "未找到外置存储设备,退出..."
return 1
else
MIWIFIPATH=$(df|awk '/\/extdisks\/sd[a-z][0-9]?$/{print $6;exit}')
fi
else
echo "暂不支持您的路由器。"
return 1
fi
rm -rf $MIWIFIPATH/misstar
mkdir $MIWIFIPATH/misstar
if [ "$MIWIFIPATH" != "/etc" ]; then
rm -rf /etc/misstar
ln -s $MIWIFIPATH/misstar /etc/
fi
echo "检查磁盘空间。.."
result=$(df -h | grep -E 'etc' | grep '100%' | wc -l)
if [ "$result" == '0' ];then
echo "完成"
else
df -h | grep -E 'etc'
echo "磁盘空间不足,请清理后安装。"
exit
fi
echo "开始下载安装包..."
url="https://raw.githubusercontent.com/honglt1/Misstar-Tools/master/appstore/$model"
curl -kL ${url}/misstar.mt -o /tmp/misstar.mt
if [ $? -eq 0 ];then
echo "安装包下载完成!"
else
echo "下载安装包失败,正在退出..."
exit
fi
mount -o remount,rw /
if [ $? -eq 0 ];then
echo "挂载文件系统成功。"
else
echo "挂载文件系统失败,正在退出..."
exit
fi
echo "开始解压安装包..."
tar -zxvf /tmp/misstar.mt -C / >/dev/null 2>&1
if [ $? -eq 0 ];then
echo "解压完成,开始安装:"
else
echo "解压失败,正在退出..."
exit
fi
chmod +x /etc/misstar/scripts/*
cp -rf /etc/misstar/config/misstar /etc/config/misstar
touch /etc/firewall.user
sed -i '/misstar/d' /etc/firewall.user
echo 'CHECKPATH="$(ls /extdisks/sd*/misstar/scripts/misstarini 2>/dev/null)" #misstar' >> /etc/firewall.user
echo 'if [ ! -f "$CHECKPATH" ];then #misstar' >> /etc/firewall.user
echo ' CHECKPATH="$(ls /userdisk/data/misstar/scripts/misstarini 2>/dev/null)" #misstar' >> /etc/firewall.user
echo 'fi #misstar' >> /etc/firewall.user
echo 'if [ ! -f "$CHECKPATH" ];then #misstar' >> /etc/firewall.user
echo ' CHECKPATH="$(ls /etc/misstar/scripts/misstarini 2>/dev/null)" #misstar' >> /etc/firewall.user
echo 'fi #misstar' >> /etc/firewall.user
echo 'if [ -f "$CHECKPATH" ]; then #misstar' >> /etc/firewall.user
echo ' $CHECKPATH #misstar' >> /etc/firewall.user
echo 'fi #misstar' >> /etc/firewall.user
/etc/misstar/scripts/misstarini
if [ $? -eq 0 ];then
snmd5=$(echo `nvram get wl1_maclist` `nvram get SN` | md5sum | awk '{print $1}')
counter=`curl "https://raw.githubusercontent.com/honglt1/Misstar-Tools/master/counter.php?sha1sum=$snmd5" -s | awk -F "\"" '{print $4}'`
uci set misstar.misstar.counter=$counter
uci commit misstar
echo -e "安装完成,请刷新网页。"
else
echo "安装失败。"
exit
fi
rm -rf /tmp/misstar.mt
rm -rf /tmp/install.sh