重新的每种源的打印,写好docker,正在写alist

This commit is contained in:
lsy 2024-07-24 12:50:44 +08:00
parent 4d6c726209
commit 635d49195f
4 changed files with 114 additions and 25 deletions

View File

@ -1,2 +1,21 @@
#!/bin/bash #!/bin/bash
echo "alist" declare path=$1
declare port=$2
cd $path
cat > "docker-compose.yml" << EOF
version: '3.8'
services:
alist:
image: xhofe/alist:latest
container_name: alist
restart: always
volumes:
- ./:/opt/alist/data
ports:
- "${port}:5244"
EOF
sudo docker compose up -d | "安装失败" $$ exit
declare password=$( docker exec -it alist ./alist admin random )
echo "账号admin"
echo "密码:${password}"
cd - >> /dev/null

View File

@ -11,6 +11,7 @@ declare pick
echo "========Docker========" echo "========Docker========"
echo "1.换源" echo "1.换源"
echo "2.清除所有未使用镜像"
echo "-----一键搭建软件-----" echo "-----一键搭建软件-----"
cd "Config/Docker" cd "Config/Docker"
for i in *;do for i in *;do
@ -24,12 +25,75 @@ echo "任意输入返回主菜单"
echo "========Docker========" echo "========Docker========"
read -p "请输入要使用的功能:" pick read -p "请输入要使用的功能:" pick
clear
if [[ "${pick_number}" -gt 0 && "${pick}" -le "$((${#pick_array[*]}+${pick_number}))" ]];then if [[ $pick == '1' ]];then
clear declare -A img_dick
bash "Config/Docker/${pick_array[${pick}]}.sh" declare -a img_number
else declare img_pick=0
clear img_dick['中国科技技术大学(默认)']='https://docker.mirrors.ustc.edu.cn/'
for i in "${!img_dick[@]}";
do
img_pick=$(( img_pick+1 ))
declare[$img_pick]=$i
echo "${img_pick}.${i}"
done
read -p "请输入要选择的镜像,也可直接输入镜像网站:" img_pick
if [[ -z $img_pick ]];then
declare url='https://docker.mirrors.ustc.edu.cn/'
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
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 Config/Docker/${pick_array[${pick}]}.sh "$file_path" "$port"
echo "访问链接http://127.0.0.1:${port}"
echo "${pick_array[${pick}]}安装完成"
fi fi

View File

@ -55,7 +55,7 @@ if [[ ! $pick_docker =~ [Nn] ]];then
for i in "${!docker_imgs[@]}"; do for i in "${!docker_imgs[@]}"; do
docker_img_number_pick=$((docker_img_number_pick + 1)) docker_img_number_pick=$((docker_img_number_pick + 1))
docker_img_number[$docker_img_number_pick]=$i docker_img_number[$docker_img_number_pick]=$i
echo "${docker_img_number_pick}.${docker_img_number[$docker_img_number_pick]}" echo "${docker_img_number_pick}.${i}"
done done
read -p "请输入需要选择的镜像站:" docker_img_number_pick read -p "请输入需要选择的镜像站:" docker_img_number_pick
declare docker_img declare docker_img

View File

@ -10,37 +10,43 @@ case "$version" in
exit exit
esac esac
declare -A sources_dick
sources_array[1]='http://mirrors.ustc.edu.cn' sources_dick['中国科技技术大学(默认)']='http://mirrors.ustc.edu.cn'
sources_array[2]='https://mirrors.tuna.tsinghua.edu.cn' sources_dick['清华大学']='https://mirrors.tuna.tsinghua.edu.cn'
sources_array[3]='https://mirrors.aliyun.com' sources_dick['阿里云']='https://mirrors.aliyun.com'
declare pick declare -a pcik_array
declare pick=0
echo "========Sources========" echo "========Sources========"
echo "1.中国科技技术大学" for i in "${!sources_dick[@]}";
echo "2.清华大学" do
echo "3.阿里云" pick=$(( pick+1 ))
pcik_array[$pick]=$i
echo "${pick}.${i}"
done
echo "========Sources========" echo "========Sources========"
read -p "请输入(默认1)" pick read -p "请输入" pick
if [[ -z $pick ]];then
pick=1
fi
echo $pick if [[ ${pick} -le 0 || ${pick} -gt ${#sources_dick[*]} ]];then
if ! [[ ${pick} =~ [123] ]];then
echo "输入错误" echo "输入错误"
exit exit
elif [[ -z $pick ]];then
declare url='http://mirrors.ustc.edu.cn'
else
pick=${pcik_array[$pick]}
declare url=${sources_dick[$pick]}
fi fi
case "$version" in case "$version" in
'bookworm') 'bookworm')
{ {
echo "deb ${sources_array[$pick]}/debian/ bookworm main contrib non-free non-free-firmware" echo "deb ${url}/debian/ bookworm main contrib non-free non-free-firmware"
echo "deb ${sources_array[$pick]}/debian/ bookworm-updates main contrib non-free non-free-firmware" echo "deb ${url}/debian/ bookworm-updates main contrib non-free non-free-firmware"
echo "deb ${sources_array[$pick]}/debian/ bookworm-backports main contrib non-free non-free-firmware" echo "deb ${url}/debian/ bookworm-backports main contrib non-free non-free-firmware"
} > /etc/apt/sources.list } > /etc/apt/sources.list
sudo apt-get update sudo apt-get update
;; ;;