From 79a3b35ce75e4269255892b6f43c83e1fedabb58 Mon Sep 17 00:00:00 2001 From: lsy Date: Sat, 21 Sep 2024 14:17:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AF=E4=BB=B6=E5=AE=89=E8=A3=85=E5=8C=85?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=99=A8=E6=9B=B4=E6=94=B9,=E6=89=80?= =?UTF-8?q?=E6=9C=89=E5=AE=89=E8=A3=85=E5=8A=A0y,=E6=94=B9=E7=BB=9D?= =?UTF-8?q?=E5=AF=B9=E8=B7=AF=E5=BE=84,=E7=BE=8E=E5=8C=96=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E4=B8=8D=E5=AE=8C=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/Automation/update.sh | 8 ++++---- Menus/Automation.sh | 4 ++-- Menus/Docker.sh | 2 +- Menus/Other.sh | 8 ++++---- Menus/Software.sh | 23 +++++++++++++---------- Menus/Sources.sh | 4 ++-- Run.sh | 4 ++-- 7 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Config/Automation/update.sh b/Config/Automation/update.sh index 4391ce2..51aeaa1 100644 --- a/Config/Automation/update.sh +++ b/Config/Automation/update.sh @@ -8,11 +8,11 @@ fi echo '#!/bin/bash' > "${path}/update.sh" if [[ -f "/usr/bin/apt" ]];then - echo 'sudo apt update' >> "${path}/update.sh" - echo 'sudo apt-get dist-upgrade' >> "${path}/update.sh" + echo 'sudo apt update -y' >> "${path}/update.sh" + echo 'sudo apt-get dist-upgrad -y' >> "${path}/update.sh" elif [[ -f "/usr/bin/apt-get" ]];then - echo 'sudo apt-get update' >> "${path}/update.sh" - echo 'sudo apt dist-upgrade' >> "${path}/update.sh" + echo 'sudo apt-get update -y' >> "${path}/update.sh" + echo 'sudo apt dist-upgrade -y' >> "${path}/update.sh" else rm "${path}/update.sh" echo "暂不支持该系统配置自动更新软件" diff --git a/Menus/Automation.sh b/Menus/Automation.sh index bedc22b..92cd51f 100644 --- a/Menus/Automation.sh +++ b/Menus/Automation.sh @@ -48,10 +48,10 @@ fi case $pick in '1') - bash Config/Automation/backup.sh "$path" "$cron" + bash "${PWD}/Config/Automation/backup.sh" "$path" "$cron" ;; '2') - bash Config/Automation/update.sh "$path" "$cron" + bash "${PWD}/Config/Automation/update.sh" "$path" "$cron" ;; '3') if ! command -v docker &> /dev/null; then diff --git a/Menus/Docker.sh b/Menus/Docker.sh index c7baafc..037820e 100644 --- a/Menus/Docker.sh +++ b/Menus/Docker.sh @@ -91,7 +91,7 @@ elif [[ "${pick}" -gt "$((${pick_number}-${#pick_array[*]}))" && "${pick}" -le " exit fi - bash Config/Docker/${pick_array[${pick}]}.sh "$file_path" "$port" + bash "${PWD}/Config/Docker/${pick_array[${pick}]}.sh" "$file_path" "$port" echo "${pick_array[${pick}]}安装完成,访问端口${port}" fi diff --git a/Menus/Other.sh b/Menus/Other.sh index 3235efe..cfc168c 100644 --- a/Menus/Other.sh +++ b/Menus/Other.sh @@ -24,13 +24,13 @@ case "$pick" in echo "2.英文" read -p "请输入:" lang if [[ -f "/usr/bin/apt-get" ]];then - sudo apt-get update - sudo apt-get dist-upgrade + sudo apt-get update -y + sudo apt-get dist-upgrade -y sudo apt-get install -y locales sudo apt-get install -y language-pack-zh-hans elif [[ -f "/usr/bin/apt" ]];then - sudo apt update - sudo apt dist-upgrade + sudo apt update -y + sudo apt dist-upgrade -y sudo apt install -y locales sudo apt install -y language-pack-zh-hans else diff --git a/Menus/Software.sh b/Menus/Software.sh index e12ed96..5ed510b 100644 --- a/Menus/Software.sh +++ b/Menus/Software.sh @@ -5,13 +5,13 @@ declare version="$(cat /etc/os-release | grep "^ID" | awk -F '=' '{print $2}')" declare pkg if [[ -f "/usr/bin/apt-get" ]];then - pkg='apt-get' - sudo apt-get update - sudo apt-get dist-upgrade + pkg='apt-get install -y' + sudo apt-get update -y + sudo apt-get dist-upgrade -y elif [[ -f "/usr/bin/apt" ]];then - pkg='apt' - sudo apt update - sudo apt dist-upgrade + pkg='apt install -y' + sudo apt update -y + sudo apt dist-upgrade -y else echo "暂不支持该系统一键安装常用软件" exit @@ -81,13 +81,13 @@ if [[ ! $pick_x =~ [Nn] ]];then fi -eval "sudo ${pkg} install -y ${install_str}" +eval "sudo ${pkg} ${install_str}" if [[ ! $pick_x =~ [Nn] ]];then eval "$(curl https://get.x-cmd.com)" fi if [[ ! $pick_docker =~ [Nn] ]];then - if [[ ${pkg} == 'apt' || ${pkg} == 'apt-get' ]];then + if [[ ${pkg} =~ '^apt' || ${pkg} =~ '^apt-get' ]];then sudo ${pkg} update sudo ${pkg} install ca-certificates curl -y sudo install -m 0755 -d /etc/apt/keyrings @@ -104,13 +104,16 @@ fi if [[ ! $pick_zsh =~ [Nn] ]];then - sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" - zsh + curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh + while [[ ! -d "$HOME/.oh-my-zsh" ]]; do + sleep 3 + done git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions sudo sed -i 's/^#\?ZSH_THEME.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/g' ~/.zshrc sudo sed -i 's/^#\?plugins.*/plugins=(zsh-syntax-highlighting zsh-autosuggestions command-not-found)/g' ~/.zshrc + source ~/.zshrc fi diff --git a/Menus/Sources.sh b/Menus/Sources.sh index c523566..3fb9da0 100644 --- a/Menus/Sources.sh +++ b/Menus/Sources.sh @@ -48,8 +48,8 @@ deb ${url}/debian/ bookworm main contrib non-free non-free-firmware deb ${url}/debian/ bookworm-updates main contrib non-free non-free-firmware deb ${url}/debian/ bookworm-backports main contrib non-free non-free-firmware EOF - sudo apt update - sudo apt-get update + sudo apt update -y + sudo apt-get update -y ;; *) echo "暂不支持该系统配置自动更新软件" diff --git a/Run.sh b/Run.sh index ed5825d..7e2852e 100644 --- a/Run.sh +++ b/Run.sh @@ -14,7 +14,7 @@ do pick_number=0 echo "======Linux工具箱======" -cd Menus +cd Menus || exit for i in * do pick_number=$((pick_number + 1)) @@ -26,7 +26,7 @@ echo "======Linux工具箱======" read -p "请输入要使用的功能:" pick if [[ "${pick}" -gt 0 && "${pick}" -le "${#pick_array[*]}" ]];then clear - bash Menus/${pick_array[$pick]}.sh + bash "${PWD}/Menus/${pick_array[$pick]}.sh" else exit fi