修复菜单脚本文件数量过多判断问题,gitea脚本执行顺序问题,去掉sudo检查

This commit is contained in:
lsy 2025-05-19 01:41:13 +08:00
parent a29c459709
commit 601b8ea2fb
8 changed files with 50 additions and 50 deletions

View File

@ -1,18 +1,16 @@
#!/bin/bash
if ! command -v sudo &> /dev/null; then
echo "该软件需要安装sudo才能正常安装"
exit
fi
declare install_path=$1
declare service_port=$2
sudo useradd -m git
sudo -u git ssh-keygen -t rsa -b 4096 -C "Gitea Host Key" -f /home/git/.ssh/id_rsa -N ""
sudo -u git sh -c 'cat /home/git/.ssh/id_rsa.pub >> /home/git/.ssh/authorized_keys'
sudo -u git sh -c 'chmod a+x /usr/local/bin/gitea'
sudo -u git sh -c 'echo "ssh -p '$(( service_port+22 ))' -o StrictHostKeyChecking=no git@127.0.0.1 \"SSH_ORIGINAL_COMMAND=\\\"\$SSH_ORIGINAL_COMMAND\\\" \$0 \$@\"" > /usr/local/bin/gitea'
useradd -m git
su - git -c "ssh-keygen -t rsa -b 4096 -C \"Gitea Host Key\" -f /home/git/.ssh/id_rsa -N \"\""
su - git -c "cat /home/git/.ssh/id_rsa.pub >> /home/git/.ssh/authorized_keys"
echo "ssh -p $(( service_port+22 )) -o StrictHostKeyChecking=no git@127.0.0.1 \"SSH_ORIGINAL_COMMAND=\\\"\$SSH_ORIGINAL_COMMAND\\\" \$0 \$@\"" > /usr/local/bin/gitea
chown git:git /usr/local/bin/gitea
su - git -c "chmod a+x /usr/local/bin/gitea"
declare user_id=$( id git | awk -F'[=() ]+' '{print $2}' )
declare group_id=$( id git | awk -F'[=() ]+' '{print $5}' )
@ -60,5 +58,4 @@ services:
- ./mysql:/var/lib/mysql
EOF
chown -R git:git $install_path
sudo docker compose up -d
docker compose up -d

View File

@ -17,7 +17,7 @@ done
echo "输入其他字符返回主页"
read -p "请输入:" user_choice
if [[ ! ${user_choice} =~ [1-$file_count] ]];then
if [[ ! "$user_choice" =~ ^[0-9]+$ ]] || [ "$user_choice" -lt 1 ] || [ "$user_choice" -gt "$file_count" ]; then
exit
fi
@ -28,7 +28,10 @@ if [[ -z ${storage_path} ]];then
fi
if [[ ! -d "$storage_path" ]]; then
sudo mkdir -p "$storage_path" || { echo "目录创建失败"; exit 1; }
mkdir -p "$storage_path" || {
echo "目录创建失败"
exit 1
}
elif [[ ! -z "$(find "$storage_path" -mindepth 1 -print -quit)" ]]; then
echo "该目录存有文件"
exit
@ -36,8 +39,7 @@ fi
declare random_port=$(($RANDOM % 9000 + 1000))
while ss -tuln | grep $random_port &> /dev/null
do
while ss -tuln | grep $random_port &>/dev/null; do
random_port=$(($RANDOM % 9000 + 1000))
done

View File

@ -108,11 +108,11 @@ rm typecho.zip
cd $installation_directory
sudo chown -R 1000:1000 $installation_directory
chown -R 1000:1000 $installation_directory
sudo chmod -R 777 data
chmod -R 777 data
sudo docker compose up -d
docker compose up -d
echo "数据库地址mysql"
echo "数据库用户名root"

View File

@ -43,11 +43,11 @@ fi
if [[ ! $baidu_backup_choice =~ [Nn] ]];then
if [[ -f "/usr/bin/apt-get" ]];then
sudo apt-get install python3-venv -y
apt-get install python3-venv -y
elif [[ -f "/usr/bin/apt" ]];then
sudo apt-get install python3-venv -y
apt-get install python3-venv -y
elif [[ -f "/usr/bin/pacman" ]];then
sudo pacman -Sy python3-venv --noconfirm
pacman -Sy python3-venv --noconfirm
else
echo "无法自动安装 python3-venv请手动安装"
exit

View File

@ -17,10 +17,11 @@ done
echo "输入其他任意值返回主页"
read -p "请输入:" user_choice
if [[ ! ${user_choice} =~ [1-$file_count] ]];then
if [[ ! "$user_choice" =~ ^[0-9]+$ ]] || [ "$user_choice" -lt 1 ] || [ "$user_choice" -gt "$file_count" ]; then
exit
fi
read -p "请输入脚本存放路径(默认:/var/script" script_path
if [[ -z $script_path ]];then

View File

@ -15,7 +15,7 @@ cat > "${docker_compose_path}/up-docker_compose.sh" << EOF
#!/bin/bash
for dir in "${data_directory}"/*/; do
cd "\$dir" || exit
sudo docker compose pull
sudo docker compose up -d
docker compose pull
docker compose up -d
done
EOF

View File

@ -3,13 +3,13 @@ declare update_path="$1"
echo '#!/bin/bash' > "${update_path}/update.sh"
if [[ -f "/usr/bin/apt" ]];then
echo 'sudo apt update -y' >> "${update_path}/update.sh"
echo 'sudo apt-get dist-upgrade -y' >> "${update_path}/update.sh"
echo 'apt update -y' >> "${update_path}/update.sh"
echo 'apt-get dist-upgrade -y' >> "${update_path}/update.sh"
elif [[ -f "/usr/bin/apt-get" ]];then
echo 'sudo apt-get update -y' >> "${update_path}/update.sh"
echo 'sudo apt dist-upgrade -y' >> "${update_path}/update.sh"
echo 'apt-get update -y' >> "${update_path}/update.sh"
echo 'apt dist-upgrade -y' >> "${update_path}/update.sh"
elif [[ -f "/usr/bin/pacman" ]];then
sudo pacman -Syu --noconfirm
pacman -Syu --noconfirm
else
rm "${update_path}/update.sh"
echo "暂不支持该系统的自动更新配置"

2
run.sh
View File

@ -44,7 +44,7 @@ if [[ $local_path != $script_path ]]; then
fi
read -p "请输入要使用的功能:" user_choice
if [[ "${user_choice}" =~ [1-${#function_array[*]}] ]];then
if [[ "$user_choice" =~ ^[0-9]+$ ]] && [ "$user_choice" -ge 1 ] && [ "$user_choice" -le "${#function_array[*]}" ]; then
clear
if [[ -d "${local_path}/${function_array[$user_choice]}" ]]; then
local_path="${local_path}/${function_array[$user_choice]}"