From bcea9aa2cb012ef93ade30da6723e77655daa78b Mon Sep 17 00:00:00 2001 From: tsosunchia <59512455+tsosunchia@users.noreply.github.com> Date: Mon, 23 May 2022 20:26:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E8=A3=85=E8=84=9A=E6=9C=AC=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0checkVersion=E4=B8=BA=E4=B9=8B=E5=90=8E=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=81=9A=E5=87=86=E5=A4=87=EF=BC=9B=E4=BC=98=E5=8C=96=E4=BA=86?= =?UTF-8?q?=E9=83=A8=E5=88=86=E9=80=BB=E8=BE=91=E7=BB=93=E6=9E=84=EF=BC=9B?= =?UTF-8?q?=E5=9C=A8=E9=83=A8=E5=88=86=E8=BD=AF=E4=BB=B6=E5=8C=85=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=99=A8=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E5=8C=85=E4=B9=8B=E5=89=8D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=BD=AF=E4=BB=B6=E6=BA=90=E7=9A=84=E6=AD=A5=E9=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nt_install.sh | 58 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/nt_install.sh b/nt_install.sh index 884fc11..425e212 100644 --- a/nt_install.sh +++ b/nt_install.sh @@ -52,64 +52,78 @@ installWgetPackage() { # macOS should install wget originally. Nothing to do echo "wget 正在安装中..." # try apt - apt -h >/dev/null + apt-get -h >/dev/null if [ $? -eq 0 ]; then # 先更新一下数据源,有些机器数据源比较老可能会404 - apt update -y >/dev/null - apt install wget -y >/dev/null + apt-get update -y >/dev/null + apt-get install wget -y >/dev/null fi # try yum yum -h >/dev/null if [ $? -eq 0 ]; then + yum -y update >/dev/null yum install wget -y >/dev/null fi # try dnf dnf -h >/dev/null if [ $? -eq 0 ]; then + dnf check-update >/dev/null dnf install wget -y >/dev/null fi # try pacman pacman -h >/dev/null if [ $? -eq 0 ]; then - pacman -Sy - pacman -S wget + pacman -Sy >/dev/null + pacman -S wget >/dev/null fi + wget -h >/dev/null + if [ $? -ne 0 ]; then + echo "wget 安装失败" + exit 1 + fi } installJqPackage() { # macOS should install wget originally. Nothing to do echo "jq 正在安装中..." # try apt - apt -h >/dev/null + apt-get -h >/dev/null if [ $? -eq 0 ]; then # 先更新一下数据源,有些机器数据源比较老可能会404 - apt update -y >/dev/null - apt install jq -y >/dev/null + apt-get update -y >/dev/null + apt-get install jq -y >/dev/null fi # try yum yum -h >/dev/null if [ $? -eq 0 ]; then + yum -y update >/dev/null yum install jq -y >/dev/null fi # try dnf dnf -h >/dev/null if [ $? -eq 0 ]; then + dnf check-update >/dev/null dnf install jq -y >/dev/null fi # try pacman pacman -h >/dev/null if [ $? -eq 0 ]; then - pacman -Sy - pacman -S jq + pacman -Sy >/dev/null + pacman -S jq >/dev/null fi + jq -h >/dev/null + if [ $? -ne 0 ]; then + echo "jq 安装失败" + exit 1 + fi } checkWgetPackage() { @@ -134,6 +148,29 @@ checkWgetPackage() { fi } +checkVersion() { + echo "正在检查版本..." + version=$(curl -sL https://api.github.com/repos/xgadget-lab/nexttrace/releases/latest | jq -r '.tag_name') + if [[ $version == "" ]]; then + echo "获取版本失败,请检查网络连接" + exit 1 + fi + echo 当前最新release版本:${version} + read -r -p "是否安装/更新软件? (y/n)" input + case $input in + [yY][eE][sS] | [yY]) + break + ;; + [nN][oO] | [nN]) + echo "您选择了取消安装/更新,脚本即将退出" + exit 1 + ;; + *) + break + ;; + esac +} + checkJqPackage() { jq -h >/dev/null if [ $? -ne 0 ]; then @@ -218,6 +255,7 @@ checkRootPermit checkSystemDistribution checkSystemArch checkWgetPackage +checkVersion # Download Procedure getLocation