forked from sbwml/luci-app-alist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
71 lines (64 loc) · 2.66 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
#!/bin/sh
RED_COLOR='\e[1;31m'
GREEN_COLOR='\e[1;32m'
RES='\e[0m'
# sysinfo
if [ -f /etc/openwrt_release ]; then
. /etc/openwrt_release
version=$(echo ${DISTRIB_RELEASE%%.*})
platform=$(echo $DISTRIB_ARCH)
ldd_version=$(ldd --version 2>&1 | grep Version | awk '{print $2}')
[ ${ldd_version%.*} = "1.2" ] && sdk=22.03 || sdk=21.02
else
echo -e "${RED_COLOR}Unknown OpenWRT Version${RES}"
exit 1
fi
# temp
temp_dir=$(mktemp -d) || exit 1
# github mirror
ip_info=$(curl -sk https://ip.cooluc.com)
country_code=$(echo $ip_info | sed -r 's/.*country_code":"([^"]*).*/\1/')
if [ $country_code = "CN" ]; then
google_status=$(curl -I -4 -m 3 -o /dev/null -s -w %{http_code} http://www.google.com/generate_204)
if [ ! $google_status = "204" ];then
mirror="https://github.cooluc.com/"
fi
fi
CHECK() (
echo -e "\n${GREEN_COLOR}Checking available space ...${RES}"
ROOT_SPACE=$(df -m /usr | awk 'END{print $4}')
if [ $ROOT_SPACE -lt 40 ]; then
echo -e "\n${RED_COLOR}Error, The system storage space is less than 40MB.${RES}"
exit 1;
fi
echo -e "\n${GREEN_COLOR}Checking platform ...${RES}\n"
prebuilt="aarch64_cortex-a53 aarch64_cortex-a72 aarch64_generic arm_arm1176jzf-s_vfp arm_arm926ej-s arm_cortex-a15_neon-vfpv4 arm_cortex-a5_vfpv4 arm_cortex-a7 arm_cortex-a7_neon-vfpv4 arm_cortex-a8_vfpv3 arm_cortex-a9 arm_cortex-a9_neon arm_cortex-a9_vfpv3-d16 arm_fa526 arm_mpcore arm_xscale i386_pentium-mmx i386_pentium4 mips64_octeonplus mips_24kc mips_4kec mips_mips32 mipsel_24kc mipsel_24kc_24kf mipsel_74kc mipsel_mips32 x86_64"
verif=$(expr match "$prebuilt" ".*\($platform\)")
if [[ ! $verif ]]; then
echo -e "${RED_COLOR}Error! The current \"$platform\" platform is not currently supported.${RES}"
exit 1;
else
echo -e "${GREEN_COLOR}Install luci-compat ...${RES}\n"
opkg update
opkg install luci-compat
fi
)
DOWNLOAD() (
echo -e "\n${GREEN_COLOR}Download "$mirror"https://github.com/sbwml/luci-app-alist/releases/latest/download/openwrt-$sdk-$platform.tar.gz ...${RES}\n"
curl --connect-timeout 30 -m 600 -kLo "$temp_dir/openwrt-$sdk-$platform.tar.gz" "$mirror"https://github.com/sbwml/luci-app-alist/releases/latest/download/openwrt-$sdk-$platform.tar.gz
if [ $? -ne 0 ]; then
echo -e "\n${RED_COLOR}Error! Download openwrt-$sdk-$platform.tar.gz failed.${RES}"
rm -rf $temp_dir
exit 1
fi
)
INSTALL() (
echo -e "\n${GREEN_COLOR}Install Packages ...${RES}\n"
tar -zxf $temp_dir/openwrt-$sdk-$platform.tar.gz -C $temp_dir/
opkg install $temp_dir/packages_ci/alist*.ipk
opkg install $temp_dir/packages_ci/luci-app-alist*.ipk
opkg install $temp_dir/packages_ci/luci-i18n*.ipk
rm -rf $temp_dir /tmp/luci-*
echo -e "\n${GREEN_COLOR}Done!${RES}\n"
)
CHECK && DOWNLOAD && INSTALL