diff --git a/Menus/Automation.sh b/Menus/Automation.sh index 92cd51f..41ac7a6 100644 --- a/Menus/Automation.sh +++ b/Menus/Automation.sh @@ -1,5 +1,6 @@ #!/bin/bash +declare path_script=$1 declare pick echo "========Automation========" echo "1.自动备份" @@ -48,10 +49,10 @@ fi case $pick in '1') - bash "${PWD}/Config/Automation/backup.sh" "$path" "$cron" + bash "${path_script}/Config/Automation/backup.sh" "$path" "$cron" ;; '2') - bash "${PWD}/Config/Automation/update.sh" "$path" "$cron" + bash "${path_script}/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 037820e..cf29390 100644 --- a/Menus/Docker.sh +++ b/Menus/Docker.sh @@ -1,5 +1,7 @@ #!/bin/bash +declare path_script=$1 + if ! command -v docker &> /dev/null; then echo "docker未安装" exit @@ -91,7 +93,7 @@ elif [[ "${pick}" -gt "$((${pick_number}-${#pick_array[*]}))" && "${pick}" -le " exit fi - bash "${PWD}/Config/Docker/${pick_array[${pick}]}.sh" "$file_path" "$port" + bash "${path_script}/Config/Docker/${pick_array[${pick}]}.sh" "$file_path" "$port" echo "${pick_array[${pick}]}安装完成,访问端口${port}" fi diff --git a/Run.sh b/Run.sh index 978acf8..e90cfec 100644 --- a/Run.sh +++ b/Run.sh @@ -8,13 +8,14 @@ fi declare -a pick_array declare pick_number declare pick +declare path_script=$(dirname $0) while true do pick_number=0 echo "======Linux工具箱======" -for i in "${PWD}/Menus/"* +for i in "${path_script}/Menus"/* do pick_number=$((pick_number + 1)) pick_array[$pick_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)") @@ -24,7 +25,7 @@ echo "======Linux工具箱======" read -p "请输入要使用的功能:" pick if [[ "${pick}" -gt 0 && "${pick}" -le "${#pick_array[*]}" ]];then clear - bash "${PWD}/Menus/${pick_array[$pick]}.sh" + bash "${path_script}/Menus/${pick_array[$pick]}.sh ${path_script}" else exit fi