Compare commits
No commits in common. "e1d14e68cb47258d1119841be9802e55568ffcd0" and "147670f24f095b09f766e330ce22834795b37eca" have entirely different histories.
e1d14e68cb
...
147670f24f
@ -1,7 +0,0 @@
|
|||||||
declare path="$1"
|
|
||||||
|
|
||||||
cat > "${path}/acme_update.sh" << EOF
|
|
||||||
#!/bin/bash
|
|
||||||
${HOME}/.acme.sh/acme.sh --upgrade
|
|
||||||
${HOME}/.acme.sh/acme.sh --renew-all
|
|
||||||
EOF
|
|
11
Config/Automation/acme.sh
Normal file
11
Config/Automation/acme.sh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
declare path="$1"
|
||||||
|
|
||||||
|
if [[ -f "${path}/acme.sh" ]];then
|
||||||
|
echo "该路径文件已经存在"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat > "${path}/acme.sh" << EOF
|
||||||
|
#!/bin/bash
|
||||||
|
${HOME}/.acme.sh/acme.sh --upgrade
|
||||||
|
${HOME}/.acme.sh/acme.sh --renew-all
|
||||||
|
EOF
|
@ -8,6 +8,10 @@ declare aliyun_pick
|
|||||||
declare ignore=1
|
declare ignore=1
|
||||||
|
|
||||||
|
|
||||||
|
if [[ -f "${path}/backup.sh" ]];then
|
||||||
|
echo "该路径文件已经存在"
|
||||||
|
fi
|
||||||
|
|
||||||
read -p "请输入数据目录,默认 /var/www :" web_path
|
read -p "请输入数据目录,默认 /var/www :" web_path
|
||||||
if [[ -z ${web_path} ]];then
|
if [[ -z ${web_path} ]];then
|
||||||
web_path='/var/www'
|
web_path='/var/www'
|
||||||
@ -19,7 +23,7 @@ for item in "$web_path"/* ; do
|
|||||||
echo "${item_name}"
|
echo "${item_name}"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "请输入需要屏蔽的目录用 空格 隔开"
|
echo "请输入需要屏蔽的目录用逗号隔开"
|
||||||
read -p "请输入:" ignore
|
read -p "请输入:" ignore
|
||||||
|
|
||||||
|
|
@ -5,7 +5,9 @@ if ! command -v docker &> /dev/null; then
|
|||||||
echo "docker未安装"
|
echo "docker未安装"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
if [[ -f "${path}/up-docker_compose.sh" ]];then
|
||||||
|
echo "该路径文件已经存在"
|
||||||
|
fi
|
||||||
declare web_path
|
declare web_path
|
||||||
read -p "请输入数据目录,默认 /var/www :" web_path
|
read -p "请输入数据目录,默认 /var/www :" web_path
|
||||||
if [[ -z ${web_path} ]];then
|
if [[ -z ${web_path} ]];then
|
@ -1,5 +1,9 @@
|
|||||||
declare path="$1"
|
declare path="$1"
|
||||||
|
|
||||||
|
if [[ -f "${path}/update.sh" ]];then
|
||||||
|
echo "该路径文件已经存在"
|
||||||
|
fi
|
||||||
|
|
||||||
echo '#!/bin/bash' > "${path}/update.sh"
|
echo '#!/bin/bash' > "${path}/update.sh"
|
||||||
|
|
||||||
if [[ -f "/usr/bin/apt" ]];then
|
if [[ -f "/usr/bin/apt" ]];then
|
@ -14,7 +14,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "${port}:5244"
|
- "${port}:5244"
|
||||||
EOF
|
EOF
|
||||||
docker compose up -d || "安装失败" $$ exit
|
sudo docker compose up -d || "安装失败" $$ exit
|
||||||
declare password=$( docker exec -it alist ./alist admin random | grep password | awk '{print $4}')
|
declare password=$( sudo docker exec -it alist ./alist admin random | grep password | awk '{print $4}')
|
||||||
echo "账号:admin"
|
echo "账号:admin"
|
||||||
echo "密码:${password}"
|
echo "密码:${password}"
|
@ -1,10 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if ! command -v sudo &> /dev/null; then
|
|
||||||
echo "该软件需要安装sudo才能正常安装"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare path=$1
|
declare path=$1
|
||||||
declare port=$2
|
declare port=$2
|
||||||
|
|
||||||
@ -57,7 +52,6 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./mysql:/var/lib/mysql
|
- ./mysql:/var/lib/mysql
|
||||||
EOF
|
EOF
|
||||||
chown -R git:git $path
|
|
||||||
sudo docker compose up -d
|
sudo docker compose up -d
|
||||||
|
|
||||||
sudo -u git ssh -p $(( port+22 )) -o StrictHostKeyChecking=no git@127.0.0.1 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@"
|
sudo -u git ssh -p $(( port+22 )) -o StrictHostKeyChecking=no git@127.0.0.1 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@"
|
@ -16,6 +16,6 @@ services:
|
|||||||
- ./data:/data
|
- ./data:/data
|
||||||
- ./letsencrypt:/etc/letsencrypt
|
- ./letsencrypt:/etc/letsencrypt
|
||||||
EOF
|
EOF
|
||||||
docker compose up -d
|
sudo docker compose up -d
|
||||||
echo "Email: admin@example.com"
|
echo "Email: admin@example.com"
|
||||||
echo "Password: changeme"
|
echo "Password: changeme"
|
@ -12,7 +12,7 @@ POSTGRES_PASSWORD="safeline"
|
|||||||
SUBNET_PREFIX=172.22.222
|
SUBNET_PREFIX=172.22.222
|
||||||
IMAGE_PREFIX=swr.cn-east-3.myhuaweicloud.com/chaitin-safeline
|
IMAGE_PREFIX=swr.cn-east-3.myhuaweicloud.com/chaitin-safeline
|
||||||
EOF
|
EOF
|
||||||
docker compose up -d || "安装失败" $$ exit
|
sudo docker compose up -d || "安装失败" $$ exit
|
||||||
declare password=$( docker exec safeline-mgt resetadmin &> /dev/null | grep password | awk -F ":" '{print $2}' )
|
declare password=$( docker exec safeline-mgt resetadmin &> /dev/null | grep password | awk -F ":" '{print $2}' )
|
||||||
echo "账号:admin"
|
echo "账号:admin"
|
||||||
echo "密码:${password}"
|
echo "密码:${password}"
|
@ -8,7 +8,7 @@ if [[ -z $password ]];then
|
|||||||
password="Siyuan"
|
password="Siyuan"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown -R 1000:1000 $path
|
sudo chown -R 1000:1000 $path
|
||||||
cd $path
|
cd $path
|
||||||
cat > "docker-compose.yml" << EOF
|
cat > "docker-compose.yml" << EOF
|
||||||
version: "3.9"
|
version: "3.9"
|
||||||
@ -27,5 +27,5 @@ services:
|
|||||||
- "--lang=zh_CN"
|
- "--lang=zh_CN"
|
||||||
- "--accessAuthCode=$password"
|
- "--accessAuthCode=$password"
|
||||||
EOF
|
EOF
|
||||||
docker compose up -d || "安装失败" $$ exit
|
sudo docker compose up -d || "安装失败" $$ exit
|
||||||
echo "访问密码:$password"
|
echo "访问密码:$password"
|
@ -1,57 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
declare path_local=$1
|
|
||||||
declare pick
|
|
||||||
declare file_name
|
|
||||||
echo "========$(basename $0 .sh)========"
|
|
||||||
declare print_number=0
|
|
||||||
declare -a print_array
|
|
||||||
for i in "${path_local}"/*;do
|
|
||||||
file_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
|
|
||||||
if [[ $file_name == "test" || $file_name == "menu" ]]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
print_number=$((print_number + 1))
|
|
||||||
print_array[$print_number]=$file_name
|
|
||||||
echo "${print_number}.${file_name}"
|
|
||||||
done
|
|
||||||
echo "输入其他任意返回主页"
|
|
||||||
read -p "请输入:" pick
|
|
||||||
|
|
||||||
if [[ ! ${pick} =~ [1-$print_number] ]];then
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare file_path
|
|
||||||
read -p "请输入软件储存位置,默认 /var/www/${print_array[${pick}]} :" file_path
|
|
||||||
if [[ -z ${file_path} ]];then
|
|
||||||
file_path="/var/www/${print_array[${pick}]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -d "$file_path" ]];then
|
|
||||||
sudo mkdir -p "$file_path" || { echo "目录创建失败"; exit 1; }
|
|
||||||
elif [[ ! -z "$(find "$file_path" -mindepth 1 -print -quit)" ]];then
|
|
||||||
echo "该目录存有文件"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare dport=$(($RANDOM % 9000 + 1000))
|
|
||||||
|
|
||||||
while ss -tuln | grep $dport &> /dev/null
|
|
||||||
do
|
|
||||||
dport=$(($RANDOM % 9000 + 1000))
|
|
||||||
done
|
|
||||||
|
|
||||||
declare port
|
|
||||||
read -p "请输入访问端口,默认 $dport :" port
|
|
||||||
|
|
||||||
if [[ -z $port ]];then
|
|
||||||
port=$dport
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ss -tuln | grep $port &> /dev/null;then
|
|
||||||
echo "端口已被占用"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
bash "${path_local}/${print_array[pick]}.sh" "$file_path" "$port"
|
|
||||||
echo "${print_array[${pick}]}安装完成,访问端口${port}"
|
|
@ -40,5 +40,5 @@ mv "$admin" "../admin"
|
|||||||
mv "$email" "../email"
|
mv "$email" "../email"
|
||||||
cd ..
|
cd ..
|
||||||
rm -rf vaultwarden-lang-zhcn-main
|
rm -rf vaultwarden-lang-zhcn-main
|
||||||
docker compose up -d || echo "安装失败" && exit
|
sudo docker compose up -d || echo "安装失败" && exit
|
||||||
echo "需要反向代理,使用https,才能正常使用"
|
echo "需要反向代理,使用https,才能正常使用"
|
@ -1,31 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
echo "1.查看当前运行中的镜像"
|
|
||||||
echo "2.停止镜像"
|
|
||||||
echo "3.删除没有使用的镜像"
|
|
||||||
|
|
||||||
declare pick
|
|
||||||
read -p "请输入:" pick
|
|
||||||
|
|
||||||
case $pick in
|
|
||||||
'1')
|
|
||||||
docker ps --format "{{.Names}}"
|
|
||||||
;;
|
|
||||||
'2')
|
|
||||||
declare -a docker_arr=($(docker ps --format "{{.Names}}"))
|
|
||||||
declare docker_number=0
|
|
||||||
for i in "${docker_arr[@]}" ; do
|
|
||||||
docker_number=$(( docker_number+1 ))
|
|
||||||
echo "${docker_number}.${i}"
|
|
||||||
done
|
|
||||||
echo "要停止的镜像序号,多个镜像用 空格 隔开"
|
|
||||||
read -p "请输入:" pick
|
|
||||||
for i in $pick ; do
|
|
||||||
if [[ $i =~ [1-$docker_number] ]]; then
|
|
||||||
docker stop "${docker_arr[$(( i -1 ))]}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
'3')
|
|
||||||
docker system prune -af
|
|
||||||
echo "清理完成"
|
|
||||||
esac
|
|
@ -1,42 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
echo "========$(basename $0 .sh)========"
|
|
||||||
echo "1.查看当前源"
|
|
||||||
echo "2.换源"
|
|
||||||
declare pick
|
|
||||||
read -p "请输入:" pick
|
|
||||||
|
|
||||||
case $pick in
|
|
||||||
'1')
|
|
||||||
grep -oP '(https?://[^\"]+)' /etc/docker/daemon.json
|
|
||||||
;;
|
|
||||||
'2')
|
|
||||||
declare -A img_dick
|
|
||||||
declare -a img_number
|
|
||||||
declare img_pick=0
|
|
||||||
img_dick['Daocloud(默认)']='https://docker.m.daocloud.io'
|
|
||||||
img_dick['官方']='docker.io'
|
|
||||||
|
|
||||||
for i in "${!img_dick[@]}";
|
|
||||||
do
|
|
||||||
img_pick=$(( img_pick+1 ))
|
|
||||||
img_number[$img_pick]=$i
|
|
||||||
echo "${img_pick}.${i}"
|
|
||||||
done
|
|
||||||
read -p "请输入要选择的镜像,也可直接输入镜像网站:" img_pick
|
|
||||||
if [[ -z $img_pick ]];then
|
|
||||||
declare url='https://docker.m.daocloud.io'
|
|
||||||
elif [[ $img_pick =~ [\w\.]+ ]];then
|
|
||||||
declare url=$img_pick
|
|
||||||
elif [[ ${img_pick} =~ [1-${!img_dick[*]}] ]];then
|
|
||||||
img_pick=${img_number[$img_pick]}
|
|
||||||
declare url=${img_dick[$img_pick]}
|
|
||||||
else
|
|
||||||
echo "输入错误"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
echo "{\"registry-mirrors\": [\"${url}\"]}" > "/etc/docker/daemon.json"
|
|
||||||
systemctl restart docker 2>> /dev/null|| echo "docker 重启失败"&&exit
|
|
||||||
echo "换源成功"
|
|
||||||
|
|
||||||
;;
|
|
||||||
esac
|
|
@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
if ! command -v docker &> /dev/null; then
|
|
||||||
echo "docker未安装"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
@ -1,93 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
if [[ $UID != 0 ]]; then
|
|
||||||
echo "请以root权限执行该脚本"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! command -v git &> /dev/null; then
|
|
||||||
if [[ -f "/usr/bin/apt-get" ]];then
|
|
||||||
apt-get update -y
|
|
||||||
apt-get install git -y
|
|
||||||
elif [[ -f "/usr/bin/apt" ]];then
|
|
||||||
apt update -y
|
|
||||||
apt install git -y
|
|
||||||
elif [[ -f "/usr/bin/pacman" ]];then
|
|
||||||
pacman -Syu --noconfirm
|
|
||||||
pacman -Sy --noconfirm git
|
|
||||||
else
|
|
||||||
echo "git未安装"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
declare path
|
|
||||||
echo "请输入脚本的安装位置"
|
|
||||||
read -p "默认 /var/script:" path
|
|
||||||
if [[ -z $path ]];then
|
|
||||||
path="/var/script"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "$path"
|
|
||||||
rm -rf "$path/linuxtool"
|
|
||||||
|
|
||||||
declare -A url_dick
|
|
||||||
declare -a url_arr
|
|
||||||
declare url_number=0
|
|
||||||
declare url_pick
|
|
||||||
declare url
|
|
||||||
echo "请选择脚本的下载地址"
|
|
||||||
url_dick['github(default)']='https://github.com/lsy2246/linuxtool.git'
|
|
||||||
url_dick['gitee']='https://gitee.com/lsy22/linuxtool.git'
|
|
||||||
url_dick['gitlsy']='https://g.lsy22.com/lsy/linuxtool.git'
|
|
||||||
|
|
||||||
for i in "${!url_dick[@]}" ; do
|
|
||||||
url_number=$(( url_number+1 ))
|
|
||||||
url_arr[$url_number]=$i
|
|
||||||
echo "${url_number}.${i}"
|
|
||||||
done
|
|
||||||
|
|
||||||
read -p "请输入:" url_pick
|
|
||||||
|
|
||||||
if [[ $url_pick =~ [1-${#url_dick[@]}] ]]; then
|
|
||||||
url=${url_dick[${url_arr[$url_pick]}]}
|
|
||||||
else
|
|
||||||
url='https://github.com/lsy2246/linuxtool.git'
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "正在下载脚本中"
|
|
||||||
git clone "$url" "$path/linuxtool" &> /dev/null
|
|
||||||
|
|
||||||
if ! [[ -d "${path}/linuxtool" ]];then
|
|
||||||
echo "脚本下载失败"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
chmod +x "$path/linuxtool/run.sh" &> /dev/null
|
|
||||||
|
|
||||||
if [[ -e "${HOME}/.bashrc" ]];then
|
|
||||||
sed -i '/alias tool.*/d' "${HOME}/.bashrc"
|
|
||||||
echo "alias tool='$path/linuxtool/run.sh'" | cat >> "${HOME}/.bashrc"
|
|
||||||
source "${HOME}/.bashrc" &> /dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -e "${HOME}/.profile" ]];then
|
|
||||||
sed -i '/alias tool.*/d' "${HOME}/.profile"
|
|
||||||
echo "alias tool='$path/linuxtool/run.sh'" | cat >> "${HOME}/.profile"
|
|
||||||
source "${HOME}/.profile" &> /dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -e "${HOME}/.zshrc" ]];then
|
|
||||||
sed -i '/alias tool.*/d' "${HOME}/.zshrc"
|
|
||||||
echo "alias tool='$path/linuxtool/run.sh'" | cat >> "${HOME}/.zshrc"
|
|
||||||
source "${HOME}/.zshrc" &> /dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
sed -i '/alias tool.*/d' "/etc/profile"
|
|
||||||
echo "alias tool='$path/linuxtool/run.sh'" | cat >> "/etc/profile"
|
|
||||||
|
|
||||||
alias tool="$path/linuxtool/run.sh"
|
|
||||||
|
|
||||||
echo "工具箱已经安装成功"
|
|
||||||
echo "位置:${path}/linuxtool"
|
|
||||||
echo "命令:tool"
|
|
100
Config/Other/Acme.sh
Normal file
100
Config/Other/Acme.sh
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ ! -f "${HOME}/.acme.sh/acme.sh" ]];then
|
||||||
|
rm -rf ${HOME}/.acme.sh
|
||||||
|
declare mail
|
||||||
|
declare domain
|
||||||
|
read -p "请输入用来申请域名的邮箱:" mail
|
||||||
|
if [[ ! $mail =~ .*@.* ]];then
|
||||||
|
echo "邮箱不合法"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl https://get.acme.sh | sh -s "email=$mail"
|
||||||
|
fi
|
||||||
|
|
||||||
|
declare domain_str=''
|
||||||
|
echo "请输入需要申请SSL证书的域名"
|
||||||
|
while(true);do
|
||||||
|
read -p "不输入退出添加:" domain
|
||||||
|
if [[ -z $domain ]];then
|
||||||
|
break
|
||||||
|
elif [[ ! $domain =~ [\w+\.]+ ]];then
|
||||||
|
echo "域名不合法"
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
domain_str="$domain_str -d $domain"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ -z $domain_str ]]; then
|
||||||
|
echo "需要添加的域名不能为空"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
declare pick_mode
|
||||||
|
echo "1.http验证"
|
||||||
|
echo "2.dns验证"
|
||||||
|
read -p "请选择验证模式:" pick_mode
|
||||||
|
|
||||||
|
case $pick_mode in
|
||||||
|
'1')
|
||||||
|
declare pick_start
|
||||||
|
echo "请到服务器将80和443端口开启,将域名解析到本机"
|
||||||
|
read -p "解析完成请输入 y:" pick_start
|
||||||
|
if [[ ! $pick_start =~ [Yy] ]];then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
eval "${HOME}/.acme.sh/acme.sh --issue $domain_str --standalone"
|
||||||
|
;;
|
||||||
|
'2')
|
||||||
|
declare pick=0
|
||||||
|
declare -a mode_arr
|
||||||
|
mode_arr[1]="TXT记录"
|
||||||
|
mode_arr[2]='cloudflare'
|
||||||
|
for i in "${!mode_arr[@]}"; do
|
||||||
|
((pick++))
|
||||||
|
echo "${pick}. ${mode_arr[$i]}"
|
||||||
|
done
|
||||||
|
read -p "请选择验证模式:" pick_mode
|
||||||
|
if [[ ! $pick_mode =~ [1-${pick}] ]]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
case ${mode_arr[$pick_mode]} in
|
||||||
|
'TXT记录')
|
||||||
|
declare domain
|
||||||
|
declare log_output=$(${HOME}/.acme.sh/acme.sh --issue --dns $domain_str --yes-I-know-dns-manual-mode-enough-go-ahead-please)
|
||||||
|
declare domain=$( echo "$log_output" | grep "Domain:" | awk -F ": " '{print $2}')
|
||||||
|
declare txt_value=$(echo "$log_output" | grep "TXT value:" | awk -F ": " '{print $2}')
|
||||||
|
echo "请到dns系统解析TXT记录"
|
||||||
|
echo "名称: "
|
||||||
|
echo $domain
|
||||||
|
echo "文本记录:"
|
||||||
|
echo $txt_value
|
||||||
|
read -p "解析完成请输入 y:" pick
|
||||||
|
if [[ $pick =~ [Yy] ]]; then
|
||||||
|
eval "${HOME}/.acme.sh/acme.sh --renew $domain_str --yes-I-know-dns-manual-mode-enough-go-ahead-please"
|
||||||
|
else
|
||||||
|
echo "解析完成后请输入下面的命令完成验证"
|
||||||
|
echo "${HOME}/.acme.sh/acme.sh --renew $domain_str --yes-I-know-dns-manual-mode-enough-go-ahead-please"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
'cloudflare')
|
||||||
|
declare CF_Key
|
||||||
|
declare CF_Email
|
||||||
|
read -p "请输入cloudflare的邮箱:" CF_Email
|
||||||
|
if [[ ! $CF_Email =~ .*@.* ]];then
|
||||||
|
echo "邮箱不合法"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
read -p "请输入cloudflare的密钥:" CF_Key
|
||||||
|
export CF_Key=$CF_Key
|
||||||
|
export CF_Email=$CF_Email
|
||||||
|
eval "${HOME}/.acme.sh/acme.sh --issue $domain_str --dns dns_cf"
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
37
Config/Other/Language.sh
Normal file
37
Config/Other/Language.sh
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
declare lang
|
||||||
|
echo "1.中文"
|
||||||
|
echo "2.英文"
|
||||||
|
read -p "请输入:" lang
|
||||||
|
if [[ -f "/usr/bin/apt-get" ]];then
|
||||||
|
sudo apt-get update -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 -y
|
||||||
|
sudo apt install -y locales
|
||||||
|
sudo apt install -y language-pack-zh-hans
|
||||||
|
else
|
||||||
|
echo "暂不支持该系统一键更换语言"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
sudo sed -i '/^#/! s/^/# /' /etc/locale.gen
|
||||||
|
if ! grep LC_ALL /etc/default/locale &> /dev/null; then
|
||||||
|
echo "LC_ALL=en_US.UTF-8" >> /etc/default/locale
|
||||||
|
fi
|
||||||
|
case $lang in
|
||||||
|
'1')
|
||||||
|
sudo sed -i 's/.*zh_CN.UTF-8.*/zh_CN.UTF-8 UTF-8/g' /etc/locale.gen
|
||||||
|
sudo sed -i "s/^LANG.*/LANG=zh_CN.UTF-8/g" /etc/default/locale
|
||||||
|
sudo sed -i "s/^LC_ALL.*/LC_ALL=zh_CN.UTF-8/g" /etc/default/locale
|
||||||
|
;;
|
||||||
|
'2')
|
||||||
|
sudo sed -i 's/.*en_US.UTF-8.*/en_US.UTF-8 UTF-8/g' /etc/locale.gen
|
||||||
|
sudo sed -i "s/^LANG.*/LANG=en_US.UTF-8/g" /etc/default/locale
|
||||||
|
sudo sed -i "s/^LC_ALL.*/LC_ALL=en_US.UTF-8/g" /etc/default/locale
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
sudo locale-gen
|
||||||
|
update-locale
|
||||||
|
source /etc/default/locale
|
||||||
|
echo "语言更换成功"
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
declare version=$(uname -r | awk -F "." '{print $1}')
|
|
||||||
if ! [[ $version -ge 5 ]];then
|
|
||||||
echo "系统内核版本过低"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
grep -q "net.core.default_qdisc=fq" "/etc/sysctl.conf" || echo 'net.core.default_qdisc=fq' | tee -a "/etc/sysctl.conf"
|
|
||||||
grep -q "net.ipv4.tcp_congestion_control=bbr" "/etc/sysctl.conf" || echo 'net.ipv4.tcp_congestion_control=bbr' | tee -a "/etc/sysctl.conf"
|
|
||||||
sysctl -p || echo "bbr 开启失败"
|
|
||||||
sysctl net.ipv4.tcp_available_congestion_control | grep bbr && echo "bbr 开启成功"
|
|
@ -1,38 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
declare lang
|
|
||||||
echo "========$(basename $0 .sh)========"
|
|
||||||
echo "1.中文"
|
|
||||||
echo "2.英文"
|
|
||||||
read -p "请输入:" lang
|
|
||||||
if [[ -f "/usr/bin/apt-get" ]];then
|
|
||||||
apt-get update -y
|
|
||||||
apt-get install -y locales
|
|
||||||
apt-get install -y language-pack-zh-hans
|
|
||||||
elif [[ -f "/usr/bin/apt" ]];then
|
|
||||||
apt update -y
|
|
||||||
apt install -y locales
|
|
||||||
apt install -y language-pack-zh-hans
|
|
||||||
else
|
|
||||||
echo "暂不支持该系统一键更换语言"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
sed -i '/^#/! s/^/# /' /etc/locale.gen
|
|
||||||
if ! grep LC_ALL /etc/default/locale &> /dev/null; then
|
|
||||||
echo "LC_ALL=en_US.UTF-8" >> /etc/default/locale
|
|
||||||
fi
|
|
||||||
case $lang in
|
|
||||||
'1')
|
|
||||||
sed -i 's/.*zh_CN.UTF-8.*/zh_CN.UTF-8 UTF-8/g' /etc/locale.gen
|
|
||||||
sed -i "s/^LANG.*/LANG=zh_CN.UTF-8/g" /etc/default/locale
|
|
||||||
sed -i "s/^LC_ALL.*/LC_ALL=zh_CN.UTF-8/g" /etc/default/locale
|
|
||||||
;;
|
|
||||||
'2')
|
|
||||||
sed -i 's/.*en_US.UTF-8.*/en_US.UTF-8 UTF-8/g' /etc/locale.gen
|
|
||||||
sed -i "s/^LANG.*/LANG=en_US.UTF-8/g" /etc/default/locale
|
|
||||||
sed -i "s/^LC_ALL.*/LC_ALL=en_US.UTF-8/g" /etc/default/locale
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
locale-gen
|
|
||||||
update-locale
|
|
||||||
source /etc/default/locale
|
|
||||||
echo "语言更换成功"
|
|
@ -1,55 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
declare pick
|
|
||||||
declare server
|
|
||||||
echo "========$(basename $0 .sh)========"
|
|
||||||
echo "请选择下载服务器"
|
|
||||||
echo "1.国内服务器"
|
|
||||||
echo "2.国外服务器(默认)"
|
|
||||||
read -p "请输入:" pick
|
|
||||||
if [[ $pick == '1' ]];then
|
|
||||||
server="https://jihulab.com/bin456789/reinstall/-/raw/main/reinstall.sh"
|
|
||||||
else
|
|
||||||
server="https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh"
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare -A imags_dick
|
|
||||||
declare -a imags_arr
|
|
||||||
declare imags_number=0
|
|
||||||
imags_dick['arch']=""
|
|
||||||
imags_dick['kali']=""
|
|
||||||
imags_dick['debian']="8 9 10 11 12"
|
|
||||||
imags_dick['Ubuntu']="16.04 18.04 20.04 22.04 24.04"
|
|
||||||
|
|
||||||
for i in "${!imags_dick[@]}" ; do
|
|
||||||
imags_number=$(( imags_number+1 ))
|
|
||||||
imags_arr[$imags_number]=$i
|
|
||||||
echo "${imags_number}.${i}"
|
|
||||||
done
|
|
||||||
|
|
||||||
read -p "请选择需要安装的镜像序号:" pick
|
|
||||||
|
|
||||||
if [[ $pick =~ [1-"${#imags_dick[@]}"\ ] ]];then
|
|
||||||
declare img=${imags_arr[$pick]}
|
|
||||||
declare version=''
|
|
||||||
declare -a version_arr
|
|
||||||
declare version_number=0
|
|
||||||
if [[ ! -z ${imags_dick[$img]} ]];then
|
|
||||||
echo "请输入要安装的版本(默认最新)"
|
|
||||||
for i in ${imags_dick[$img]} ; do
|
|
||||||
version_number=$(( version_number+1 ))
|
|
||||||
version_arr[$version_number]=$i
|
|
||||||
echo "${version_number}.${i}"
|
|
||||||
done
|
|
||||||
read -p "请输入:" pick
|
|
||||||
if [ -z $pick ]; then
|
|
||||||
version=${version_arr[$version_number]}
|
|
||||||
elif [[ $pick =~ [1-$version_number] ]];then
|
|
||||||
version=${version_arr[$pick]}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
eval "bash <(curl -Ls ${server}) ${img} ${version}"
|
|
||||||
echo "重启之后开始重装系统"
|
|
||||||
echo "用服务器厂家的VNC连接可以看到重装进度"
|
|
||||||
else
|
|
||||||
echo "选择错误"
|
|
||||||
fi
|
|
@ -1,114 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
echo "========$(basename $0 .sh)========"
|
|
||||||
echo "1.生成密钥"
|
|
||||||
echo "2.安装密钥"
|
|
||||||
echo "输入其他返回主页"
|
|
||||||
declare pick
|
|
||||||
read -p "请输入要选择的命令:" pick
|
|
||||||
|
|
||||||
function open_key() {
|
|
||||||
chmod 600 "$HOME/.ssh/authorized_keys"
|
|
||||||
chmod 700 "$HOME/.ssh"
|
|
||||||
|
|
||||||
sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
|
||||||
|
|
||||||
declare pick2
|
|
||||||
echo "是否关闭密码登录:"
|
|
||||||
read -p "输入 n 取消关闭:" pick2
|
|
||||||
|
|
||||||
if [[ ! $pick2 =~ [Nn] ]];then
|
|
||||||
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/g' /etc/ssh/sshd_config
|
|
||||||
fi
|
|
||||||
|
|
||||||
systemctl restart sshd.service
|
|
||||||
|
|
||||||
echo "密钥安装完成"
|
|
||||||
}
|
|
||||||
|
|
||||||
case $pick in
|
|
||||||
'1')
|
|
||||||
declare site="${HOME}/.ssh"
|
|
||||||
read -p "请输入密钥安装位置,默认 :${site}:" pick
|
|
||||||
|
|
||||||
if [[ -d $pick ]]; then
|
|
||||||
site=$pick
|
|
||||||
elif [[ ! -z $pick ]];then
|
|
||||||
echo "该路径没有文件夹"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare bit=""
|
|
||||||
declare type=""
|
|
||||||
declare phrase=""
|
|
||||||
declare -A type_dick
|
|
||||||
type_dick['rsa']="2048 4096"
|
|
||||||
type_dick['ed25519']=""
|
|
||||||
|
|
||||||
declare print_number=0
|
|
||||||
declare -a print_arr
|
|
||||||
for i in "${!type_dick[@]}" ; do
|
|
||||||
print_number=$(( print_number+1 ))
|
|
||||||
print_arr[$print_number]=$i
|
|
||||||
echo "${print_number}.${i}"
|
|
||||||
done
|
|
||||||
read -p "请选择要生成的密钥类型:" pick
|
|
||||||
if ! [[ $pick =~ [1-${#type_dick[@]}] ]]; then
|
|
||||||
echo "选择错误"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
type=${print_arr[$pick]}
|
|
||||||
|
|
||||||
if [ ! -z "${type_dick[$type]}" ]; then
|
|
||||||
print_number=0
|
|
||||||
echo "请选择密钥位大小"
|
|
||||||
for i in ${type_dick[$type]} ; do
|
|
||||||
print_number=$(( print_number+1 ))
|
|
||||||
print_arr[$print_number]=$i
|
|
||||||
echo "${print_number}.${i}"
|
|
||||||
done
|
|
||||||
read -p "请选择:" pick
|
|
||||||
if ! [[ $pick =~ [1-${#print_arr[@]}] ]]; then
|
|
||||||
echo "选择错误"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
bit="-b ${print_arr[$pick]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
read -p "是否开启密钥短语,输入y开启,请输入:" pick
|
|
||||||
if [[ $pick =~ [Yy] ]]; then
|
|
||||||
read -p "请输入要设置的密钥短语" phrase
|
|
||||||
fi
|
|
||||||
eval "ssh-keygen -t ${type} ${bit} -N '${phrase}' -f '${site}/key' -q"
|
|
||||||
echo "密钥安装成功"
|
|
||||||
echo "私钥:${site}/key"
|
|
||||||
echo "公钥:${site}/key.pub"
|
|
||||||
read -p "是否开启密钥登录,输入n取消:" pick
|
|
||||||
if ! [[ $pick =~ [Nn] ]]; then
|
|
||||||
mkdir -p "$HOME/.ssh"
|
|
||||||
echo "${site}/key.pub" > "$HOME/.ssh/authorized_keys"
|
|
||||||
open_key
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
'2')
|
|
||||||
declare key
|
|
||||||
echo "请输入公钥或文件路径:"
|
|
||||||
echo "默认:$HOME/.ssh/id_rsa.pub"
|
|
||||||
read -p "回车默认:" key
|
|
||||||
|
|
||||||
if [[ -z $key ]];then
|
|
||||||
key="$HOME/.ssh/id_rsa.pub"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -f $key ]];then
|
|
||||||
key=$(cat "$key")
|
|
||||||
fi
|
|
||||||
if [[ ! $key =~ ^ssh-(rsa|ecdsa-sha2-nistp[0-9]+|ed25519|dss) ]];then
|
|
||||||
echo "公钥不合法"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "$HOME/.ssh"
|
|
||||||
echo "$key" > "$HOME/.ssh/authorized_keys"
|
|
||||||
open_key
|
|
||||||
esac
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
declare pick
|
|
||||||
echo "========$(basename $0 .sh)========"
|
|
||||||
echo "1.更换ssh端口"
|
|
||||||
echo "2.修改ssh登录方式"
|
|
||||||
echo "任意输入返回主菜单"
|
|
||||||
read -p "请输入要使用的功能:" pick
|
|
||||||
|
|
||||||
case $pick in
|
|
||||||
'1')
|
|
||||||
read -p "请输入需要修改的端口号(默认22): " port_number
|
|
||||||
|
|
||||||
if [[ -z $port_number ]];then
|
|
||||||
port_number=22
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! [[ $port_number =~ ^[0-9]+$ ]] || ! ((port_number > 0 && port_number < 65535)); then
|
|
||||||
echo "端口不合法"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if lsof -i :$port_number -t >/dev/null; then
|
|
||||||
echo "$port_number 端口已被占用"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
sed -i "s/^#\?Port.*/Port $port_number/g" /etc/ssh/sshd_config
|
|
||||||
|
|
||||||
systemctl restart sshd.service
|
|
||||||
|
|
||||||
echo "端口已经修改为$port_number,记得防火墙放行"
|
|
||||||
;;
|
|
||||||
'2')
|
|
||||||
declare pick_root
|
|
||||||
declare pick2_key
|
|
||||||
declare pick2_password
|
|
||||||
echo "是否关闭root登录"
|
|
||||||
read -p "输入 n 关闭:" pick_root
|
|
||||||
echo "是否关闭密码登录"
|
|
||||||
read -p "输入 n 关闭:" pick2_password
|
|
||||||
echo "是否关闭密钥登录"
|
|
||||||
read -p "输入 n 关闭:" pick2_key
|
|
||||||
|
|
||||||
if [[ ! $pick_root =~ [Nn] ]];then
|
|
||||||
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
|
|
||||||
echo "root用户登录:开启"
|
|
||||||
else
|
|
||||||
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/g' /etc/ssh/sshd_config
|
|
||||||
echo "root用户登录:关闭"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! $pick2_password =~ [Nn] ]];then
|
|
||||||
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
|
||||||
echo "密码登录:开启"
|
|
||||||
else
|
|
||||||
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/g' /etc/ssh/sshd_config
|
|
||||||
echo "密码登录:关闭"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! $pick2_key =~ [Nn] ]];then
|
|
||||||
sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
|
||||||
echo "密钥登录:开启"
|
|
||||||
else
|
|
||||||
sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication no/g' /etc/ssh/sshd_config
|
|
||||||
echo "密钥登录:关闭"
|
|
||||||
fi
|
|
||||||
|
|
||||||
systemctl restart sshd.service
|
|
||||||
;;
|
|
||||||
esac
|
|
@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
if ! command -v ssh &> /dev/null; then
|
|
||||||
echo "ssh未安装"
|
|
||||||
exit
|
|
||||||
fi
|
|
@ -1,102 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
declare pick
|
|
||||||
echo "========$(basename $0 .sh)========"
|
|
||||||
echo "1.新建用户"
|
|
||||||
echo "2.查看所有用户"
|
|
||||||
echo "3.删除用户"
|
|
||||||
echo "4.修改用户密码"
|
|
||||||
echo "任意输入返回主菜单"
|
|
||||||
read -p "请输入要使用的功能:" pick
|
|
||||||
|
|
||||||
case $pick in
|
|
||||||
'1')
|
|
||||||
declare user_name
|
|
||||||
read -p "请输入你想创建的用户名:" user_name
|
|
||||||
|
|
||||||
if id "$user_name" &>/dev/null; then
|
|
||||||
echo "用户 $user_name 已存在。"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
useradd -m -s /bin/bash "$user_name"
|
|
||||||
|
|
||||||
if grep -q "^$user_name " /etc/sudoers;then
|
|
||||||
sed -i "s/^#\?$user_name.*/$user_name ALL=(ALL) NOPASSWD: ALL/g" /etc/sudoers
|
|
||||||
else
|
|
||||||
echo "$user_name ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
declare pick
|
|
||||||
echo "用户登录方式"
|
|
||||||
echo "y.密码登录"
|
|
||||||
echo "n.使用root用户公钥"
|
|
||||||
read -p "默认y,请输入:" pick
|
|
||||||
if [[ ! $pick =~ [Nn] ]];then
|
|
||||||
declare password
|
|
||||||
read -p "请输入密码:" password
|
|
||||||
echo "$user_name:$password" |chpasswd
|
|
||||||
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
|
|
||||||
echo "创建成功"
|
|
||||||
echo "账号:$user_name"
|
|
||||||
echo "密码:$password"
|
|
||||||
else
|
|
||||||
sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
|
||||||
su "$user_name" -c "mkdir -p '/home/$user_name/.ssh'"
|
|
||||||
cp "/root/.ssh/authorized_keys" "/home/$user_name/.ssh/authorized_keys"
|
|
||||||
chown "$user_name:$user_name" "/home/$user_name/.ssh/authorized_keys"
|
|
||||||
su "$user_name" -c "chmod 600 '/home/$user_name/.ssh/authorized_keys'"
|
|
||||||
su "$user_name" -c "chmod 700 '/home/$user_name/.ssh/'"
|
|
||||||
|
|
||||||
echo "创建成功"
|
|
||||||
echo "账号:$user_name"
|
|
||||||
echo "密钥登录"
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare pick2
|
|
||||||
echo "是否关闭root登录"
|
|
||||||
read -p "输入 n 取消关闭:" pick2
|
|
||||||
|
|
||||||
if [[ ! $pick2 =~ [Nn] ]];then
|
|
||||||
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/g' /etc/ssh/sshd_config
|
|
||||||
echo "root用户登录已关闭"
|
|
||||||
fi
|
|
||||||
|
|
||||||
systemctl restart sshd.service
|
|
||||||
;;
|
|
||||||
'2')
|
|
||||||
echo "当前系统有以下用户"
|
|
||||||
cut -d: -f1 /etc/passwd
|
|
||||||
;;
|
|
||||||
'3')
|
|
||||||
declare user_name
|
|
||||||
read -p "请输入需要删除的用户:" user_name
|
|
||||||
if ! id $user_name &> /dev/nuull ;then
|
|
||||||
echo "系统内没有该用户"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
sed -i "/^#\?$user_name.*/d" /etc/sudoers &> /dev/null
|
|
||||||
pkill -u $user_name
|
|
||||||
userdel -r $user_name &> /dev/null
|
|
||||||
rm -rf "/home/${user_name}"
|
|
||||||
echo "用户删除成功"
|
|
||||||
;;
|
|
||||||
'4')
|
|
||||||
declare password
|
|
||||||
declare user_name
|
|
||||||
read -p "请输入需要修改密码的用户:" user_name
|
|
||||||
if ! id $user_name &> /dev/null;then
|
|
||||||
echo "系统内没有该用户"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
read -p "请输入${user_name}需要修改的密码:" password
|
|
||||||
echo "${user_name}:${password}" |chpasswd
|
|
||||||
if [[ ${user_name} == "root" ]]; then
|
|
||||||
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
|
|
||||||
fi
|
|
||||||
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
|
||||||
systemctl restart sshd.service
|
|
||||||
echo "修改成功,用户${user_name}的密码为:${password}"
|
|
||||||
;;
|
|
||||||
esac
|
|
@ -1,142 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
declare pick_mode=$1
|
|
||||||
declare domain=$2
|
|
||||||
|
|
||||||
if ! [[ $pick_mode == "nginx" ]]; then
|
|
||||||
pick_mode=""
|
|
||||||
domain=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! command -v socat &> /dev/null; then
|
|
||||||
if [[ -f "/usr/bin/apt-get" ]];then
|
|
||||||
apt-get update -y
|
|
||||||
apt-get install socat -y
|
|
||||||
elif [[ -f "/usr/bin/apt" ]];then
|
|
||||||
apt update -y
|
|
||||||
apt install socat -y
|
|
||||||
elif [[ -f "/usr/bin/pacman" ]];then
|
|
||||||
pacman -Syu --noconfirm
|
|
||||||
pacman -Sy --noconfirm socat
|
|
||||||
else
|
|
||||||
echo "socat未安装"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -f "${HOME}/.acme.sh/acme.sh" ]];then
|
|
||||||
rm -rf ${HOME}/.apple.sh
|
|
||||||
declare mail
|
|
||||||
read -p "请输入用来申请域名的邮箱:" mail
|
|
||||||
if [[ ! $mail =~ .*@.* ]];then
|
|
||||||
echo "邮箱不合法"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
curl https://get.acme.sh | sh -s "email=$mail"
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare domain_str
|
|
||||||
|
|
||||||
if [[ ! $domain ]];then
|
|
||||||
echo "请输入需要申请SSL证书的域名"
|
|
||||||
read -p "请输入要绑定的域名多个用 空格 隔开:" domain
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
for i in ${domain} ; do
|
|
||||||
if [[ ! $i =~ [\w+\.]+ ]];then
|
|
||||||
echo "域名不合法"
|
|
||||||
exit
|
|
||||||
else
|
|
||||||
domain_str="$domain_str -d $i"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -z $domain_str ]]; then
|
|
||||||
echo "需要添加的域名不能为空"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "1.http验证"
|
|
||||||
echo "2.dns验证"
|
|
||||||
read -p "请选择验证模式:" pick_mode
|
|
||||||
|
|
||||||
case $pick_mode in
|
|
||||||
'1')
|
|
||||||
declare mode
|
|
||||||
if command -v nginx &> /dev/null; then
|
|
||||||
mode="nginx"
|
|
||||||
cat > "/etc/nginx/conf.d/test.conf" << EOF
|
|
||||||
server {
|
|
||||||
listen 80; # 监听80端口
|
|
||||||
server_name ${domain}; # 服务器名称(本地)
|
|
||||||
|
|
||||||
location / {
|
|
||||||
root /usr/share/nginx/html; # 指定根目录
|
|
||||||
index index.html index.htm; # 默认页面
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
elif command -v apache &> /dev/null; then
|
|
||||||
mode="apache"
|
|
||||||
else
|
|
||||||
mode="standalone"
|
|
||||||
fi
|
|
||||||
echo "请到服务器将80和443端口开启,将域名解析到本机"
|
|
||||||
read -p "解析完成请回车:"
|
|
||||||
eval "${HOME}/.acme.sh/acme.sh --issue ${domain_str} --${mode}"
|
|
||||||
rm /etc/nginx/conf.d/test.conf
|
|
||||||
;;
|
|
||||||
'2')
|
|
||||||
declare pick=0
|
|
||||||
declare -a mode_arr
|
|
||||||
mode_arr[1]="TXT记录"
|
|
||||||
mode_arr[2]='cloudflare'
|
|
||||||
for i in "${!mode_arr[@]}"; do
|
|
||||||
((pick++))
|
|
||||||
echo "${pick}. ${mode_arr[$i]}"
|
|
||||||
done
|
|
||||||
read -p "请选择验证模式:" pick_mode
|
|
||||||
if [[ ! $pick_mode =~ [1-${pick}] ]]; then
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
case ${mode_arr[$pick_mode]} in
|
|
||||||
'TXT记录')
|
|
||||||
declare log_output=$(${HOME}/.apple.sh/apple.sh --issue --dns $domain_str --yes-I-know-dns-manual-mode-enough-go-ahead-please)
|
|
||||||
declare -a domain=($( echo "$log_output" | grep "Domain:" | awk -F ": " '{print $2}'))
|
|
||||||
declare -a txt_value=($(echo "$log_output" | grep "TXT value:" | awk -F ": " '{print $2}'))
|
|
||||||
echo "请到dns系统解析TXT记录"
|
|
||||||
for (( i = 0; i < ${#domain[@]}; i++ )); do
|
|
||||||
echo "需要解析的第$((i+1))条"
|
|
||||||
echo "名称: ${domain[$i]}"
|
|
||||||
echo "文本记录:${txt_value[$i]}"
|
|
||||||
done
|
|
||||||
|
|
||||||
read -p "解析完成请输入 y:" pick
|
|
||||||
if [[ $pick =~ [Yy] ]]; then
|
|
||||||
eval "${HOME}/.acme.sh/acme.sh --renew $domain_str --yes-I-know-dns-manual-mode-enough-go-ahead-please"
|
|
||||||
else
|
|
||||||
echo "解析完成后请输入下面的命令完成验证"
|
|
||||||
echo "${HOME}/.acme.sh/acme.sh --renew $domain_str --yes-I-know-dns-manual-mode-enough-go-ahead-please"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
'cloudflare')
|
|
||||||
declare CF_Key
|
|
||||||
declare CF_Email
|
|
||||||
read -p "请输入cloudflare的邮箱:" CF_Email
|
|
||||||
if [[ ! $CF_Email =~ .*@.* ]];then
|
|
||||||
echo "邮箱不合法"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
read -p "请输入cloudflare的密钥:" CF_Key
|
|
||||||
export CF_Key=$CF_Key
|
|
||||||
export CF_Email=$CF_Email
|
|
||||||
eval "${HOME}/.acme.sh/acme.sh --issue $domain_str --dns dns_cf"
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,245 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if ! command -v nginx &> /dev/null; then
|
|
||||||
if [[ -f "/usr/bin/apt-get" ]];then
|
|
||||||
apt-get update -y
|
|
||||||
apt-get install nginx -y
|
|
||||||
elif [[ -f "/usr/bin/apt" ]];then
|
|
||||||
apt update -y
|
|
||||||
apt install nginx -y
|
|
||||||
elif [[ -f "/usr/bin/pacman" ]];then
|
|
||||||
pacman -Syu --noconfirm
|
|
||||||
pacman -Sy --noconfirm nginx
|
|
||||||
else
|
|
||||||
echo "nginx未安装"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare pick
|
|
||||||
echo "========$(basename $0 .sh)========"
|
|
||||||
echo "1.新增站点配置文件"
|
|
||||||
echo "2.查看已有站点配置文件"
|
|
||||||
echo "3.删除站点配置文件"
|
|
||||||
read -p "请选择:" pick
|
|
||||||
case $pick in
|
|
||||||
'1')
|
|
||||||
declare domain
|
|
||||||
read -p "请输入要绑定的域名多个用 空格 隔开:" domain
|
|
||||||
|
|
||||||
declare ssl_certificate
|
|
||||||
declare ssl_certificate_key
|
|
||||||
declare ssl_domain=$(echo "${domain}" | awk '{print $1}')
|
|
||||||
|
|
||||||
echo "ssl证书"
|
|
||||||
echo "1.自动申请(默认)"
|
|
||||||
echo "2.手动输入"
|
|
||||||
read -p "请输入:" pick
|
|
||||||
if [[ $pick == 2 ]]; then
|
|
||||||
echo "证书,默认 ${HOME}/.acme.sh/${ssl_domain}_ecc/fullchain.cer"
|
|
||||||
read -p "请输入证书地址:" ssl_certificate
|
|
||||||
if [[ -z $ssl_certificate ]];then
|
|
||||||
ssl_certificate="${HOME}/.acme.sh/${ssl_domain}_ecc/fullchain.cer"
|
|
||||||
fi
|
|
||||||
echo "密钥,默认 ${HOME}/.acme.sh/${ssl_domain}_ecc/${ssl_domain}.key"
|
|
||||||
|
|
||||||
read -p "请输入密钥地址:" ssl_certificate_key
|
|
||||||
if [[ -z $ssl_certificate_key ]];then
|
|
||||||
ssl_certificate_key="${HOME}/.acme.sh/${ssl_domain}_ecc/${ssl_domain}.key"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "1.nginx(默认)"
|
|
||||||
read -p "请选择:" pick
|
|
||||||
bash "$(dirname $0)/acme/apply" "nginx" "${domain}"
|
|
||||||
ssl_certificate="${HOME}/.acme.sh/${ssl_domain}_ecc/fullchain.cer"
|
|
||||||
ssl_certificate_key="${HOME}/.acme.sh/${ssl_domain}_ecc/${ssl_domain}.key"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
declare name
|
|
||||||
read -p "请输入配置文件名,默认为域名:" name
|
|
||||||
if [[ -z $name ]]; then
|
|
||||||
name=$ssl_domain
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "工作方式"
|
|
||||||
echo "1.反向代理(默认)"
|
|
||||||
echo "2.静态文件"
|
|
||||||
read -p "请选择:" pick
|
|
||||||
declare path
|
|
||||||
if [[ $pick == 2 ]]; then
|
|
||||||
read -p "请输入要代理的站点路径" path
|
|
||||||
cat > "/etc/nginx/sites-available/${name}.conf" << EOF
|
|
||||||
server {
|
|
||||||
listen 443 ssl http2; # 监听 443 端口并启用 SSL 和 HTTP/2
|
|
||||||
server_name ${domain}; # 替换为你的域名
|
|
||||||
|
|
||||||
# SSL 证书配置
|
|
||||||
ssl_certificate ${ssl_certificate}; # 证书文件路径
|
|
||||||
ssl_certificate_key ${ssl_certificate_key}; # 证书密钥文件路径
|
|
||||||
ssl_protocols TLSv1.2 TLSv1.3; # 仅使用安全的 TLS 协议版本
|
|
||||||
ssl_ciphers HIGH:!aNULL:!MD5; # 安全的密码套件
|
|
||||||
ssl_prefer_server_ciphers on; # 优先使用服务器的密码套件
|
|
||||||
ssl_session_cache shared:SSL:10m;
|
|
||||||
ssl_session_timeout 10m;
|
|
||||||
|
|
||||||
# HSTS(HTTP 严格传输安全)强制浏览器使用 HTTPS
|
|
||||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
||||||
|
|
||||||
# 设置文件传输的最大大小
|
|
||||||
client_max_body_size 100M; # 上传文件最大大小 (例如 100MB)
|
|
||||||
proxy_max_temp_file_size 1024m; # 代理最大临时文件大小
|
|
||||||
|
|
||||||
# 超时与缓冲设置
|
|
||||||
client_body_timeout 60s; # 等待客户端发送请求主体的超时时间
|
|
||||||
client_header_timeout 60s; # 等待客户端发送请求头的超时时间
|
|
||||||
send_timeout 60s; # 发送响应的超时时间
|
|
||||||
client_body_buffer_size 128k; # 上传缓冲区大小
|
|
||||||
proxy_buffer_size 4k; # 设置代理服务器响应的缓冲区大小
|
|
||||||
proxy_buffers 8 16k; # 代理服务器的缓冲区数和大小
|
|
||||||
proxy_busy_buffers_size 64k; # 忙碌代理缓冲区大小
|
|
||||||
large_client_header_buffers 4 16k; # 设置较大的客户端头部缓冲区,防止上传大文件时出现 413 错误
|
|
||||||
|
|
||||||
# 静态文件目录
|
|
||||||
root ${path};
|
|
||||||
index index.html index.htm;
|
|
||||||
|
|
||||||
# 日志
|
|
||||||
access_log /var/log/nginx/example.com_access.log;
|
|
||||||
error_log /var/log/nginx/example.com_error.log;
|
|
||||||
|
|
||||||
# 默认处理
|
|
||||||
location / {
|
|
||||||
try_files \$uri \$uri/ =404;
|
|
||||||
}
|
|
||||||
|
|
||||||
# 防止访问隐藏文件(如 .git)
|
|
||||||
location ~ /\. {
|
|
||||||
deny all;
|
|
||||||
}
|
|
||||||
|
|
||||||
# 错误页面配置
|
|
||||||
error_page 404 /404.html;
|
|
||||||
location = /404.html {
|
|
||||||
root /var/www/example.com/html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# HTTP 到 HTTPS 重定向
|
|
||||||
server {
|
|
||||||
listen 80; # 监听 80 端口
|
|
||||||
server_name ${domain};
|
|
||||||
|
|
||||||
# 将所有 HTTP 请求重定向到 HTTPS
|
|
||||||
return 301 https://\$host\$request_uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
EOF
|
|
||||||
else
|
|
||||||
read -p "请输入后端服务器的地址,如果只输入数字代表端口:" path
|
|
||||||
if [[ $path =~ [0-9]+ ]]; then
|
|
||||||
path="http://127.0.0.1:${path}"
|
|
||||||
fi
|
|
||||||
cat > "/etc/nginx/sites-available/${name}.conf" << EOF
|
|
||||||
server {
|
|
||||||
listen 443 ssl http2; # 监听 443 端口,并启用 HTTP/2
|
|
||||||
server_name ${domain}; # 替换为你的域名
|
|
||||||
|
|
||||||
# SSL 证书配置
|
|
||||||
ssl_certificate ${ssl_certificate}; # 证书文件路径
|
|
||||||
ssl_certificate_key ${ssl_certificate_key}; # 证书密钥文件路径
|
|
||||||
ssl_protocols TLSv1.2 TLSv1.3; # 使用安全的 TLS 协议版本
|
|
||||||
ssl_ciphers HIGH:!aNULL:!MD5; # 安全密码套件
|
|
||||||
ssl_prefer_server_ciphers on;
|
|
||||||
|
|
||||||
# 启用 SSL session 缓存和超时设置
|
|
||||||
ssl_session_cache shared:SSL:10m;
|
|
||||||
ssl_session_timeout 10m;
|
|
||||||
|
|
||||||
# 强制使用 HTTPS (HSTS)
|
|
||||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
||||||
|
|
||||||
# 日志设置
|
|
||||||
access_log /var/log/nginx/${name}_access.log;
|
|
||||||
error_log /var/log/nginx/${name}_error.log;
|
|
||||||
|
|
||||||
# 错误页面配置
|
|
||||||
error_page 404 /404.html;
|
|
||||||
location = /404.html {
|
|
||||||
root /var/www/example.com/html;
|
|
||||||
}
|
|
||||||
|
|
||||||
# 设置文件传输的最大大小
|
|
||||||
client_max_body_size 100M; # 上传文件最大大小 (例如 100MB)
|
|
||||||
proxy_max_temp_file_size 1024m; # 代理最大临时文件大小
|
|
||||||
|
|
||||||
# 超时与缓冲设置
|
|
||||||
client_body_timeout 60s; # 等待客户端发送请求主体的超时时间
|
|
||||||
client_header_timeout 60s; # 等待客户端发送请求头的超时时间
|
|
||||||
send_timeout 60s; # 发送响应的超时时间
|
|
||||||
client_body_buffer_size 128k; # 上传缓冲区大小
|
|
||||||
proxy_buffer_size 4k; # 设置代理服务器响应的缓冲区大小
|
|
||||||
proxy_buffers 8 16k; # 代理服务器的缓冲区数和大小
|
|
||||||
proxy_busy_buffers_size 64k; # 忙碌代理缓冲区大小
|
|
||||||
large_client_header_buffers 4 16k; # 设置较大的客户端头部缓冲区,防止上传大文件时出现 413 错误
|
|
||||||
|
|
||||||
# 反向代理到后台应用 (常规 HTTP/HTTPS)
|
|
||||||
location / {
|
|
||||||
proxy_pass ${path}; # 反向代理到后端应用服务器
|
|
||||||
proxy_set_header Host \$host; # 保持原始主机头
|
|
||||||
proxy_set_header X-Real-IP \$remote_addr; # 传递客户端的真实 IP
|
|
||||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; # 传递代理链中的 IP
|
|
||||||
proxy_set_header X-Forwarded-Proto \$scheme; # 传递协议(HTTP 或 HTTPS)
|
|
||||||
|
|
||||||
# 防止后端服务器返回不安全的内容
|
|
||||||
proxy_redirect off;
|
|
||||||
|
|
||||||
# 超时时间配置
|
|
||||||
proxy_connect_timeout 60s;
|
|
||||||
proxy_send_timeout 60s;
|
|
||||||
proxy_read_timeout 60s;
|
|
||||||
send_timeout 60s;
|
|
||||||
}
|
|
||||||
|
|
||||||
# WebSocket 反向代理到后台应用
|
|
||||||
location /ws {
|
|
||||||
proxy_pass ${path}; # 反向代理到 WebSocket 应用服务器
|
|
||||||
proxy_http_version 1.1; # WebSocket 必须使用 HTTP 1.1
|
|
||||||
proxy_set_header Upgrade \$http_upgrade; # 升级请求头,用于 WebSocket
|
|
||||||
proxy_set_header Connection "Upgrade"; # 持久连接,保持 WebSocket 连接
|
|
||||||
proxy_set_header Host \$host; # 保持原始主机头
|
|
||||||
proxy_set_header X-Real-IP \$remote_addr; # 传递客户端的真实 IP
|
|
||||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; # 传递代理链中的 IP
|
|
||||||
proxy_set_header X-Forwarded-Proto \$scheme; # 传递协议(HTTP 或 HTTPS)
|
|
||||||
|
|
||||||
# 超时时间配置 (WebSocket 是长连接)
|
|
||||||
proxy_connect_timeout 60s;
|
|
||||||
proxy_send_timeout 60s;
|
|
||||||
proxy_read_timeout 3600s; # WebSocket 长连接需较长读超时
|
|
||||||
send_timeout 60s;
|
|
||||||
}
|
|
||||||
|
|
||||||
# 错误页面配置
|
|
||||||
error_page 502 /502.html;
|
|
||||||
location = /502.html {
|
|
||||||
root /usr/share/nginx/html; # 错误页面路径
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# HTTP 到 HTTPS 重定向
|
|
||||||
server {
|
|
||||||
listen 80; # 监听 HTTP 80 端口
|
|
||||||
server_name ${domain}; # 替换为你的域名
|
|
||||||
|
|
||||||
# 将所有 HTTP 请求重定向到 HTTPS
|
|
||||||
return 301 https://\$host\$request_uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
ln -s "/etc/nginx/sites-available/${name}.conf" "/etc/nginx/sites-enabled" &> /dev/null
|
|
||||||
nginx -s reload &> /dev/null
|
|
||||||
echo "配置完成"
|
|
||||||
;;
|
|
||||||
esac
|
|
@ -1,20 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
declare path_local=$1
|
|
||||||
|
declare path_script=$1
|
||||||
declare pick
|
declare pick
|
||||||
declare file_name
|
echo "========Automation========"
|
||||||
echo "========$(basename $0 .sh)========"
|
|
||||||
declare print_number=0
|
declare print_number=0
|
||||||
declare -a print_array
|
declare -a print_array
|
||||||
for i in "${path_local}"/*;do
|
for i in "${path_script}/Config/Automation"/*;do
|
||||||
file_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
|
|
||||||
if [[ $file_name == "test" || $file_name == "menu" ]]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
print_number=$((print_number + 1))
|
print_number=$((print_number + 1))
|
||||||
print_array[$print_number]=$file_name
|
print_array[$print_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
|
||||||
echo "${print_number}.${file_name}"
|
echo "${print_number}.${print_array[$print_number]}"
|
||||||
done
|
done
|
||||||
echo "输入其他任意返回主页"
|
echo "输入其他任意返回主页"
|
||||||
|
echo "========Automation========"
|
||||||
read -p "请输入:" pick
|
read -p "请输入:" pick
|
||||||
|
|
||||||
if [[ ! ${pick} =~ [1-$print_number] ]];then
|
if [[ ! ${pick} =~ [1-$print_number] ]];then
|
||||||
@ -52,17 +49,13 @@ if [[ "$cron" == '* * * * * ' ]];then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "${path_local}/${print_array[pick]}.sh" ]];then
|
bash "${path_script}/Config/Automation/${print_array[pick]}.sh" "$path"
|
||||||
echo "该路径文件已经存在"
|
|
||||||
fi
|
|
||||||
|
|
||||||
bash "${path_local}/${print_array[pick]}.sh" "$path"
|
|
||||||
|
|
||||||
chmod +x "${path}/${print_array[pick]}.sh"
|
chmod +x "${path}/${print_array[pick]}.sh"
|
||||||
declare cron_job="${cron} ${path}/${print_array[pick]}.sh"
|
declare cron_job="${cron} ${path}/${print_array[pick]}.sh"
|
||||||
(crontab -l 2>/dev/null | grep -v "${print_array[pick]}.sh") | crontab -
|
(crontab -l 2>/dev/null | grep -v "${print_array[pick]}.sh") | sudo crontab -
|
||||||
(crontab -l 2>/dev/null; echo "$cron_job") | crontab -
|
(crontab -l 2>/dev/null; echo "$cron_job") | sudo crontab -
|
||||||
|
|
||||||
systemctl restart cron 2>> /dev/null || echo "自动任务重启失败"
|
sudo systemctl restart cron 2>> /dev/null || echo "自动任务重启失败"
|
||||||
|
|
||||||
echo "配置完成"
|
echo "配置完成"
|
98
Menus/Docker.sh
Normal file
98
Menus/Docker.sh
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
declare path_script=$1
|
||||||
|
|
||||||
|
if ! command -v docker &> /dev/null; then
|
||||||
|
echo "docker未安装"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
declare pick_array
|
||||||
|
declare pick_number=6
|
||||||
|
declare pick
|
||||||
|
|
||||||
|
echo "========Docker========"
|
||||||
|
echo "1.换源"
|
||||||
|
echo "2.清除所有未使用镜像"
|
||||||
|
echo "-----一键搭建软件-----"
|
||||||
|
for i in "${path_script}/Config/Docker"/*;do
|
||||||
|
pick_number=$((pick_number + 1))
|
||||||
|
pick_array[$pick_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
|
||||||
|
echo "${pick_number}.${pick_array[$pick_number]}"
|
||||||
|
done
|
||||||
|
echo "-----一键搭建软件-----"
|
||||||
|
echo "任意输入返回主菜单"
|
||||||
|
echo "========Docker========"
|
||||||
|
read -p "请输入要使用的功能:" pick
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
if [[ $pick == '1' ]];then
|
||||||
|
declare -A img_dick
|
||||||
|
declare -a img_number
|
||||||
|
declare img_pick=0
|
||||||
|
img_dick['Daocloud(默认)']='https://docker.m.daocloud.io'
|
||||||
|
|
||||||
|
for i in "${!img_dick[@]}";
|
||||||
|
do
|
||||||
|
img_pick=$(( img_pick+1 ))
|
||||||
|
img_number[$img_pick]=$i
|
||||||
|
echo "${img_pick}.${i}"
|
||||||
|
done
|
||||||
|
read -p "请输入要选择的镜像,也可直接输入镜像网站:" img_pick
|
||||||
|
if [[ -z $img_pick ]];then
|
||||||
|
declare url='https://docker.m.daocloud.io'
|
||||||
|
elif [[ $img_pick =~ ^[http] ]];then
|
||||||
|
declare url=$img_pick
|
||||||
|
elif [[ ${img_pick} -le 0 || ${img_pick} -ge ${!img_dick[*]} ]];then
|
||||||
|
img_pick=${img_number[$img_pick]}
|
||||||
|
declare url=${img_dick[$img_pick]}
|
||||||
|
else
|
||||||
|
echo "输入错误"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
sudo echo "{\"registry-mirrors\": [\"${url}\"]}" > "/etc/docker/daemon.json"
|
||||||
|
sudo systemctl restart docker 2>> /dev/null|| echo "docker 重启失败"
|
||||||
|
echo "换源成功"
|
||||||
|
|
||||||
|
elif [[ $pick == '2' ]];then
|
||||||
|
sudo docker system prune -af
|
||||||
|
echo "清理完成"
|
||||||
|
elif [[ "${pick}" -gt "$((${pick_number}-${#pick_array[*]}))" && "${pick}" -le "${pick_number}" ]];then
|
||||||
|
declare file_path
|
||||||
|
read -p "请输入软件储存位置,默认 /var/www/${pick_array[${pick}]} :" file_path
|
||||||
|
if [[ -z ${file_path} ]];then
|
||||||
|
file_path="/var/www/${pick_array[${pick}]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d "$file_path" ]];then
|
||||||
|
sudo mkdir -p "$file_path" || { echo "目录创建失败"; exit 1; }
|
||||||
|
elif [[ ! -z "$(find "$file_path" -mindepth 1 -print -quit)" ]];then
|
||||||
|
echo "该目录存有文件"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
declare dport=$(($RANDOM % 9000 + 1000))
|
||||||
|
|
||||||
|
while ss -tuln | grep $dport &> /dev/null
|
||||||
|
do
|
||||||
|
dport=$(($RANDOM % 9000 + 1000))
|
||||||
|
done
|
||||||
|
|
||||||
|
declare port
|
||||||
|
read -p "请输入访问端口,默认 $dport :" port
|
||||||
|
|
||||||
|
if [[ -z $port ]];then
|
||||||
|
port=$dport
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ss -tuln | grep $port &> /dev/null;then
|
||||||
|
echo "端口已被占用"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
bash "${path_script}/Config/Docker/${pick_array[${pick}]}.sh" "$file_path" "$port"
|
||||||
|
echo "${pick_array[${pick}]}安装完成,访问端口${port}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
182
Menus/Login.sh
Normal file
182
Menus/Login.sh
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
declare pick
|
||||||
|
echo "========Login========"
|
||||||
|
echo "1.修改root密码"
|
||||||
|
echo "2.ssh安装密钥"
|
||||||
|
echo "3.新建用户"
|
||||||
|
echo "4.管理ssh登录方式"
|
||||||
|
echo "5.更换ssh端口"
|
||||||
|
echo "任意输入返回主菜单"
|
||||||
|
echo "========Login========"
|
||||||
|
read -p "请输入要使用的功能:" pick
|
||||||
|
|
||||||
|
|
||||||
|
case $pick in
|
||||||
|
1)
|
||||||
|
declare password
|
||||||
|
read -p "请输入root密码:" password
|
||||||
|
echo "root:$password" |sudo chpasswd
|
||||||
|
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
|
||||||
|
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
||||||
|
sudo systemctl restart sshd.service
|
||||||
|
echo "修改成功当前root密码为:$password"
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
declare key
|
||||||
|
echo "请输入公钥或文件路径:"
|
||||||
|
echo "默认:$HOME/.ssh/id_rsa.pub"
|
||||||
|
read -p "回车默认:" key
|
||||||
|
|
||||||
|
if [[ -z $key ]];then
|
||||||
|
key="$HOME/.ssh/id_rsa.pub"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f $key ]];then
|
||||||
|
key=$(cat "$key")
|
||||||
|
fi
|
||||||
|
if [[ ! $key =~ ^ssh-(rsa|ecdsa-sha2-nistp[0-9]+|ed25519|dss) ]];then
|
||||||
|
echo "公钥不合法"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$HOME/.ssh"
|
||||||
|
echo "$key" > "$HOME/.ssh/authorized_keys"
|
||||||
|
|
||||||
|
chmod 600 "$HOME/.ssh/authorized_keys"
|
||||||
|
chmod 700 "$HOME/.ssh"
|
||||||
|
|
||||||
|
sudo sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
declare pick2
|
||||||
|
echo "是否关闭密码登录:"
|
||||||
|
read -p "输入 n 取消关闭:" pick2
|
||||||
|
|
||||||
|
if [[ ! $pick2 =~ [Nn] ]];then
|
||||||
|
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/g' /etc/ssh/sshd_config
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
sudo systemctl restart sshd.service
|
||||||
|
|
||||||
|
echo "密钥安装完成"
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
declare user_name
|
||||||
|
read -p "请输入你想创建的用户名:" user_name
|
||||||
|
|
||||||
|
if id "$user_name" &>/dev/null; then
|
||||||
|
echo "用户 $user_name 已存在。"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
useradd -m -s /bin/bash "$user_name"
|
||||||
|
|
||||||
|
if grep -q "^$user_name " /etc/sudoers;then
|
||||||
|
sudo sed -i "s/^#\?$user_name.*/lsy ALL=(ALL) NOPASSWD: ALL/g" /etc/sudoers
|
||||||
|
else
|
||||||
|
sudo echo "lsy ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
declare pick
|
||||||
|
echo "用户登录方式"
|
||||||
|
echo "y.密码登录"
|
||||||
|
echo "n.使用root用户公钥"
|
||||||
|
read -p "默认y,请输入:" pick
|
||||||
|
if [[ ! $pick =~ [Nn] ]];then
|
||||||
|
declare password
|
||||||
|
read -p "请输入密码:" password
|
||||||
|
echo "$user_name:$password" |sudo chpasswd
|
||||||
|
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
|
||||||
|
echo "创建成功"
|
||||||
|
echo "账号:$user_name"
|
||||||
|
echo "密码:$password"
|
||||||
|
else
|
||||||
|
sudo sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
||||||
|
su "$user_name" -c "mkdir -p '/home/$user_name/.ssh'"
|
||||||
|
sudo cp "/root/.ssh/authorized_keys" "/home/$user_name/.ssh/authorized_keys"
|
||||||
|
sudo chown lsy:lsy "/home/$user_name/.ssh/authorized_keys"
|
||||||
|
su "$user_name" -c "chmod 600 '/home/$user_name/.ssh/authorized_keys'"
|
||||||
|
su "$user_name" -c "chmod 700 '/home/$user_name/.ssh/'"
|
||||||
|
|
||||||
|
echo "创建成功"
|
||||||
|
echo "账号:$user_name"
|
||||||
|
echo "密钥登录"
|
||||||
|
fi
|
||||||
|
|
||||||
|
declare pick2
|
||||||
|
echo "是否关闭root登录"
|
||||||
|
read -p "输入 n 取消关闭:" pick2
|
||||||
|
|
||||||
|
if [[ ! $pick2 =~ [Nn] ]];then
|
||||||
|
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/g' /etc/ssh/sshd_config
|
||||||
|
echo "root用户登录已关闭"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo systemctl restart sshd.service
|
||||||
|
|
||||||
|
;;
|
||||||
|
4)
|
||||||
|
declare pick_root
|
||||||
|
declare pick2_key
|
||||||
|
declare pick2_password
|
||||||
|
echo "是否关闭root登录"
|
||||||
|
read -p "输入 n 关闭:" pick_root
|
||||||
|
echo "是否关闭密码登录"
|
||||||
|
read -p "输入 n 关闭:" pick2_password
|
||||||
|
echo "是否关闭密钥登录"
|
||||||
|
read -p "输入 n 关闭:" pick2_key
|
||||||
|
|
||||||
|
if [[ ! $pick_root =~ [Nn] ]];then
|
||||||
|
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
|
||||||
|
echo "root用户登录:开启"
|
||||||
|
else
|
||||||
|
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/g' /etc/ssh/sshd_config
|
||||||
|
echo "root用户登录:关闭"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! $pick2_password =~ [Nn] ]];then
|
||||||
|
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
||||||
|
echo "密码登录:开启"
|
||||||
|
else
|
||||||
|
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/g' /etc/ssh/sshd_config
|
||||||
|
echo "密码登录:关闭"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! $pick2_key =~ [Nn] ]];then
|
||||||
|
sudo sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
||||||
|
echo "密钥登录:开启"
|
||||||
|
else
|
||||||
|
sudo sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication no/g' /etc/ssh/sshd_config
|
||||||
|
echo "密钥登录:关闭"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo systemctl restart sshd.service
|
||||||
|
;;
|
||||||
|
5)
|
||||||
|
read -p "请输入需要修改的端口号(默认22): " port_number
|
||||||
|
|
||||||
|
if [[ -z $port_number ]];then
|
||||||
|
port_number=22
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ $port_number =~ ^[0-9]+$ ]] || ! ((port_number > 0 && port_number < 65535)); then
|
||||||
|
echo "端口不合法"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if sudo lsof -i :$port_number -t >/dev/null; then
|
||||||
|
echo "$port_number 端口已被占用"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo sed -i "s/^#\?Port.*/Port $port_number/g" /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
sudo systemctl restart sshd.service
|
||||||
|
|
||||||
|
echo "端口已经修改为$port_number,记得防火墙放行"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
clear
|
||||||
|
esac
|
||||||
|
|
29
Menus/Other.sh
Normal file
29
Menus/Other.sh
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
declare pick
|
||||||
|
declare path_script=$1
|
||||||
|
echo "========Other========"
|
||||||
|
echo "1.开启BBR"
|
||||||
|
echo "2.更换系统语言"
|
||||||
|
echo "3.申请SSL证书"
|
||||||
|
echo "输入其他任意返回主页"
|
||||||
|
echo "========Other========"
|
||||||
|
read -p "请输入:" pick
|
||||||
|
|
||||||
|
case "$pick" in
|
||||||
|
'1')
|
||||||
|
declare version=$(uname -r | awk -F "." '{print $1}')
|
||||||
|
if ! [[ $version -ge 5 ]];then
|
||||||
|
echo "系统内核版本过低"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
grep -q "net.core.default_qdisc=fq" "/etc/sysctl.conf" || echo 'net.core.default_qdisc=fq' | sudo tee -a "/etc/sysctl.conf"
|
||||||
|
grep -q "net.ipv4.tcp_congestion_control=bbr" "/etc/sysctl.conf" || echo 'net.ipv4.tcp_congestion_control=bbr' | sudo tee -a "/etc/sysctl.conf"
|
||||||
|
sudo sysctl -p || echo "bbr 开启失败"
|
||||||
|
sysctl net.ipv4.tcp_available_congestion_control | grep bbr && echo "bbr 开启成功"
|
||||||
|
;;
|
||||||
|
'2')
|
||||||
|
bash "${path_script}/Config/Other/Language.sh"
|
||||||
|
;;
|
||||||
|
'3')
|
||||||
|
bash "${path_script}/Config/Other/Acme.sh"
|
||||||
|
;;
|
||||||
|
esac
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
echo "正在更新系统包管理器"
|
|
||||||
declare install_str
|
declare install_str
|
||||||
declare version="$(cat /etc/os-release | grep "^ID" | awk -F '=' '{print $2}')"
|
declare version="$(cat /etc/os-release | grep "^ID" | awk -F '=' '{print $2}')"
|
||||||
declare status=0
|
declare status=0
|
||||||
@ -8,15 +8,15 @@ declare pkg
|
|||||||
if [[ -f "/usr/bin/apt-get" ]];then
|
if [[ -f "/usr/bin/apt-get" ]];then
|
||||||
pkg='apt-get'
|
pkg='apt-get'
|
||||||
install_str+="${pkg} install -y"
|
install_str+="${pkg} install -y"
|
||||||
apt-get update -y
|
sudo apt-get update -y
|
||||||
elif [[ -f "/usr/bin/apt" ]];then
|
elif [[ -f "/usr/bin/apt" ]];then
|
||||||
pkg='apt'
|
pkg='apt'
|
||||||
install_str+="${pkg} install -y"
|
install_str+="${pkg} install -y"
|
||||||
apt update -y
|
sudo apt update -y
|
||||||
elif [[ -f "/usr/bin/pacman" ]];then
|
elif [[ -f "/usr/bin/pacman" ]];then
|
||||||
pkg='pacman'
|
pkg='pacman'
|
||||||
install_str+="${pkg} -Sy --noconfirm"
|
install_str+="${pkg} -Sy --noconfirm"
|
||||||
pacman -Syu --noconfirm
|
sudo pacman -Syu --noconfirm
|
||||||
else
|
else
|
||||||
echo "暂不支持该系统一键安装常用软件"
|
echo "暂不支持该系统一键安装常用软件"
|
||||||
exit
|
exit
|
||||||
@ -24,55 +24,35 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
declare pick
|
declare pick
|
||||||
declare soft_number
|
|
||||||
declare -A soft_dick
|
|
||||||
declare -a soft_array
|
declare -a soft_array
|
||||||
soft_dick['git']=0
|
soft_array[0]='git'
|
||||||
soft_dick['vim']=0
|
soft_array[1]='vim'
|
||||||
soft_dick['wget']=0
|
soft_array[2]='wget'
|
||||||
soft_dick['curl']=0
|
soft_array[3]='curl'
|
||||||
soft_dick['sudo']=0
|
soft_array[4]='ssh'
|
||||||
soft_dick['ssh']=0
|
soft_array[5]='zsh'
|
||||||
soft_dick['zsh']=0
|
soft_array[6]='zip'
|
||||||
soft_dick['zsh-beautify']=1
|
|
||||||
soft_dick['docker']=1
|
|
||||||
soft_dick['x-cmd']=1
|
|
||||||
|
|
||||||
echo "========$(basename $0 .sh)========"
|
echo "======一键安装常用软件======"
|
||||||
for i in "${!soft_dick[@]}" ; do
|
for i in "${soft_array[@]}"
|
||||||
soft_number=$(( soft_number+1 ))
|
do
|
||||||
soft_array[$soft_number]=$i
|
read -p "是否安装${i},输入 n 取消安装:" pick
|
||||||
echo "${soft_number}.${i}"
|
if [[ ! $pick =~ [Nn] ]];then
|
||||||
done
|
install_str+=" ${i}"
|
||||||
echo "请输入需要安装的软件序号(默认安装全部)"
|
|
||||||
read -p "用 空格 隔开:" pick
|
|
||||||
|
|
||||||
if [[ -z $pick ]];then
|
|
||||||
for (( i = 1; i <= ${#soft_dick[@]}; i++ )); do
|
|
||||||
if [[ $i != 1 ]]; then
|
|
||||||
pick="$pick $i"
|
|
||||||
else
|
|
||||||
pick="$i"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
elif ! [[ $pick -ge 1 && $pick -le ${#soft_dick[@]} || $pick =~ ([1-${#soft_dick[@]}][\s]?)+ ]];then
|
|
||||||
echo "输入错误"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
for i in $pick ; do
|
|
||||||
if [[ ${soft_dick[${soft_array[$i]}]} == 0 ]]; then
|
|
||||||
eval "$install_str ${soft_array[$i]}"
|
|
||||||
else
|
|
||||||
soft_dick[${soft_array[$i]}]=2
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ${soft_dick['x-cmd']} == 2 ]];then
|
|
||||||
eval "$(curl https://get.x-cmd.com)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ${soft_dick['docker']} == 2 ]];then
|
declare pick_x
|
||||||
|
read -p "是否安装x-cmd,输入 n 取消安装:" pick_x
|
||||||
|
|
||||||
|
declare pick_zsh
|
||||||
|
read -p "是否一键美化zsh,输入 n 取消:" pick_zsh
|
||||||
|
|
||||||
|
declare pick_docker
|
||||||
|
read -p "是否安装docker,输入 n 取消:" pick_docker
|
||||||
|
|
||||||
|
if [[ ! $pick_docker =~ [Nn] ]];then
|
||||||
declare -A docker_imgs
|
declare -A docker_imgs
|
||||||
docker_imgs['官方']='https://download.docker.com'
|
docker_imgs['官方']='https://download.docker.com'
|
||||||
docker_imgs['中国科技大学(默认)']='https://mirrors.ustc.edu.cn/docker-ce'
|
docker_imgs['中国科技大学(默认)']='https://mirrors.ustc.edu.cn/docker-ce'
|
||||||
@ -88,7 +68,7 @@ if [[ ${soft_dick['docker']} == 2 ]];then
|
|||||||
docker_img_number[$docker_img_number_pick]=$i
|
docker_img_number[$docker_img_number_pick]=$i
|
||||||
echo "${docker_img_number_pick}.${i}"
|
echo "${docker_img_number_pick}.${i}"
|
||||||
done
|
done
|
||||||
read -p "请选择Docker镜像站:" docker_img_number_pick
|
read -p "请输入需要选择的镜像站:" docker_img_number_pick
|
||||||
declare docker_img
|
declare docker_img
|
||||||
if [[ ! $docker_img_number_pick =~ [1-${#docker_imgs[@]}] ]];then
|
if [[ ! $docker_img_number_pick =~ [1-${#docker_imgs[@]}] ]];then
|
||||||
docker_img='https://mirrors.sustc.edu.cn/docker-ce'
|
docker_img='https://mirrors.sustc.edu.cn/docker-ce'
|
||||||
@ -96,30 +76,42 @@ if [[ ${soft_dick['docker']} == 2 ]];then
|
|||||||
docker_img_number_pick=${docker_img_number[$docker_img_number_pick]}
|
docker_img_number_pick=${docker_img_number[$docker_img_number_pick]}
|
||||||
docker_img=${docker_imgs[$docker_img_number_pick]}
|
docker_img=${docker_imgs[$docker_img_number_pick]}
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [[ ! $pick_x =~ [Nn] ]];then
|
||||||
|
eval "$(curl https://get.x-cmd.com)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
eval "sudo ${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
|
||||||
${pkg} update
|
sudo ${pkg} update
|
||||||
${pkg} install ca-certificates curl -y
|
sudo ${pkg} install ca-certificates curl -y
|
||||||
install -m 0755 -d /etc/apt/keyrings
|
sudo install -m 0755 -d /etc/apt/keyrings
|
||||||
curl -fsSL "${docker_img}/linux/${version}/gpg" -o /etc/apt/keyrings/docker.asc
|
sudo curl -fsSL "${docker_img}/linux/${version}/gpg" -o /etc/apt/keyrings/docker.asc
|
||||||
chmod a+r /etc/apt/keyrings/docker.asc
|
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
||||||
echo \
|
echo \
|
||||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] ${docker_img}/linux/${version} \
|
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] ${docker_img}/linux/${version} \
|
||||||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
||||||
tee /etc/apt/sources.list.d/docker.list > /dev/null
|
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
${pkg} update
|
sudo ${pkg} update
|
||||||
${pkg} install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
|
sudo ${pkg} install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
|
||||||
elif [[ ${pkg} == 'pacman' ]];then
|
elif [[ ${pkg} == 'arch' ]];then
|
||||||
pacman -Sy docker --noconfirm
|
sudo pacman -Sy docker --noconfirm
|
||||||
systemctl start docker.service
|
sudo systemctl start docker.service
|
||||||
systemctl enable docker.service
|
sudo systemctl enable docker.service
|
||||||
usermod -aG docker $USER
|
sudo usermod -aG docker $USER
|
||||||
newgrp docker
|
newgrp docker
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ! $pick_zsh =~ [Nn] ]];then
|
||||||
if [[ ${soft_dick['zsh-beautify']} == 2 ]];then
|
|
||||||
curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sed 's/read -r opt//g'| sed 's/exec zsh -l//g'| sh
|
curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sed 's/read -r opt//g'| sed 's/exec zsh -l//g'| sh
|
||||||
while [[ ! -d "$HOME/.oh-my-zsh" ]]; do
|
while [[ ! -d "$HOME/.oh-my-zsh" ]]; do
|
||||||
sleep 3
|
sleep 3
|
||||||
@ -127,8 +119,8 @@ if [[ ${soft_dick['zsh-beautify']} == 2 ]];then
|
|||||||
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
|
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-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
|
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
|
||||||
sed -i 's/^#\?ZSH_THEME.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/g' ~/.zshrc
|
sudo sed -i 's/^#\?ZSH_THEME.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/g' ~/.zshrc
|
||||||
sed -i 's/^#\?plugins.*/plugins=(zsh-syntax-highlighting zsh-autosuggestions command-not-found)/g' ~/.zshrc
|
sudo sed -i 's/^#\?plugins.*/plugins=(zsh-syntax-highlighting zsh-autosuggestions command-not-found)/g' ~/.zshrc
|
||||||
chsh -s /bin/zsh
|
chsh -s /bin/zsh
|
||||||
exec zsh -l
|
exec zsh -l
|
||||||
fi
|
fi
|
@ -12,13 +12,14 @@ sources_dick['网易云']='https://mirrors.163.com'
|
|||||||
|
|
||||||
declare -a pcik_array
|
declare -a pcik_array
|
||||||
declare pick=0
|
declare pick=0
|
||||||
echo "========$(basename $0 .sh)========"
|
echo "========Sources========"
|
||||||
for i in "${!sources_dick[@]}";
|
for i in "${!sources_dick[@]}";
|
||||||
do
|
do
|
||||||
pick=$(( pick+1 ))
|
pick=$(( pick+1 ))
|
||||||
pcik_array[$pick]=$i
|
pcik_array[$pick]=$i
|
||||||
echo "${pick}.${i}"
|
echo "${pick}.${i}"
|
||||||
done
|
done
|
||||||
|
echo "========Sources========"
|
||||||
read -p "请输入:" pick
|
read -p "请输入:" pick
|
||||||
|
|
||||||
|
|
||||||
@ -39,8 +40,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-updates main contrib non-free non-free-firmware
|
||||||
deb ${url}/debian/ bookworm-backports main contrib non-free non-free-firmware
|
deb ${url}/debian/ bookworm-backports main contrib non-free non-free-firmware
|
||||||
EOF
|
EOF
|
||||||
apt update -y
|
sudo apt update -y
|
||||||
apt-get update -y
|
sudo apt-get update -y
|
||||||
status=1
|
status=1
|
||||||
;;
|
;;
|
||||||
'bullseye')
|
'bullseye')
|
||||||
@ -49,18 +50,18 @@ deb ${url}/debian/ bullseye main contrib non-free
|
|||||||
deb ${url}/debian/ bullseye-updates main contrib non-free
|
deb ${url}/debian/ bullseye-updates main contrib non-free
|
||||||
deb ${url}/debian/ bullseye-backports main contrib non-free
|
deb ${url}/debian/ bullseye-backports main contrib non-free
|
||||||
EOF
|
EOF
|
||||||
apt update -y
|
sudo apt update -y
|
||||||
apt-get update -y
|
sudo apt-get update -y
|
||||||
status=1
|
status=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$system" in
|
case "$system" in
|
||||||
'arch')
|
'arch')
|
||||||
pacman -Sy pacman-key --noconfirm
|
sudo pacman -Sy pacman-key --noconfirm
|
||||||
sed -i '/^Server.*/d' "/etc/pacman.conf"
|
sed -i '/^Server.*/d' "/etc/pacman.conf"
|
||||||
echo "Server = ${url}/archlinuxcn/\$arch"
|
echo "Server = ${url}/archlinuxcn/\$arch"
|
||||||
pacman-key --lsign-key "farseerfc@archlinux.org"
|
sudo pacman-key --lsign-key "farseerfc@archlinux.org"
|
||||||
pacman -Syyu
|
pacman -Syyu
|
||||||
status=1
|
status=1
|
||||||
;;
|
;;
|
||||||
@ -71,8 +72,8 @@ deb ${url}/ubuntu/ ${version}-security main restricted universe multiverse
|
|||||||
deb ${url}/ubuntu/ ${version}-updates main restricted universe multiverse
|
deb ${url}/ubuntu/ ${version}-updates main restricted universe multiverse
|
||||||
deb ${url}/ubuntu/ ${version}-backports main restricted universe multiverse
|
deb ${url}/ubuntu/ ${version}-backports main restricted universe multiverse
|
||||||
EOF
|
EOF
|
||||||
apt update -y
|
sudo apt update -y
|
||||||
apt-get update -y
|
sudo apt-get update -y
|
||||||
status=1
|
status=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
33
Run.sh
Normal file
33
Run.sh
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if ! command -v sudo &> /dev/null; then
|
||||||
|
echo "sudo未安装,部分命令无法正常运行"
|
||||||
|
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 "${path_script}/Menus"/*
|
||||||
|
do
|
||||||
|
pick_number=$((pick_number + 1))
|
||||||
|
pick_array[$pick_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
|
||||||
|
echo "${pick_number}.${pick_array[$pick_number]}"
|
||||||
|
done
|
||||||
|
echo "======Linux工具箱======"
|
||||||
|
read -p "请输入要使用的功能:" pick
|
||||||
|
if [[ "${pick}" -gt 0 && "${pick}" -le "${#pick_array[*]}" ]];then
|
||||||
|
clear
|
||||||
|
bash "${path_script}/Menus/${pick_array[$pick]}.sh" "$path_script"
|
||||||
|
else
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
63
run.sh
63
run.sh
@ -1,63 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [[ $UID != 0 ]]; then
|
|
||||||
echo "请以root权限执行该脚本"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare -a pick_array
|
|
||||||
declare pick_number
|
|
||||||
declare pick
|
|
||||||
declare path_script=$(dirname $0)
|
|
||||||
path_script="${path_script}/Config"
|
|
||||||
declare path_local=$path_script
|
|
||||||
declare file_name
|
|
||||||
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
if [[ -e "${path_local}/test.sh" ]]; then
|
|
||||||
bash "${path_local}/test.sh"
|
|
||||||
if [[ $? -eq 1 ]]; then
|
|
||||||
path_local=$path_script
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ -e "${path_local}/menu.sh" ]]; then
|
|
||||||
clear
|
|
||||||
bash "${path_local}/menu.sh" "$path_local"
|
|
||||||
path_local=$path_script
|
|
||||||
fi
|
|
||||||
pick_number=0
|
|
||||||
pick_array=()
|
|
||||||
echo "======$(basename $path_local .sh)======"
|
|
||||||
for i in "${path_local}"/*
|
|
||||||
do
|
|
||||||
file_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
|
|
||||||
if [[ $file_name == "test" ]]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
pick_number=$((pick_number + 1))
|
|
||||||
pick_array[$pick_number]=$file_name
|
|
||||||
echo "${pick_number}.${pick_array[$pick_number]}"
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ $path_local != $path_script ]]; then
|
|
||||||
echo "输入任意返回主页"
|
|
||||||
fi
|
|
||||||
|
|
||||||
read -p "请输入要使用的功能:" pick
|
|
||||||
if [[ "${pick}" =~ [1-${#pick_array[*]}] ]];then
|
|
||||||
clear
|
|
||||||
if [[ -d "${path_local}/${pick_array[$pick]}" ]]; then
|
|
||||||
path_local="${path_local}/${pick_array[$pick]}"
|
|
||||||
elif [[ -e "${path_local}/${pick_array[$pick]}.sh" ]]; then
|
|
||||||
bash "${path_local}/${pick_array[$pick]}.sh"
|
|
||||||
path_local=$path_script
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [[ $path_local == $path_script ]]; then
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
path_local=$path_script
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
|
Loading…
Reference in New Issue
Block a user