mirror of
https://github.com/oneclickvirt/pve.git
synced 2024-09-20 15:05:56 +08:00
2023.07.31
This commit is contained in:
parent
b73d7a6b2f
commit
8ea7270dd1
|
@ -15,9 +15,10 @@
|
|||
|
||||
2023.07.31
|
||||
|
||||
- 尝试修复部分机器重启机器后失联的情况
|
||||
- 修复部分机器重启机器后失联的情况
|
||||
- 增加自动时间校准功能
|
||||
- 加速系统熵计算
|
||||
- 修复创建虚拟机和容器的一键脚本分别适配ARM和X86_64的情况
|
||||
|
||||
[更新日志](CHANGELOG.md)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
# from
|
||||
# https://github.com/spiritLHLS/pve
|
||||
# 2023.06.29
|
||||
# 2023.07.31
|
||||
|
||||
|
||||
# ./buildct.sh CTID 密码 CPU核数 内存 硬盘 SSH端口 80端口 443端口 外网端口起 外网端口止 系统 存储盘
|
||||
|
@ -23,6 +23,25 @@ else
|
|||
echo "Locale set to $utf8_locale"
|
||||
fi
|
||||
|
||||
get_system_arch() {
|
||||
local sysarch="$(uname -m)"
|
||||
if [ "${sysarch}" = "unknown" ] || [ "${sysarch}" = "" ]; then
|
||||
local sysarch="$(arch)"
|
||||
fi
|
||||
# 根据架构信息设置系统位数并下载文件,其余 * 包括了 x86_64
|
||||
case "${sysarch}" in
|
||||
"i386" | "i686" | "x86_64")
|
||||
system_arch="x86"
|
||||
;;
|
||||
"armv7l" | "armv8" | "armv8l" | "aarch64")
|
||||
system_arch="arch"
|
||||
;;
|
||||
*)
|
||||
system_arch=""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cd /root >/dev/null 2>&1
|
||||
CTID="${1:-102}"
|
||||
password="${2:-123456}"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
# from
|
||||
# https://github.com/spiritLHLS/pve
|
||||
# 2023.06.29
|
||||
# 2023.07.31
|
||||
|
||||
|
||||
# ./buildvm.sh VMID 用户名 密码 CPU核数 内存 硬盘 SSH端口 80端口 443端口 外网端口起 外网端口止 系统 存储盘
|
||||
|
@ -41,6 +41,25 @@ else
|
|||
_green "Locale set to $utf8_locale"
|
||||
fi
|
||||
|
||||
get_system_arch() {
|
||||
local sysarch="$(uname -m)"
|
||||
if [ "${sysarch}" = "unknown" ] || [ "${sysarch}" = "" ]; then
|
||||
local sysarch="$(arch)"
|
||||
fi
|
||||
# 根据架构信息设置系统位数并下载文件,其余 * 包括了 x86_64
|
||||
case "${sysarch}" in
|
||||
"i386" | "i686" | "x86_64")
|
||||
system_arch="x86"
|
||||
;;
|
||||
"armv7l" | "armv8" | "armv8l" | "aarch64")
|
||||
system_arch="arch"
|
||||
;;
|
||||
*)
|
||||
system_arch=""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
check_cdn() {
|
||||
local o_url=$1
|
||||
for cdn_url in "${cdn_urls[@]}"; do
|
||||
|
@ -66,26 +85,70 @@ cdn_urls=("https://cdn.spiritlhl.workers.dev/" "https://cdn3.spiritlhl.net/" "ht
|
|||
if [ ! -d "qcow" ]; then
|
||||
mkdir qcow
|
||||
fi
|
||||
# "centos7" "alpinelinux_v3_15" "alpinelinux_v3_17" "rockylinux8" "QuTScloud_5.0.1"
|
||||
systems=("debian10" "debian11" "debian9" "ubuntu18" "ubuntu20" "ubuntu22" "archlinux" "centos9-stream" "centos8-stream" "almalinux8" "almalinux9" "fedora33" "fedora34" "opensuse-leap-15")
|
||||
for sys in ${systems[@]}; do
|
||||
if [[ "$system" == "$sys" ]]; then
|
||||
file_path="/root/qcow/${system}.qcow2"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z "$file_path" ]]; then
|
||||
# centos9-stream centos8-stream centos7 almalinux8 almalinux9
|
||||
_red "Unable to install corresponding system, please check https://github.com/spiritLHLS/Images/ for supported system images "
|
||||
_red "无法安装对应系统,请查看 https://github.com/spiritLHLS/Images/ 支持的系统镜像 "
|
||||
exit 1
|
||||
get_system_arch
|
||||
if [ -z "${system_arch}" ] || [ ! -v system_arch ]; then
|
||||
_red "This script can only run on machines under x86_64 or arm architecture."
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$file_path" ]; then
|
||||
# v1.0 基础安装包预安装
|
||||
# v1.1 增加agent安装包预安装,方便在宿主机上看到虚拟机的进程
|
||||
check_cdn_file
|
||||
url="${cdn_success_url}https://github.com/spiritLHLS/Images/releases/download/v1.0/${system}.qcow2"
|
||||
curl -L -o "$file_path" "$url"
|
||||
if [ "$system_arch" = "x86" ]; then
|
||||
systems=("debian10" "debian11" "debian9" "ubuntu18" "ubuntu20" "ubuntu22" "archlinux" "centos9-stream" "centos8-stream" "almalinux8" "almalinux9" "fedora33" "fedora34" "opensuse-leap-15")
|
||||
for sys in ${systems[@]}; do
|
||||
if [[ "$system" == "$sys" ]]; then
|
||||
file_path="/root/qcow/${system}.qcow2"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z "$file_path" ]]; then
|
||||
_red "Unable to install corresponding system, please check https://github.com/spiritLHLS/Images/ for supported system images "
|
||||
_red "无法安装对应系统,请查看 https://github.com/spiritLHLS/Images/ 支持的系统镜像 "
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$file_path" ]; then
|
||||
# v1.0 基础安装包预安装
|
||||
# v1.1 增加agent安装包预安装,方便在宿主机上看到虚拟机的进程
|
||||
check_cdn_file
|
||||
url="${cdn_success_url}https://github.com/spiritLHLS/Images/releases/download/v1.1/${system}.qcow2"
|
||||
curl -L -o "$file_path" "$url"
|
||||
fi
|
||||
elif [ "$system_arch" = "arch" ]; then
|
||||
systems=("ubuntu14" "ubuntu16" "ubuntu18" "ubuntu20" "ubuntu22")
|
||||
for sys in ${systems[@]}; do
|
||||
if [[ "$system" == "$sys" ]]; then
|
||||
file_path="/root/qcow/${system}.img"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z "$file_path" ]]; then
|
||||
# https://www.debian.org/mirror/list
|
||||
_red "Unable to install corresponding system, please check http://cloud-images.ubuntu.com for supported system images "
|
||||
_red "无法安装对应系统,请查看 http://cloud-images.ubuntu.com 支持的系统镜像 "
|
||||
exit 1
|
||||
fi
|
||||
if [ -n "$file_path" ] && [ -f "$file_path" ]; then
|
||||
case "$system" in
|
||||
ubuntu14)
|
||||
version="trusty"
|
||||
;;
|
||||
ubuntu16)
|
||||
version="xenial"
|
||||
;;
|
||||
ubuntu18)
|
||||
version="bionic"
|
||||
;;
|
||||
ubuntu20)
|
||||
version="focal"
|
||||
;;
|
||||
ubuntu22)
|
||||
version="jammy"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported Ubuntu version."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
url="http://cloud-images.ubuntu.com/${version}/current/${version}-server-cloudimg-arm64.img"
|
||||
curl -L -o "$file_path" "$url"
|
||||
fi
|
||||
fi
|
||||
|
||||
first_digit=${vm_num:0:1}
|
||||
|
@ -102,8 +165,14 @@ else
|
|||
fi
|
||||
|
||||
qm create $vm_num --agent 1 --scsihw virtio-scsi-single --serial0 socket --cores $core --sockets 1 --cpu host --net0 virtio,bridge=vmbr1,firewall=0
|
||||
qm importdisk $vm_num /root/qcow/${system}.qcow2 ${storage}
|
||||
qm set $vm_num --scsihw virtio-scsi-pci --scsi0 ${storage}:${vm_num}/vm-${vm_num}-disk-0.raw
|
||||
if [ "$system_arch" = "x86" ]; then
|
||||
qm importdisk $vm_num /root/qcow/${system}.qcow2 ${storage}
|
||||
qm set $vm_num --scsihw virtio-scsi-pci --scsi0 ${storage}:${vm_num}/vm-${vm_num}-disk-0.raw
|
||||
else
|
||||
qm set $vm_num --bios ovmf
|
||||
qm importdisk $vm_num /root/qcow/${system}.img ${storage}
|
||||
qm set $vm_num --scsihw virtio-scsi-pci --scsi0 ${storage}:${vm_num}/vm-${vm_num}-disk-0.raw
|
||||
fi
|
||||
qm set $vm_num --bootdisk scsi0
|
||||
qm set $vm_num --boot order=scsi0
|
||||
qm set $vm_num --memory $memory
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
# from
|
||||
# https://github.com/spiritLHLS/pve
|
||||
# 2023.06.29
|
||||
# 2023.07.31
|
||||
# 自动选择要绑定的IPV4地址
|
||||
|
||||
|
||||
|
@ -38,6 +38,25 @@ else
|
|||
_green "Locale set to $utf8_locale"
|
||||
fi
|
||||
|
||||
get_system_arch() {
|
||||
local sysarch="$(uname -m)"
|
||||
if [ "${sysarch}" = "unknown" ] || [ "${sysarch}" = "" ]; then
|
||||
local sysarch="$(arch)"
|
||||
fi
|
||||
# 根据架构信息设置系统位数并下载文件,其余 * 包括了 x86_64
|
||||
case "${sysarch}" in
|
||||
"i386" | "i686" | "x86_64")
|
||||
system_arch="x86"
|
||||
;;
|
||||
"armv7l" | "armv8" | "armv8l" | "aarch64")
|
||||
system_arch="arch"
|
||||
;;
|
||||
*)
|
||||
system_arch=""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
check_cdn() {
|
||||
local o_url=$1
|
||||
for cdn_url in "${cdn_urls[@]}"; do
|
||||
|
@ -63,25 +82,70 @@ cdn_urls=("https://cdn.spiritlhl.workers.dev/" "https://cdn3.spiritlhl.net/" "ht
|
|||
if [ ! -d "qcow" ]; then
|
||||
mkdir qcow
|
||||
fi
|
||||
# "centos7" "alpinelinux_v3_15" "alpinelinux_v3_17" "rockylinux8" "QuTScloud_5.0.1"
|
||||
systems=("debian10" "debian11" "debian9" "ubuntu18" "ubuntu20" "ubuntu22" "archlinux" "centos9-stream" "centos8-stream" "almalinux8" "almalinux9" "fedora33" "fedora34" "opensuse-leap-15")
|
||||
for sys in ${systems[@]}; do
|
||||
if [[ "$system" == "$sys" ]]; then
|
||||
file_path="/root/qcow/${system}.qcow2"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z "$file_path" ]]; then
|
||||
_red "Unable to install corresponding system, please check https://github.com/spiritLHLS/Images/ for supported system images "
|
||||
_red "无法安装对应系统,请查看 https://github.com/spiritLHLS/Images/ 支持的系统镜像 "
|
||||
exit 1
|
||||
get_system_arch
|
||||
if [ -z "${system_arch}" ] || [ ! -v system_arch ]; then
|
||||
_red "This script can only run on machines under x86_64 or arm architecture."
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$file_path" ]; then
|
||||
# v1.0 基础安装包预安装
|
||||
# v1.1 增加agent安装包预安装,方便在宿主机上看到虚拟机的进程
|
||||
check_cdn_file
|
||||
url="${cdn_success_url}https://github.com/spiritLHLS/Images/releases/download/v1.1/${system}.qcow2"
|
||||
curl -L -o "$file_path" "$url"
|
||||
if [ "$system_arch" = "x86" ]; then
|
||||
systems=("debian10" "debian11" "debian9" "ubuntu18" "ubuntu20" "ubuntu22" "archlinux" "centos9-stream" "centos8-stream" "almalinux8" "almalinux9" "fedora33" "fedora34" "opensuse-leap-15")
|
||||
for sys in ${systems[@]}; do
|
||||
if [[ "$system" == "$sys" ]]; then
|
||||
file_path="/root/qcow/${system}.qcow2"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z "$file_path" ]]; then
|
||||
_red "Unable to install corresponding system, please check https://github.com/spiritLHLS/Images/ for supported system images "
|
||||
_red "无法安装对应系统,请查看 https://github.com/spiritLHLS/Images/ 支持的系统镜像 "
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$file_path" ]; then
|
||||
# v1.0 基础安装包预安装
|
||||
# v1.1 增加agent安装包预安装,方便在宿主机上看到虚拟机的进程
|
||||
check_cdn_file
|
||||
url="${cdn_success_url}https://github.com/spiritLHLS/Images/releases/download/v1.1/${system}.qcow2"
|
||||
curl -L -o "$file_path" "$url"
|
||||
fi
|
||||
elif [ "$system_arch" = "arch" ]; then
|
||||
systems=("ubuntu14" "ubuntu16" "ubuntu18" "ubuntu20" "ubuntu22")
|
||||
for sys in ${systems[@]}; do
|
||||
if [[ "$system" == "$sys" ]]; then
|
||||
file_path="/root/qcow/${system}.img"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z "$file_path" ]]; then
|
||||
# https://www.debian.org/mirror/list
|
||||
_red "Unable to install corresponding system, please check http://cloud-images.ubuntu.com for supported system images "
|
||||
_red "无法安装对应系统,请查看 http://cloud-images.ubuntu.com 支持的系统镜像 "
|
||||
exit 1
|
||||
fi
|
||||
if [ -n "$file_path" ] && [ -f "$file_path" ]; then
|
||||
case "$system" in
|
||||
ubuntu14)
|
||||
version="trusty"
|
||||
;;
|
||||
ubuntu16)
|
||||
version="xenial"
|
||||
;;
|
||||
ubuntu18)
|
||||
version="bionic"
|
||||
;;
|
||||
ubuntu20)
|
||||
version="focal"
|
||||
;;
|
||||
ubuntu22)
|
||||
version="jammy"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported Ubuntu version."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
url="http://cloud-images.ubuntu.com/${version}/current/${version}-server-cloudimg-arm64.img"
|
||||
curl -L -o "$file_path" "$url"
|
||||
fi
|
||||
fi
|
||||
|
||||
first_digit=${vm_num:0:1}
|
||||
|
@ -160,8 +224,14 @@ _green "The current IP to which the VM will be bound is: ${user_ip}"
|
|||
_green "当前虚拟机将绑定的IP为:${user_ip}"
|
||||
|
||||
qm create $vm_num --agent 1 --scsihw virtio-scsi-single --serial0 socket --cores $core --sockets 1 --cpu host --net0 virtio,bridge=vmbr0,firewall=0
|
||||
qm importdisk $vm_num /root/qcow/${system}.qcow2 ${storage}
|
||||
qm set $vm_num --scsihw virtio-scsi-pci --scsi0 ${storage}:${vm_num}/vm-${vm_num}-disk-0.raw
|
||||
if [ "$system_arch" = "x86" ]; then
|
||||
qm importdisk $vm_num /root/qcow/${system}.qcow2 ${storage}
|
||||
qm set $vm_num --scsihw virtio-scsi-pci --scsi0 ${storage}:${vm_num}/vm-${vm_num}-disk-0.raw
|
||||
else
|
||||
qm set $vm_num --bios ovmf
|
||||
qm importdisk $vm_num /root/qcow/${system}.img ${storage}
|
||||
qm set $vm_num --scsihw virtio-scsi-pci --scsi0 ${storage}:${vm_num}/vm-${vm_num}-disk-0.raw
|
||||
fi
|
||||
qm set $vm_num --bootdisk scsi0
|
||||
qm set $vm_num --boot order=scsi0
|
||||
qm set $vm_num --memory $memory
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
# from
|
||||
# https://github.com/spiritLHLS/pve
|
||||
# 2023.06.29
|
||||
# 2023.07.31
|
||||
# 手动指定要绑定的IPV4地址
|
||||
|
||||
|
||||
|
@ -39,6 +39,25 @@ else
|
|||
_green "Locale set to $utf8_locale"
|
||||
fi
|
||||
|
||||
get_system_arch() {
|
||||
local sysarch="$(uname -m)"
|
||||
if [ "${sysarch}" = "unknown" ] || [ "${sysarch}" = "" ]; then
|
||||
local sysarch="$(arch)"
|
||||
fi
|
||||
# 根据架构信息设置系统位数并下载文件,其余 * 包括了 x86_64
|
||||
case "${sysarch}" in
|
||||
"i386" | "i686" | "x86_64")
|
||||
system_arch="x86"
|
||||
;;
|
||||
"armv7l" | "armv8" | "armv8l" | "aarch64")
|
||||
system_arch="arch"
|
||||
;;
|
||||
*)
|
||||
system_arch=""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
is_ipv4() {
|
||||
local ip=$1
|
||||
local regex="^([0-9]{1,3}\.){3}[0-9]{1,3}$"
|
||||
|
@ -91,25 +110,70 @@ cdn_urls=("https://cdn.spiritlhl.workers.dev/" "https://cdn3.spiritlhl.net/" "ht
|
|||
if [ ! -d "qcow" ]; then
|
||||
mkdir qcow
|
||||
fi
|
||||
# "centos7" "alpinelinux_v3_15" "alpinelinux_v3_17" "rockylinux8" "QuTScloud_5.0.1"
|
||||
systems=("debian10" "debian11" "debian9" "ubuntu18" "ubuntu20" "ubuntu22" "archlinux" "centos9-stream" "centos8-stream" "almalinux8" "almalinux9" "fedora33" "fedora34" "opensuse-leap-15")
|
||||
for sys in ${systems[@]}; do
|
||||
if [[ "$system" == "$sys" ]]; then
|
||||
file_path="/root/qcow/${system}.qcow2"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z "$file_path" ]]; then
|
||||
_red "Unable to install corresponding system, please check https://github.com/spiritLHLS/Images/ for supported system images "
|
||||
_red "无法安装对应系统,请查看 https://github.com/spiritLHLS/Images/ 支持的系统镜像 "
|
||||
exit 1
|
||||
get_system_arch
|
||||
if [ -z "${system_arch}" ] || [ ! -v system_arch ]; then
|
||||
_red "This script can only run on machines under x86_64 or arm architecture."
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$file_path" ]; then
|
||||
# v1.0 基础安装包预安装
|
||||
# v1.1 增加agent安装包预安装,方便在宿主机上看到虚拟机的进程
|
||||
check_cdn_file
|
||||
url="${cdn_success_url}https://github.com/spiritLHLS/Images/releases/download/v1.1/${system}.qcow2"
|
||||
curl -L -o "$file_path" "$url"
|
||||
if [ "$system_arch" = "x86" ]; then
|
||||
systems=("debian10" "debian11" "debian9" "ubuntu18" "ubuntu20" "ubuntu22" "archlinux" "centos9-stream" "centos8-stream" "almalinux8" "almalinux9" "fedora33" "fedora34" "opensuse-leap-15")
|
||||
for sys in ${systems[@]}; do
|
||||
if [[ "$system" == "$sys" ]]; then
|
||||
file_path="/root/qcow/${system}.qcow2"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z "$file_path" ]]; then
|
||||
_red "Unable to install corresponding system, please check https://github.com/spiritLHLS/Images/ for supported system images "
|
||||
_red "无法安装对应系统,请查看 https://github.com/spiritLHLS/Images/ 支持的系统镜像 "
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$file_path" ]; then
|
||||
# v1.0 基础安装包预安装
|
||||
# v1.1 增加agent安装包预安装,方便在宿主机上看到虚拟机的进程
|
||||
check_cdn_file
|
||||
url="${cdn_success_url}https://github.com/spiritLHLS/Images/releases/download/v1.1/${system}.qcow2"
|
||||
curl -L -o "$file_path" "$url"
|
||||
fi
|
||||
elif [ "$system_arch" = "arch" ]; then
|
||||
systems=("ubuntu14" "ubuntu16" "ubuntu18" "ubuntu20" "ubuntu22")
|
||||
for sys in ${systems[@]}; do
|
||||
if [[ "$system" == "$sys" ]]; then
|
||||
file_path="/root/qcow/${system}.img"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z "$file_path" ]]; then
|
||||
# https://www.debian.org/mirror/list
|
||||
_red "Unable to install corresponding system, please check http://cloud-images.ubuntu.com for supported system images "
|
||||
_red "无法安装对应系统,请查看 http://cloud-images.ubuntu.com 支持的系统镜像 "
|
||||
exit 1
|
||||
fi
|
||||
if [ -n "$file_path" ] && [ -f "$file_path" ]; then
|
||||
case "$system" in
|
||||
ubuntu14)
|
||||
version="trusty"
|
||||
;;
|
||||
ubuntu16)
|
||||
version="xenial"
|
||||
;;
|
||||
ubuntu18)
|
||||
version="bionic"
|
||||
;;
|
||||
ubuntu20)
|
||||
version="focal"
|
||||
;;
|
||||
ubuntu22)
|
||||
version="jammy"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported Ubuntu version."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
url="http://cloud-images.ubuntu.com/${version}/current/${version}-server-cloudimg-arm64.img"
|
||||
curl -L -o "$file_path" "$url"
|
||||
fi
|
||||
fi
|
||||
|
||||
first_digit=${vm_num:0:1}
|
||||
|
@ -163,8 +227,14 @@ _green "The current IP to which the VM will be bound is: ${user_ip}"
|
|||
_green "当前虚拟机将绑定的IP为:${user_ip}"
|
||||
|
||||
qm create $vm_num --agent 1 --scsihw virtio-scsi-single --serial0 socket --cores $core --sockets 1 --cpu host --net0 virtio,bridge=vmbr0,firewall=0
|
||||
qm importdisk $vm_num /root/qcow/${system}.qcow2 ${storage}
|
||||
qm set $vm_num --scsihw virtio-scsi-pci --scsi0 ${storage}:${vm_num}/vm-${vm_num}-disk-0.raw
|
||||
if [ "$system_arch" = "x86" ]; then
|
||||
qm importdisk $vm_num /root/qcow/${system}.qcow2 ${storage}
|
||||
qm set $vm_num --scsihw virtio-scsi-pci --scsi0 ${storage}:${vm_num}/vm-${vm_num}-disk-0.raw
|
||||
else
|
||||
qm set $vm_num --bios ovmf
|
||||
qm importdisk $vm_num /root/qcow/${system}.img ${storage}
|
||||
qm set $vm_num --scsihw virtio-scsi-pci --scsi0 ${storage}:${vm_num}/vm-${vm_num}-disk-0.raw
|
||||
fi
|
||||
qm set $vm_num --bootdisk scsi0
|
||||
qm set $vm_num --boot order=scsi0
|
||||
qm set $vm_num --memory $memory
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
# from
|
||||
# https://github.com/spiritLHLS/pve
|
||||
# 2023.06.29
|
||||
# 2023.07.31
|
||||
|
||||
# cd /root
|
||||
|
||||
|
@ -20,6 +20,25 @@ else
|
|||
echo "Locale set to $utf8_locale"
|
||||
fi
|
||||
|
||||
get_system_arch() {
|
||||
local sysarch="$(uname -m)"
|
||||
if [ "${sysarch}" = "unknown" ] || [ "${sysarch}" = "" ]; then
|
||||
local sysarch="$(arch)"
|
||||
fi
|
||||
# 根据架构信息设置系统位数并下载文件,其余 * 包括了 x86_64
|
||||
case "${sysarch}" in
|
||||
"i386" | "i686" | "x86_64")
|
||||
system_arch="x86"
|
||||
;;
|
||||
"armv7l" | "armv8" | "armv8l" | "aarch64")
|
||||
system_arch="arch"
|
||||
;;
|
||||
*)
|
||||
system_arch=""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
check_cdn() {
|
||||
local o_url=$1
|
||||
for cdn_url in "${cdn_urls[@]}"; do
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
# from
|
||||
# https://github.com/spiritLHLS/pve
|
||||
# 2023.06.29
|
||||
# 2023.07.31
|
||||
|
||||
# cd /root
|
||||
|
||||
|
@ -20,6 +20,25 @@ else
|
|||
echo "Locale set to $utf8_locale"
|
||||
fi
|
||||
|
||||
get_system_arch() {
|
||||
local sysarch="$(uname -m)"
|
||||
if [ "${sysarch}" = "unknown" ] || [ "${sysarch}" = "" ]; then
|
||||
local sysarch="$(arch)"
|
||||
fi
|
||||
# 根据架构信息设置系统位数并下载文件,其余 * 包括了 x86_64
|
||||
case "${sysarch}" in
|
||||
"i386" | "i686" | "x86_64")
|
||||
system_arch="x86"
|
||||
;;
|
||||
"armv7l" | "armv8" | "armv8l" | "aarch64")
|
||||
system_arch="arch"
|
||||
;;
|
||||
*)
|
||||
system_arch=""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
check_cdn() {
|
||||
local o_url=$1
|
||||
for cdn_url in "${cdn_urls[@]}"; do
|
||||
|
@ -154,27 +173,51 @@ build_new_vms(){
|
|||
_yellow "输入无效,请输入一个正整数。"
|
||||
fi
|
||||
done
|
||||
while true; do
|
||||
sys_status="false"
|
||||
_green "What system does each virtual machine use? (Leave blank or enter debian11 if all use debian11):"
|
||||
reading "每个虚拟机都使用什么系统?(若都使用debian11,则留空或输入debian11):" system
|
||||
if [ -z "$system" ]; then
|
||||
system="debian11"
|
||||
fi
|
||||
systems=("debian10" "debian11" "debian9" "ubuntu18" "ubuntu20" "ubuntu22" "archlinux" "centos9-stream" "centos8-stream" "almalinux8" "almalinux9" "fedora33" "fedora34" "opensuse-leap-15")
|
||||
for sys in ${systems[@]}; do
|
||||
if [[ "$system" == "$sys" ]]; then
|
||||
sys_status="true"
|
||||
break
|
||||
if [ "$system_arch" = "x86" ]; then
|
||||
while true; do
|
||||
sys_status="false"
|
||||
_green "What system does each virtual machine use? (Leave blank or enter debian11 if all use debian11):"
|
||||
reading "每个虚拟机都使用什么系统?(若都使用debian11,则留空或输入debian11):" system
|
||||
if [ -z "$system" ]; then
|
||||
system="debian11"
|
||||
fi
|
||||
done
|
||||
if [ "$sys_status" = "true" ]; then
|
||||
break
|
||||
else
|
||||
_yellow "This system is not supported, please check https://github.com/spiritLHLS/Images for the names of supported systems"
|
||||
_yellow "不支持该系统,请查看 https://github.com/spiritLHLS/Images 支持的系统名字"
|
||||
fi
|
||||
done
|
||||
systems=("debian10" "debian11" "debian9" "ubuntu18" "ubuntu20" "ubuntu22" "archlinux" "centos9-stream" "centos8-stream" "almalinux8" "almalinux9" "fedora33" "fedora34" "opensuse-leap-15")
|
||||
for sys in ${systems[@]}; do
|
||||
if [[ "$system" == "$sys" ]]; then
|
||||
sys_status="true"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$sys_status" = "true" ]; then
|
||||
break
|
||||
else
|
||||
_yellow "This system is not supported, please check https://github.com/spiritLHLS/Images for the names of supported systems"
|
||||
_yellow "不支持该系统,请查看 https://github.com/spiritLHLS/Images 支持的系统名字"
|
||||
fi
|
||||
done
|
||||
else
|
||||
while true; do
|
||||
sys_status="false"
|
||||
_green "What system does each virtual machine use? (Leave blank or enter debian11 if all use debian11):"
|
||||
reading "每个虚拟机都使用什么系统?(若都使用ubuntu22,则留空或输入ubuntu22):" system
|
||||
if [ -z "$system" ]; then
|
||||
system="ubuntu22"
|
||||
fi
|
||||
systems=("ubuntu14" "ubuntu16" "ubuntu18" "ubuntu20" "ubuntu22")
|
||||
for sys in ${systems[@]}; do
|
||||
if [[ "$system" == "$sys" ]]; then
|
||||
sys_status="true"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$sys_status" = "true" ]; then
|
||||
break
|
||||
else
|
||||
_yellow "Unable to install corresponding system, please check http://cloud-images.ubuntu.com for supported system images "
|
||||
_yellow "无法安装对应系统,请查看 http://cloud-images.ubuntu.com 支持的系统镜像 "
|
||||
fi
|
||||
done
|
||||
fi
|
||||
for ((i=1; i<=$new_nums; i++)); do
|
||||
vm_num=$(($vm_num + 1))
|
||||
user=$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 4 | head -n 1)
|
||||
|
@ -193,6 +236,11 @@ build_new_vms(){
|
|||
}
|
||||
|
||||
pre_check
|
||||
get_system_arch
|
||||
if [ -z "${system_arch}" ] || [ ! -v system_arch ]; then
|
||||
_red "This script can only run on machines under x86_64 or arm architecture."
|
||||
exit 1
|
||||
fi
|
||||
check_info
|
||||
build_new_vms
|
||||
check_info
|
||||
|
|
|
@ -428,7 +428,7 @@ COUNT=$(
|
|||
TODAY=$(expr "$COUNT" : '.*\s\([0-9]\{1,\}\)\s/.*') && TOTAL=$(expr "$COUNT" : '.*/\s\([0-9]\{1,\}\)\s.*')
|
||||
}
|
||||
|
||||
get_system_bit() {
|
||||
get_system_arch() {
|
||||
local sysarch="$(uname -m)"
|
||||
if [ "${sysarch}" = "unknown" ] || [ "${sysarch}" = "" ]; then
|
||||
local sysarch="$(arch)"
|
||||
|
@ -528,7 +528,7 @@ if [ "$(id -u)" != "0" ]; then
|
|||
_red "This script must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
get_system_bit
|
||||
get_system_arch
|
||||
if [ -z "${system_arch}" ] || [ ! -v system_arch ]; then
|
||||
_red "This script can only run on machines under x86_64 or arm architecture."
|
||||
exit 1
|
||||
|
|
Loading…
Reference in a new issue