-
Notifications
You must be signed in to change notification settings - Fork 356
/
downloads.sh
318 lines (280 loc) · 13.9 KB
/
downloads.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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
download(){
local filename=$(basename $1)
if [ -e ${1} ]; then
echo "${filename} [已存在.]"
else
echo "${filename} 当前目录中不存在, 现在开始下载."
wget --no-check-certificate -c -t3 -T60 -O ${1} ${2}
if [ $? -ne 0 ]; then
_echo -e "下载 ${filename} 失败."
exit 1
fi
fi
}
download_service_file(){
local filePath=$1
local onlineServiceFileUrl=$2
local localServiceFilePath=$3
if [[ ${methods} == "Online" ]]; then
download ${filePath} ${onlineServiceFileUrl}
else
cp -rf ${localServiceFilePath} ${filePath}
fi
}
get_version_by_github_api(){
local owner=$1
local repositoryName=$2
local apiUrl allVersion latestVersion
apiUrl="https://api.github.com/repos/${owner}/${repositoryName}/releases"
allVersion=$(wget --no-check-certificate -qO- ${apiUrl} | grep -o '"tag_name": ".*"')
if [ "${repositoryName}" = "shadowsocks-rust" ]; then
allVersion=$(echo "${allVersion}" | grep -v "alpha")
fi
latestVersion=$(echo "${allVersion}" | head -n 1 | sed 's/"//g;s/v//g' | sed 's/tag_name: //g')
echo ${latestVersion}
}
get_ss_version(){
local ssName=$1
get_version_by_github_api "shadowsocks" "${ssName}"
}
get_plugins_version(){
local pluginName=$1
if [ ${pluginName} = "v2ray-plugin" ]; then
get_version_by_github_api "teddysun" "${pluginName}"
elif [ ${pluginName} = "kcptun" ]; then
get_version_by_github_api "xtaci" "${pluginName}"
elif [ ${pluginName} = "simple-obfs" ]; then
get_version_by_github_api "shadowsocks" "${pluginName}"
elif [ ${pluginName} = "GoQuiet" ]; then
get_version_by_github_api "cbeuw" "${pluginName}"
elif [ ${pluginName} = "Cloak" ]; then
get_version_by_github_api "cbeuw" "${pluginName}"
elif [ ${pluginName} = "mos-tls-tunnel" ]; then
get_version_by_github_api "IrineSistiana" "${pluginName}"
elif [ ${pluginName} = "rabbit-tcp" ]; then
get_version_by_github_api "ihciah" "${pluginName}"
elif [ ${pluginName} = "simple-tls" ]; then
get_version_by_github_api "IrineSistiana" "${pluginName}"
elif [ ${pluginName} = "gost-plugin" ]; then
get_version_by_github_api "maskedeken" "${pluginName}"
elif [ ${pluginName} = "xray-plugin" ]; then
get_version_by_github_api "teddysun" "${pluginName}"
elif [ ${pluginName} = "qtun" ]; then
get_version_by_github_api "shadowsocks" "${pluginName}"
elif [ ${pluginName} = "gun" ]; then
get_version_by_github_api "Qv2ray" "${pluginName}"
fi
}
judge_latest_version_num_is_none_and_output_error_info(){
local appName=$1
local latestVersion=$2
[ -z ${latestVersion} ] && _echo -e "获取${appName}最新版本号失败,退出运行." && exit 1
}
download_ss_file(){
cd ${CUR_DIR}
if [[ ${SS_VERSION} = "ss-libev" ]]; then
local ssName="shadowsocks-libev"
libev_ver=$(get_ss_version "${ssName}")
judge_latest_version_num_is_none_and_output_error_info "${ssName}" "${libev_ver}"
shadowsocks_libev_file="shadowsocks-libev-${libev_ver}"
shadowsocks_libev_url="https://github.com/shadowsocks/shadowsocks-libev/releases/download/v${libev_ver}/shadowsocks-libev-${libev_ver}.tar.gz"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${shadowsocks_libev_file}.tar.gz" "${shadowsocks_libev_url}"
popd > /dev/null 2>&1
download_service_file ${SHADOWSOCKS_LIBEV_INIT} ${SHADOWSOCKS_LIBEV_INIT_ONLINE} ${SHADOWSOCKS_LIBEV_INIT_LOCAL}
elif [[ ${SS_VERSION} = "ss-rust" ]]; then
local ssName="shadowsocks-rust"
rust_ver=$(get_ss_version "${ssName}")
judge_latest_version_num_is_none_and_output_error_info "${ssName}" "${rust_ver}"
if [[ ${ARCH} = "amd64" ]]; then
local MACHINE="x86_64"
else
local MACHINE="aarch64"
fi
shadowsocks_rust_file="shadowsocks-v${rust_ver}.${MACHINE}-unknown-linux-musl"
shadowsocks_rust_url="https://github.com/shadowsocks/shadowsocks-rust/releases/download/v${rust_ver}/shadowsocks-v${rust_ver}.${MACHINE}-unknown-linux-musl.tar.xz"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${shadowsocks_rust_file}.tar.xz" "${shadowsocks_rust_url}"
popd > /dev/null 2>&1
download_service_file ${SHADOWSOCKS_RUST_INIT} ${SHADOWSOCKS_RUST_INIT_ONLINE} ${SHADOWSOCKS_RUST_INIT_LOCAL}
elif [[ ${SS_VERSION} = "go-ss2" ]]; then
if [[ ${ARCH} != "amd64" ]]; then
echo "[${Red}Error${suffix}] The architecture is not supported."
exit 1
fi
local ssName="go-shadowsocks2"
go_ver=$(get_ss_version "${ssName}")
judge_latest_version_num_is_none_and_output_error_info "${ssName}" "${go_ver}"
# wriet version num
if [ ! -d "$(dirname ${GO_SHADOWSOCKS2_VERSION_FILE})" ]; then
mkdir -p $(dirname ${GO_SHADOWSOCKS2_VERSION_FILE})
fi
echo ${go_ver} > ${GO_SHADOWSOCKS2_VERSION_FILE}
go_shadowsocks2_file="shadowsocks2-linux"
go_shadowsocks2_url="https://github.com/shadowsocks/go-shadowsocks2/releases/download/v${go_ver}/shadowsocks2-linux.gz"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${go_shadowsocks2_file}.gz" "${go_shadowsocks2_url}"
popd > /dev/null 2>&1
download_service_file ${GO_SHADOWSOCKS2_INIT} ${GO_SHADOWSOCKS2_INIT_ONLINE} ${GO_SHADOWSOCKS2_INIT_LOCAL}
fi
}
download_plugins_file(){
cd ${CUR_DIR}
if [[ "${plugin_num}" == "1" ]]; then
local pluginName="v2ray-plugin"
v2ray_plugin_ver=$(get_plugins_version "${pluginName}")
judge_latest_version_num_is_none_and_output_error_info "${pluginName}" "${v2ray_plugin_ver}"
v2ray_plugin_file="v2ray-plugin-linux-${ARCH}-v${v2ray_plugin_ver}"
v2ray_plugin_url="https://github.com/teddysun/v2ray-plugin/releases/download/v${v2ray_plugin_ver}/v2ray-plugin-linux-${ARCH}-v${v2ray_plugin_ver}.tar.gz"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${v2ray_plugin_file}.tar.gz" "${v2ray_plugin_url}"
popd > /dev/null 2>&1
elif [[ "${plugin_num}" == "2" ]]; then
local pluginName="kcptun"
kcptun_ver=$(get_plugins_version "${pluginName}")
judge_latest_version_num_is_none_and_output_error_info "${pluginName}" "${kcptun_ver}"
kcptun_file="kcptun-linux-${ARCH}-${kcptun_ver}"
kcptun_url="https://github.com/xtaci/kcptun/releases/download/v${kcptun_ver}/kcptun-linux-${ARCH}-${kcptun_ver}.tar.gz"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${kcptun_file}.tar.gz" "${kcptun_url}"
popd > /dev/null 2>&1
download_service_file ${KCPTUN_INIT} ${KCPTUN_INIT_ONLINE} ${KCPTUN_INIT_LOCAL}
elif [[ "${plugin_num}" == "4" ]]; then
local pluginName="GoQuiet"
goquiet_ver=$(get_plugins_version "${pluginName}")
judge_latest_version_num_is_none_and_output_error_info "${pluginName}" "${goquiet_ver}"
goquiet_file="gq-server-linux-${ARCH}-${goquiet_ver}"
goquiet_url="https://github.com/cbeuw/GoQuiet/releases/download/v${goquiet_ver}/gq-server-linux-${ARCH}-${goquiet_ver}"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${goquiet_file}" "${goquiet_url}"
popd > /dev/null 2>&1
elif [[ "${plugin_num}" == "5" ]]; then
local pluginName="Cloak"
cloak_ver=$(get_plugins_version "${pluginName}")
judge_latest_version_num_is_none_and_output_error_info "${pluginName}" "${cloak_ver}"
# cloak_ver="2.1.1"
cloak_file="ck-server-linux-${ARCH}-v${cloak_ver}"
cloak_url="https://github.com/cbeuw/Cloak/releases/download/v${cloak_ver}/ck-server-linux-${ARCH}-v${cloak_ver}"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${cloak_file}" "${cloak_url}"
popd > /dev/null 2>&1
download_service_file ${CLOAK_INIT} ${CLOAK_INIT_ONLINE} ${CLOAK_INIT_LOCAL}
elif [[ "${plugin_num}" == "6" ]]; then
if [[ ${ARCH} != "amd64" ]]; then
echo "[${Red}Error${suffix}] The architecture is not supported."
exit 1
fi
local pluginName="mos-tls-tunnel"
mtt_ver=$(get_plugins_version "${pluginName}")
judge_latest_version_num_is_none_and_output_error_info "${pluginName}" "${mtt_ver}"
# wriet version num
if [ ! -d "$(dirname ${SHADOWSOCKS_CONFIG})" ]; then
mkdir -p $(dirname ${SHADOWSOCKS_CONFIG})
fi
echo ${mtt_ver} > ${MTT_VERSION_FILE}
mtt_file="mos-tls-tunnel-linux-amd64"
mtt_url="https://github.com/IrineSistiana/mos-tls-tunnel/releases/download/v${mtt_ver}/mos-tls-tunnel-linux-amd64.zip"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${mtt_file}.zip" "${mtt_url}"
popd > /dev/null 2>&1
elif [[ "${plugin_num}" == "7" ]]; then
local pluginName="rabbit-tcp"
rabbit_ver=$(get_plugins_version "${pluginName}")
judge_latest_version_num_is_none_and_output_error_info "${pluginName}" "${rabbit_ver}"
# wriet version num
if [ ! -d "$(dirname ${RABBIT_VERSION_FILE})" ]; then
mkdir -p $(dirname ${RABBIT_VERSION_FILE})
fi
echo ${rabbit_ver} > ${RABBIT_VERSION_FILE}
rabbit_file="rabbit-linux-${ARCH}"
rabbit_url="https://github.com/ihciah/rabbit-tcp/releases/download/v${rabbit_ver}/rabbit-linux-${ARCH}.gz"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${rabbit_file}.gz" "${rabbit_url}"
popd > /dev/null 2>&1
download_service_file ${RABBIT_INIT} ${RABBIT_INIT_ONLINE} ${RABBIT_INIT_LOCAL}
elif [[ "${plugin_num}" == "8" ]]; then
local pluginName="simple-tls"
simple_tls_ver=$(get_plugins_version "${pluginName}")
# simple_tls_ver="0.5.2"
judge_latest_version_num_is_none_and_output_error_info "${pluginName}" "${simple_tls_ver}"
if [[ ${SimpleTlsVer} = "1" ]]; then
simple_tls_ver="0.3.4"
elif [[ ${SimpleTlsVer} = "2" ]]; then
simple_tls_ver="0.4.7"
elif [[ ${SimpleTlsVer} = "3" ]]; then
simple_tls_ver="0.7.0"
fi
# wriet version num
if [ ! -d "$(dirname ${SIMPLE_TLS_VERSION_FILE})" ]; then
mkdir -p $(dirname ${SIMPLE_TLS_VERSION_FILE})
fi
echo ${simple_tls_ver} > ${SIMPLE_TLS_VERSION_FILE}
simple_tls_file="simple-tls-linux-${ARCH}"
simple_tls_url="https://github.com/IrineSistiana/simple-tls/releases/download/v${simple_tls_ver}/simple-tls-linux-${ARCH}.zip"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${simple_tls_file}.zip" "${simple_tls_url}"
popd > /dev/null 2>&1
elif [[ "${plugin_num}" == "9" ]]; then
local pluginName="gost-plugin"
# gost_plugin_ver=$(get_plugins_version "${pluginName}")
gost_plugin_ver="1.6.1"
judge_latest_version_num_is_none_and_output_error_info "${pluginName}" "${gost_plugin_ver}"
# wriet version num
if [ ! -d "$(dirname ${GOST_PLUGIN_VERSION_FILE})" ]; then
mkdir -p $(dirname ${GOST_PLUGIN_VERSION_FILE})
fi
echo ${gost_plugin_ver} > ${GOST_PLUGIN_VERSION_FILE}
gost_plugin_file="gost-plugin_linux_${ARCH}-${gost_plugin_ver}"
gost_plugin_url="https://github.com/maskedeken/gost-plugin/releases/download/v${gost_plugin_ver}/${gost_plugin_file}.zip"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${gost_plugin_file}.zip" "${gost_plugin_url}"
popd > /dev/null 2>&1
elif [[ "${plugin_num}" == "10" ]]; then
local pluginName="xray-plugin"
xray_plugin_ver=$(get_plugins_version "${pluginName}")
judge_latest_version_num_is_none_and_output_error_info "${pluginName}" "${xray_plugin_ver}"
# wriet version num
if [ ! -d "$(dirname ${XRAY_PLUGIN_VERSION_FILE})" ]; then
mkdir -p $(dirname ${XRAY_PLUGIN_VERSION_FILE})
fi
echo ${xray_plugin_ver} > ${XRAY_PLUGIN_VERSION_FILE}
xray_plugin_file="xray-plugin-linux-${ARCH}-v${xray_plugin_ver}"
xray_plugin_url="https://github.com/teddysun/xray-plugin/releases/download/v${xray_plugin_ver}/xray-plugin-linux-${ARCH}-v${xray_plugin_ver}.tar.gz"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${xray_plugin_file}.tar.gz" "${xray_plugin_url}"
popd > /dev/null 2>&1
elif [[ "${plugin_num}" == "11" ]]; then
local pluginName="qtun"
qtun_ver=$(get_plugins_version "${pluginName}")
judge_latest_version_num_is_none_and_output_error_info "${pluginName}" "${qtun_ver}"
# wriet version num
if [ ! -d "$(dirname ${QTUN_VERSION_FILE})" ]; then
mkdir -p $(dirname ${QTUN_VERSION_FILE})
fi
echo ${qtun_ver} > ${QTUN_VERSION_FILE}
if [[ ${ARCH} = "amd64" ]]; then
local MACHINE="x86_64"
else
local MACHINE="aarch64"
fi
qtun_file="qtun-v${qtun_ver}.${MACHINE}-unknown-linux-musl"
qtun_url="https://github.com/shadowsocks/qtun/releases/download/v${qtun_ver}/qtun-v${qtun_ver}.${MACHINE}-unknown-linux-musl.tar.xz"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${qtun_file}.tar.xz" "${qtun_url}"
popd > /dev/null 2>&1
elif [[ "${plugin_num}" == "12" ]]; then
local pluginName="gun"
gun_ver=$(get_plugins_version "${pluginName}")
judge_latest_version_num_is_none_and_output_error_info "${pluginName}" "${gun_ver}"
# wriet version num
if [ ! -d "$(dirname ${GUN_VERSION_FILE})" ]; then
mkdir -p $(dirname ${GUN_VERSION_FILE})
fi
echo ${gun_ver} > ${GUN_VERSION_FILE}
gun_file="gun-sip003-linux-${ARCH}"
gun_url="https://github.com/Qv2ray/gun/releases/download/${gun_ver}/gun-sip003-linux-${ARCH}"
pushd ${TEMP_DIR_PATH} > /dev/null 2>&1
download "${gun_file}" "${gun_url}"
popd > /dev/null 2>&1
fi
}