pve/install_iso.sh

86 lines
4.1 KiB
Bash
Raw Normal View History

2023-02-15 12:38:01 +08:00
#!/bin/bash
#from https://github.com/spiritLHLS/pve
2023-02-17 09:49:20 +08:00
## China_IP
if [[ -z "${CN}" ]]; then
if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then
_yellow "根据ipapi.co提供的信息当前IP可能在中国"
read -e -r -p "是否选用中国镜像完成安装? [Y/n] " input
case $input in
[yY][eE][sS] | [yY])
echo "使用中国镜像"
CN=true
;;
[nN][oO] | [nN])
echo "不使用中国镜像"
;;
*)
echo "使用中国镜像"
CN=true
;;
esac
fi
fi
2023-02-27 17:17:55 +08:00
echo "请选择要加载到的模板目录:"
2023-02-15 15:22:58 +08:00
echo "1. Proxmox VE 的模板目录(/var/lib/vz/template/iso/"
2023-02-16 21:30:06 +08:00
echo "2. LXC 的模板目录(/var/lib/vz/template/cache/"
2023-02-15 15:24:45 +08:00
echo "3. 全都要"
2023-02-15 15:22:58 +08:00
read -p "请输入选项编号1或2: " choice
2023-02-15 12:38:01 +08:00
# 将镜像文件移动到Proxmox VE的模板目录中
2023-02-15 15:22:58 +08:00
case "$choice" in
1)
2023-02-17 09:49:20 +08:00
if [[ -n "${CN}" ]]; then
2023-02-27 17:17:55 +08:00
wget -P /root/ https://ghproxy.com/https://github.com/spiritLHLS/realServer-Template/releases/download/1.1/ubuntu20.qcow2
wget -P /root/ https://ghproxy.com/https://github.com/spiritLHLS/realServer-Template/releases/download/1.0/debian11.qcow2
2023-02-17 09:49:20 +08:00
else
2023-02-27 17:17:55 +08:00
wget -P /root/ https://github.com/spiritLHLS/realServer-Template/releases/download/1.1/ubuntu20.qcow2
wget -P /root/ https://github.com/spiritLHLS/realServer-Template/releases/download/1.0/debian11.qcow2
2023-02-17 09:49:20 +08:00
fi
2023-02-27 17:17:55 +08:00
qm importdisk --format qcow2 100 /root/ubuntu20.qcow2 local
qm importdisk --format qcow2 101 /root/ubuntu20.qcow2 local
rm -rf /root/ubuntu20.qcow2 /root/debian11.qcow
2023-02-27 17:18:33 +08:00
echo "已将镜像文件加载到 Proxmox VE 的模板目录"
2023-02-15 15:22:58 +08:00
;;
2)
2023-02-17 09:49:20 +08:00
if [[ -n "${CN}" ]]; then
wget -P /root/ https://mirrors.tuna.tsinghua.edu.cn/proxmox/images/system/debian-11-standard_11.3-0_amd64.tar.gz
wget -P /root/ https://mirrors.tuna.tsinghua.edu.cn/proxmox/images/system/ubuntu-20.10-standard_20.10-1_amd64.tar.gz
2023-02-27 17:17:55 +08:00
wget -P /root/ https://mirrors.tuna.tsinghua.edu.cn/proxmox/images/system/debian-10-standard_10.7-1_amd64.tar.gz
2023-02-17 09:49:20 +08:00
else
wget -P /root/ http://download.proxmox.com/images/system/ubuntu-20.10-standard_20.10-1_amd64.tar.gz
wget -P /root/ http://download.proxmox.com/images/system/debian-11-standard_11.3-0_amd64.tar.gz
2023-02-27 17:17:55 +08:00
wget -P /root/ http://download.proxmox.com/images/system/debian-10-standard_10.7-1_amd64.tar.gz
2023-02-17 09:49:20 +08:00
fi
mv /root/ubuntu-20.10-standard_20.10-1_amd64.tar.gz /var/lib/vz/template/cache/
2023-02-17 09:41:03 +08:00
mv /root/debian-11-standard_11.3-0_amd64.tar.gz /var/lib/vz/template/cache/
2023-02-27 17:17:55 +08:00
mv /root/debian-10-standard_10.7-1_amd64.tar.gz /var/lib/vz/template/cache/
2023-02-15 15:22:58 +08:00
echo "已将镜像文件移动到 LXC 的模板目录"
;;
2023-02-15 15:24:45 +08:00
3)
2023-02-17 09:49:20 +08:00
if [[ -n "${CN}" ]]; then
2023-02-27 17:17:55 +08:00
wget -P /root/ https://ghproxy.com/https://github.com/spiritLHLS/realServer-Template/releases/download/1.1/ubuntu20.qcow2
wget -P /root/ https://ghproxy.com/https://github.com/spiritLHLS/realServer-Template/releases/download/1.0/debian11.qcow2
2023-02-17 09:49:20 +08:00
wget -P /root/ https://mirrors.tuna.tsinghua.edu.cn/proxmox/images/system/debian-11-standard_11.3-0_amd64.tar.gz
wget -P /root/ https://mirrors.tuna.tsinghua.edu.cn/proxmox/images/system/ubuntu-20.10-standard_20.10-1_amd64.tar.gz
else
2023-02-27 17:17:55 +08:00
wget -P /root/ https://github.com/spiritLHLS/realServer-Template/releases/download/1.1/ubuntu20.qcow2
wget -P /root/ https://github.com/spiritLHLS/realServer-Template/releases/download/1.0/debian11.qcow2
2023-02-17 09:49:20 +08:00
wget -P /root/ http://download.proxmox.com/images/system/ubuntu-20.10-standard_20.10-1_amd64.tar.gz
wget -P /root/ http://download.proxmox.com/images/system/debian-11-standard_11.3-0_amd64.tar.gz
fi
2023-02-27 17:17:55 +08:00
qm importdisk --format qcow2 100 /root/ubuntu20.qcow2 local
qm importdisk --format qcow2 101 /root/ubuntu20.qcow2 local
rm -rf /root/ubuntu20.qcow2 /root/debian11.qcow
2023-02-17 09:49:20 +08:00
mv /root/ubuntu-20.10-standard_20.10-1_amd64.tar.gz /var/lib/vz/template/cache/
2023-02-17 09:41:03 +08:00
mv /root/debian-11-standard_11.3-0_amd64.tar.gz /var/lib/vz/template/cache/
2023-02-27 17:18:33 +08:00
echo "已全部加载"
2023-02-15 15:24:45 +08:00
;;
2023-02-15 15:22:58 +08:00
*)
echo "无效的选项,程序退出"
;;
esac