install.sh: support libc 32/64 time
This commit is contained in:
parent
72c5c0cce0
commit
a04eeea555
79
install.sh
79
install.sh
@ -3,20 +3,22 @@ RED_COLOR='\e[1;31m'
|
|||||||
GREEN_COLOR='\e[1;32m'
|
GREEN_COLOR='\e[1;32m'
|
||||||
RES='\e[0m'
|
RES='\e[0m'
|
||||||
|
|
||||||
# OpenWrt Info
|
# sysinfo
|
||||||
if [ -f /etc/openwrt_release ]; then
|
if [ -f /etc/openwrt_release ]; then
|
||||||
. /etc/openwrt_release
|
. /etc/openwrt_release
|
||||||
version=$(echo ${DISTRIB_RELEASE%%.*})
|
version=$(echo ${DISTRIB_RELEASE%%.*})
|
||||||
platform=$(echo $DISTRIB_ARCH)
|
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
|
else
|
||||||
echo -e "${RED_COLOR}Unknown OpenWRT Version${RES}"
|
echo -e "${RED_COLOR}Unknown OpenWRT Version${RES}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TMP
|
# temp
|
||||||
TMPDIR=$(mktemp -d) || exit 1
|
temp_dir=$(mktemp -d) || exit 1
|
||||||
|
|
||||||
# GitHub mirror
|
# github mirror
|
||||||
ip_info=$(curl -sk https://ip.cooluc.com)
|
ip_info=$(curl -sk https://ip.cooluc.com)
|
||||||
country_code=$(echo $ip_info | sed -r 's/.*country_code":"([^"]*).*/\1/')
|
country_code=$(echo $ip_info | sed -r 's/.*country_code":"([^"]*).*/\1/')
|
||||||
if [ $country_code = "CN" ]; then
|
if [ $country_code = "CN" ]; then
|
||||||
@ -26,81 +28,44 @@ if [ $country_code = "CN" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check
|
|
||||||
CHECK() (
|
CHECK() (
|
||||||
echo -e "\r\n${GREEN_COLOR}Checking available space ...${RES}"
|
echo -e "\n${GREEN_COLOR}Checking available space ...${RES}"
|
||||||
ROOT_SPACE=$(df -m /usr | awk 'END{print $4}')
|
ROOT_SPACE=$(df -m /usr | awk 'END{print $4}')
|
||||||
if [ $ROOT_SPACE -lt 40 ]; then
|
if [ $ROOT_SPACE -lt 40 ]; then
|
||||||
echo -e "\r\n${RED_COLOR}Error, The system storage space is less than 40MB.${RES}"
|
echo -e "\n${RED_COLOR}Error, The system storage space is less than 40MB.${RES}"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
echo -e "\r\n${GREEN_COLOR}Checking platform ...${RES}\r\n"
|
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"
|
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\)")
|
verif=$(expr match "$prebuilt" ".*\($platform\)")
|
||||||
if [[ ! $verif ]]; then
|
if [[ ! $verif ]]; then
|
||||||
echo -e "${RED_COLOR}Error! The current \"$platform\" platform is not currently supported.${RES}"
|
echo -e "${RED_COLOR}Error! The current \"$platform\" platform is not currently supported.${RES}"
|
||||||
exit 1;
|
exit 1;
|
||||||
else
|
else
|
||||||
echo -e "${GREEN_COLOR}Update opkg sources ...${RES}"
|
echo -e "${GREEN_COLOR}Install luci-compat ...${RES}\n"
|
||||||
opkg update
|
opkg update
|
||||||
opkg install luci-compat
|
opkg install luci-compat
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
|
||||||
DOWNLOAD() (
|
DOWNLOAD() (
|
||||||
echo -e "\r\n${GREEN_COLOR}Download Packages ...${RES}\r\n"
|
echo -e "\n${GREEN_COLOR}Download "$mirror"https://github.com/sbwml/luci-app-alist/releases/latest/download/openwrt-$sdk-$platform.tar.gz ...${RES}\n"
|
||||||
# get repos info
|
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
|
||||||
curl -sk --connect-timeout 10 "https://api.github.com/repos/sbwml/luci-app-alist/releases" | grep "browser_download_url" > $TMPDIR/releases.txt
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo -e "${RED_COLOR}Failed to get version information, Please check the network status.${RES}"
|
echo -e "\n${RED_COLOR}Error! Download openwrt-$sdk-$platform.tar.gz failed.${RES}"
|
||||||
rm -rf $TMPDIR
|
rm -rf $temp_dir
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
alist=$(cat $TMPDIR/releases.txt | grep "browser_download_url" | grep $platform.ipk | head -1 | awk '{print $2}' | sed 's/\"//g')
|
|
||||||
luci_app=$(cat $TMPDIR/releases.txt | grep "browser_download_url" | grep luci-app-alist_ | head -1 | awk '{print $2}' | sed 's/\"//g')
|
|
||||||
luci_i18n=$(cat $TMPDIR/releases.txt | grep "browser_download_url" | grep luci-i18n-alist-zh-cn | head -1 | awk '{print $2}' | sed 's/\"//g')
|
|
||||||
|
|
||||||
# download
|
|
||||||
echo -e "${GREEN_COLOR}Downloading $alist ...${RES}"
|
|
||||||
curl --connect-timeout 30 -m 600 -kLo "$TMPDIR/alist_$platform.ipk" $mirror$alist
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "\r\n${RED_COLOR}Error! Download $alist failed.${RES}"
|
|
||||||
rm -rf $TMPDIR
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo -e "${GREEN_COLOR}Downloading $luci_app ...${RES}"
|
|
||||||
curl --connect-timeout 30 -m 600 -kLo "$TMPDIR/luci-app-alist.ipk" $mirror$luci_app
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "\r\n${RED_COLOR}Error! Download $luci_app failed.${RES}"
|
|
||||||
rm -rf $TMPDIR
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo -e "${GREEN_COLOR}Downloading $luci_i18n ...${RES}"
|
|
||||||
curl --connect-timeout 30 -m 600 -kLo "$TMPDIR/luci-i18n-alist-zh-cn.ipk" $mirror$luci_i18n
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "\r\n${RED_COLOR}Error! Download $luci_i18n failed.${RES}"
|
|
||||||
rm -rf $TMPDIR
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
|
||||||
INSTALL() (
|
INSTALL() (
|
||||||
# Install
|
echo -e "\n${GREEN_COLOR}Install Packages ...${RES}\n"
|
||||||
echo -e "\r\n${GREEN_COLOR}Install Packages ...${RES}\r\n"
|
tar -zxf $temp_dir/openwrt-$sdk-$platform.tar.gz -C $temp_dir/
|
||||||
opkg install $TMPDIR/alist_$platform.ipk
|
opkg install $temp_dir/packages_ci/alist*.ipk
|
||||||
opkg install $TMPDIR/luci-app-alist.ipk
|
opkg install $temp_dir/packages_ci/luci-app-alist*.ipk
|
||||||
opkg install $TMPDIR/luci-i18n-alist-zh-cn.ipk
|
opkg install $temp_dir/packages_ci/luci-i18n*.ipk
|
||||||
rm -rf $TMPDIR /tmp/luci-*
|
rm -rf $temp_dir /tmp/luci-*
|
||||||
echo -e "${GREEN_COLOR}Done!${RES}"
|
echo -e "\n${GREEN_COLOR}Done!${RES}\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
CHECK
|
CHECK && DOWNLOAD && INSTALL
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
DOWNLOAD
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
INSTALL
|
|
||||||
fi
|
|
||||||
|
Loading…
Reference in New Issue
Block a user