mirror of
https://github.com/RROrg/rr.git
synced 2026-01-14 23:39:33 +08:00
Compare commits
2 Commits
51974dd95c
...
7b66f0a7ea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b66f0a7ea | ||
|
|
ef6ed60c46 |
@ -12,6 +12,7 @@ REPO="https://github.com/RROrg/rr"
|
|||||||
ONBOOT=1 # 开机启动,默认1
|
ONBOOT=1 # 开机启动,默认1
|
||||||
EFI=1 # 启用 UEFI 引导,默认1
|
EFI=1 # 启用 UEFI 引导,默认1
|
||||||
BLTYPE="sata" # 引导盘类型, 支持 sata,usb,nvme 默认 sata
|
BLTYPE="sata" # 引导盘类型, 支持 sata,usb,nvme 默认 sata
|
||||||
|
STORAGE="" # 存储,默认自动获取
|
||||||
NINEPPATH="" # 9p路径,默认空不添加
|
NINEPPATH="" # 9p路径,默认空不添加
|
||||||
TAG="" # 镜像tag,默认自动获取
|
TAG="" # 镜像tag,默认自动获取
|
||||||
IMG="" # 本地镜像路径,默认空
|
IMG="" # 本地镜像路径,默认空
|
||||||
@ -22,6 +23,7 @@ usage() {
|
|||||||
echo " --onboot <0|1> Enable VM on boot, default 1 (enable)"
|
echo " --onboot <0|1> Enable VM on boot, default 1 (enable)"
|
||||||
echo " --efi <0|1> Enable UEFI boot, default 1 (enable)"
|
echo " --efi <0|1> Enable UEFI boot, default 1 (enable)"
|
||||||
echo " --bltype <sata|usb|nvme> Bootloader disk type, default sata"
|
echo " --bltype <sata|usb|nvme> Bootloader disk type, default sata"
|
||||||
|
echo " --storage <name> Storage name for images, default auto get"
|
||||||
echo " --9ppath <path> Set to /path/to/9p to mount 9p share"
|
echo " --9ppath <path> Set to /path/to/9p to mount 9p share"
|
||||||
echo " --tag <tag> Image tag, download latest release if not set"
|
echo " --tag <tag> Image tag, download latest release if not set"
|
||||||
echo " --img <path> Local image path, use local image if set"
|
echo " --img <path> Local image path, use local image if set"
|
||||||
@ -51,6 +53,16 @@ while true; do
|
|||||||
echo "$BLTYPE" | grep -qvE '^(sata|usb|nvme)$' && BLTYPE="sata"
|
echo "$BLTYPE" | grep -qvE '^(sata|usb|nvme)$' && BLTYPE="sata"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
--storage)
|
||||||
|
STORAGE="$2"
|
||||||
|
[ -n "${STORAGE}" ] && pvesm status -content images | grep -qw "^${STORAGE}" || STORAGE=""
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--9ppath)
|
||||||
|
NINEPPATH="$2"
|
||||||
|
[ -d "${NINEPPATH}" ] && NINEPPATH="$(realpath "${NINEPPATH}")" || NINEPPATH=""
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
--tag)
|
--tag)
|
||||||
TAG="$2"
|
TAG="$2"
|
||||||
[ "${TAG:0:1}" = "v" ] && TAG="${TAG:1}"
|
[ "${TAG:0:1}" = "v" ] && TAG="${TAG:1}"
|
||||||
@ -62,12 +74,6 @@ while true; do
|
|||||||
[ -n "${IMG}" ] && IMG="$(realpath "${IMG}")"
|
[ -n "${IMG}" ] && IMG="$(realpath "${IMG}")"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--9ppath)
|
|
||||||
NINEPPATH="$2"
|
|
||||||
[ ! -d "${NINEPPATH}" ] && NINEPPATH=""
|
|
||||||
[ -z "${NINEPPATH}" ] || NINEPPATH="$(realpath "${NINEPPATH}")"
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
@ -137,9 +143,17 @@ if [ $? -ne 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 获取 存储
|
||||||
|
[ -z "${STORAGE}" ] && STORAGE=$(pvesm status -content images | awk 'NR>1 {print $1}' | grep local | tail -1)
|
||||||
|
if [ -z "${STORAGE}" ]; then
|
||||||
|
echo "No storage for images"
|
||||||
|
qm destroy ${VMID} --purge
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# 启用 UEFI 引导
|
# 启用 UEFI 引导
|
||||||
if [ "${EFI:-1}" -eq 1 ]; then
|
if [ "${EFI:-1}" -eq 1 ]; then
|
||||||
if ! qm set ${VMID} --bios ovmf --efidisk0 local-lvm:4,efitype=4m,pre-enrolled-keys=0; then
|
if ! qm set ${VMID} --bios ovmf --efidisk0 ${STORAGE}:4,efitype=4m,pre-enrolled-keys=0; then
|
||||||
echo "Set UEFI failed"
|
echo "Set UEFI failed"
|
||||||
qm destroy ${VMID} --purge
|
qm destroy ${VMID} --purge
|
||||||
exit 1
|
exit 1
|
||||||
@ -147,12 +161,6 @@ if [ "${EFI:-1}" -eq 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# 导入 RR 镜像
|
# 导入 RR 镜像
|
||||||
STORAGE=$(pvesm status -content images | awk 'NR>1 {print $1}' | grep local | tail -1)
|
|
||||||
if [ -z "${STORAGE}" ]; then
|
|
||||||
echo "No storage for images"
|
|
||||||
qm destroy ${VMID} --purge
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
BLDISK=$(qm importdisk ${VMID} "${IMG_PATH}" "${STORAGE}" | grep 'successfully imported disk' | sed -n "s/.*'\(.*\)'.*/\1/p")
|
BLDISK=$(qm importdisk ${VMID} "${IMG_PATH}" "${STORAGE}" | grep 'successfully imported disk' | sed -n "s/.*'\(.*\)'.*/\1/p")
|
||||||
STATUS=$?
|
STATUS=$?
|
||||||
if [ "${STATUS:-0}" -ne 0 ] || [ -z "${BLDISK}" ]; then
|
if [ "${STATUS:-0}" -ne 0 ] || [ -z "${BLDISK}" ]; then
|
||||||
@ -203,7 +211,7 @@ if [ $? -ne 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# 添加 32G 数据盘
|
# 添加 32G 数据盘
|
||||||
qm set ${VMID} --sata1 local-lvm:32
|
qm set ${VMID} --sata1 ${STORAGE}:32
|
||||||
|
|
||||||
BRIDGE=$(awk -F: '/^iface vmbr/ {print $1}' /etc/network/interfaces | awk '{print $2}' | head -1)
|
BRIDGE=$(awk -F: '/^iface vmbr/ {print $1}' /etc/network/interfaces | awk '{print $2}' | head -1)
|
||||||
if [ -z "${BRIDGE}" ]; then
|
if [ -z "${BRIDGE}" ]; then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user