修复菜单脚本文件数量过多判断问题,gitea脚本执行顺序问题,去掉sudo检查
This commit is contained in:
parent
a29c459709
commit
601b8ea2fb
@ -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
|
@ -5,50 +5,52 @@ declare selected_file_name
|
||||
echo "========$(basename $0 .sh)========"
|
||||
declare file_count=0
|
||||
declare -a file_array
|
||||
for file in "${local_directory}"/*;do
|
||||
selected_file_name=$(awk -F '.' '{print $1}' <<< "$(basename $file)")
|
||||
if [[ $selected_file_name == "test" || $selected_file_name == "menu" ]]; then
|
||||
continue
|
||||
fi
|
||||
file_count=$((file_count + 1))
|
||||
file_array[$file_count]=$selected_file_name
|
||||
echo "${file_count}.${selected_file_name}"
|
||||
for file in "${local_directory}"/*; do
|
||||
selected_file_name=$(awk -F '.' '{print $1}' <<<"$(basename $file)")
|
||||
if [[ $selected_file_name == "test" || $selected_file_name == "menu" ]]; then
|
||||
continue
|
||||
fi
|
||||
file_count=$((file_count + 1))
|
||||
file_array[$file_count]=$selected_file_name
|
||||
echo "${file_count}.${selected_file_name}"
|
||||
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
|
||||
|
||||
declare storage_path
|
||||
read -p "请输入软件存储位置,默认 /var/www/${file_array[${user_choice}]} :" storage_path
|
||||
if [[ -z ${storage_path} ]];then
|
||||
read -p "请输入软件存储位置,默认 /var/www/${file_array[${user_choice}]} :" storage_path
|
||||
if [[ -z ${storage_path} ]]; then
|
||||
storage_path="/var/www/${file_array[${user_choice}]}"
|
||||
fi
|
||||
|
||||
if [[ ! -d "$storage_path" ]];then
|
||||
sudo mkdir -p "$storage_path" || { echo "目录创建失败"; exit 1; }
|
||||
elif [[ ! -z "$(find "$storage_path" -mindepth 1 -print -quit)" ]];then
|
||||
echo "该目录存有文件"
|
||||
exit
|
||||
if [[ ! -d "$storage_path" ]]; then
|
||||
mkdir -p "$storage_path" || {
|
||||
echo "目录创建失败"
|
||||
exit 1
|
||||
}
|
||||
elif [[ ! -z "$(find "$storage_path" -mindepth 1 -print -quit)" ]]; then
|
||||
echo "该目录存有文件"
|
||||
exit
|
||||
fi
|
||||
|
||||
declare random_port=$(($RANDOM % 9000 + 1000))
|
||||
|
||||
while ss -tuln | grep $random_port &> /dev/null
|
||||
do
|
||||
random_port=$(($RANDOM % 9000 + 1000))
|
||||
while ss -tuln | grep $random_port &>/dev/null; do
|
||||
random_port=$(($RANDOM % 9000 + 1000))
|
||||
done
|
||||
|
||||
declare access_port
|
||||
read -p "请输入访问端口,默认 $random_port :" access_port
|
||||
read -p "请输入访问端口,默认 $random_port :" access_port
|
||||
|
||||
if [[ -z $access_port ]];then
|
||||
if [[ -z $access_port ]]; then
|
||||
access_port=$random_port
|
||||
fi
|
||||
|
||||
if ss -tuln | grep $access_port &> /dev/null;then
|
||||
if ss -tuln | grep $access_port &>/dev/null; then
|
||||
echo "端口已被占用"
|
||||
exit
|
||||
fi
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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
2
run.sh
@ -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]}"
|
||||
|
Loading…
Reference in New Issue
Block a user