From 1ed19e66ae67409628cf4c60298fa19c586c9b99 Mon Sep 17 00:00:00 2001 From: lsy Date: Tue, 24 Sep 2024 01:48:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=89=E8=A3=85=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Menus/Install.sh | 50 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/Menus/Install.sh b/Menus/Install.sh index 1d9909f..c1435f0 100644 --- a/Menus/Install.sh +++ b/Menus/Install.sh @@ -1,23 +1,63 @@ #!/bin/bash + +if ! command -v git &> /dev/null; then + if [[ -f "/usr/bin/apt-get" ]];then + apt-get update -y + apt-get install git + elif [[ -f "/usr/bin/apt" ]];then + apt update -y + apt install git + elif [[ -f "/usr/bin/pacman" ]];then + pacman -Syu --noconfirm + pacman -Sy --noconfirm git + else + echo "git未安装" + exit + fi +fi + + declare path echo "请输入脚本的安装位置" read -p "默认 /var/script:" path if [[ -z $path ]];then path="/var/script" fi -echo "软件正在安装中" mkdir -p "$path" rm -rf "$path/linuxtool" -wget https://g.lsy22.com/lsy/linuxtool/archive/master.tar.gz -O "${path}/aa" &> /dev/null +declare -A url_dick +declare -a url_arr +declare url_number=0 +declare url_pick +declare url +echo "请选择脚本的下载地址" +url_dick['github(default)']='https://github.com/lsy2246/linuxtool.git' +url_dick['gitee']='https://gitee.com/lsy22/linuxtool.git' +url_dick['gitlsy']='https://g.lsy22.com/lsy/linuxtool.git' -if [[ -d "${path}/aa" ]];then +for i in "${!url_dick[@]}" ; do + url_number=$(( url_number+1 )) + url_arr[$url_number]=$i + echo "${url_number}.${i}" +done + +read -p "请输入:" url_pick + +if [[ $url_pick =~ [1-${#url_dick[@]}] ]]; then + url=${url_dick[${url_arr[$url_pick]}]} +else + url='https://github.com/lsy2246/linuxtool.git' +fi + +git clone "$url" "$path/linuxtool" &> /dev/null + +if [[ -d "${path}/linuxtool" ]];then echo "脚本下载失败" exit fi -tar -zxf "$path/aa" -C $path &> /dev/null -rm "$path/aa" + chmod +x "$path/linuxtool/Run.sh" &> /dev/null if [[ -e "${HOME}/.bashrc" ]];then