将脚本执行都换成绝对路径

This commit is contained in:
lsy 2024-09-21 16:25:44 +08:00
parent f7c057fb78
commit e563b33517
3 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
declare path_script=$1
declare pick declare pick
echo "========Automation========" echo "========Automation========"
echo "1.自动备份" echo "1.自动备份"
@ -48,10 +49,10 @@ fi
case $pick in case $pick in
'1') '1')
bash "${PWD}/Config/Automation/backup.sh" "$path" "$cron" bash "${path_script}/Config/Automation/backup.sh" "$path" "$cron"
;; ;;
'2') '2')
bash "${PWD}/Config/Automation/update.sh" "$path" "$cron" bash "${path_script}/Config/Automation/update.sh" "$path" "$cron"
;; ;;
'3') '3')
if ! command -v docker &> /dev/null; then if ! command -v docker &> /dev/null; then

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
declare path_script=$1
if ! command -v docker &> /dev/null; then if ! command -v docker &> /dev/null; then
echo "docker未安装" echo "docker未安装"
exit exit
@ -91,7 +93,7 @@ elif [[ "${pick}" -gt "$((${pick_number}-${#pick_array[*]}))" && "${pick}" -le "
exit exit
fi 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}" echo "${pick_array[${pick}]}安装完成,访问端口${port}"
fi fi

5
Run.sh
View File

@ -8,13 +8,14 @@ fi
declare -a pick_array declare -a pick_array
declare pick_number declare pick_number
declare pick declare pick
declare path_script=$(dirname $0)
while true while true
do do
pick_number=0 pick_number=0
echo "======Linux工具箱======" echo "======Linux工具箱======"
for i in "${PWD}/Menus/"* for i in "${path_script}/Menus"/*
do do
pick_number=$((pick_number + 1)) pick_number=$((pick_number + 1))
pick_array[$pick_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)") pick_array[$pick_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
@ -24,7 +25,7 @@ echo "======Linux工具箱======"
read -p "请输入要使用的功能:" pick read -p "请输入要使用的功能:" pick
if [[ "${pick}" -gt 0 && "${pick}" -le "${#pick_array[*]}" ]];then if [[ "${pick}" -gt 0 && "${pick}" -le "${#pick_array[*]}" ]];then
clear clear
bash "${PWD}/Menus/${pick_array[$pick]}.sh" bash "${path_script}/Menus/${pick_array[$pick]}.sh ${path_script}"
else else
exit exit
fi fi