This commit is contained in:
CanbiZ 2025-08-01 12:12:53 +02:00
parent d82b417796
commit 1c950e7d41
2 changed files with 62 additions and 56 deletions

View File

@ -27,27 +27,43 @@ function update_script() {
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
#if ! [[ $(dpkg -s python3-xmlsec 2>/dev/null) ]]; then
#$STD apt-get update RELEASE=$(curl -fsSL https://api.github.com/repos/wizarrrr/wizarr/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
#$STD apt-get install -y python3-xmlsec if [[ "${RELEASE}" != "$(cat ~/.tandoor 2>/dev/null)" ]] || [[ ! -f ~/.tandoor ]]; then
#fi msg_info "Stopping $APP"
#if cd /opt/tandoor && git pull | grep -q 'Already up to date'; then systemctl stop tandoor
msg_ok "There is currently no update available." msg_ok "Stopped $APP"
#else
#msg_info "Updating ${APP} (Patience)" msg_info "Creating Backup"
#export $(cat /opt/tandoor/.env | grep "^[^#]" | xargs) BACKUP_FILE="/opt/tandoor_backup_$(date +%F).tar.gz"
#cd /opt/tandoor/ $STD tar -czf "$BACKUP_FILE" /opt/tandoor/{.env,start.sh} /opt/tandoor/database/ &>/dev/null
#$STD pip3 install -r requirements.txt msg_ok "Backup Created"
#$STD /usr/bin/python3 /opt/tandoor/manage.py migrate
#$STD /usr/bin/python3 /opt/tandoor/manage.py collectstatic --no-input setup_uv
#$STD /usr/bin/python3 /opt/tandoor/manage.py collectstatic_js_reverse fetch_and_deploy_gh_release "tandoor" "TandoorRecipes/recipes" "tarball" "latest" "/opt/tandoor"
#cd /opt/tandoor/vue
#$STD yarn install msg_info "Updating $APP to v${RELEASE}"
#$STD yarn build cd /opt/wizarr
#cd /opt/tandoor /usr/local/bin/uv -q sync --locked
#$STD python3 version.py $STD /usr/local/bin/uv -q run pybabel compile -d app/translations
#systemctl restart gunicorn_tandoor $STD npm --prefix app/static install
#msg_ok "Updated ${APP}" $STD npm --prefix app/static run build:css
mkdir -p ./.cache
$STD tar -xf "$BACKUP_FILE" --directory=/
$STD /usr/local/bin/uv -q run flask db upgrade
msg_ok "Updated $APP to v${RELEASE}"
msg_info "Starting $APP"
systemctl start wizarr
msg_ok "Started $APP"
msg_info "Cleaning Up"
rm -rf "$BACKUP_FILE"
msg_ok "Cleanup Completed"
msg_ok "Update Successful"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi
exit exit
} }

View File

@ -207,7 +207,7 @@ function default_settings() {
VMID=$(get_valid_nextid) VMID=$(get_valid_nextid)
FORMAT=",efitype=4m" FORMAT=",efitype=4m"
MACHINE="" MACHINE=""
DISK_SIZE="8G" DISK_SIZE="32G"
DISK_CACHE="" DISK_CACHE=""
HN="debian" HN="debian"
CPU_TYPE="" CPU_TYPE=""
@ -446,7 +446,6 @@ ssh_check
start_script start_script
post_to_api_vm post_to_api_vm
msg_info "Validating Storage" msg_info "Validating Storage"
while read -r line; do while read -r line; do
TAG=$(echo $line | awk '{print $1}') TAG=$(echo $line | awk '{print $1}')
@ -475,12 +474,8 @@ else
fi fi
msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location." msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location."
msg_ok "Virtual Machine ID is ${CL}${BL}$VMID${CL}." msg_ok "Virtual Machine ID is ${CL}${BL}$VMID${CL}."
msg_info "Retrieving the URL for the Debian 12 Qcow2 Disk Image" msg_info "Retrieving the URL for the Debian 12 Cloud-Init Image"
if [ "$CLOUD_INIT" == "yes" ]; then URL=https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2
URL=https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2
else
URL=https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-amd64.qcow2
fi
sleep 2 sleep 2
msg_ok "${CL}${BL}${URL}${CL}" msg_ok "${CL}${BL}${URL}${CL}"
curl -f#SL -o "$(basename "$URL")" "$URL" curl -f#SL -o "$(basename "$URL")" "$URL"
@ -488,36 +483,23 @@ echo -en "\e[1A\e[0K"
FILE=$(basename $URL) FILE=$(basename $URL)
msg_ok "Downloaded ${CL}${BL}${FILE}${CL}" msg_ok "Downloaded ${CL}${BL}${FILE}${CL}"
### UNI-FI OS BLOCK BEGIN # Create Cloud-Init User-Data Snippet for UniFi OS Server
UOS_VERSION="4.2.23" UOS_VERSION="4.2.23"
UOS_URL="https://fw-download.ubnt.com/data/unifi-os-server/8b93-linux-x64-4.2.23-158fa00b-6b2c-4cd8-94ea-e92bc4a81369.23-x64" UOS_URL="https://fw-download.ubnt.com/data/unifi-os-server/8b93-linux-x64-4.2.23-158fa00b-6b2c-4cd8-94ea-e92bc4a81369.23-x64"
UOS_INSTALLER="unifi-os-server-${UOS_VERSION}.bin" UOS_INSTALLER="unifi-os-server-${UOS_VERSION}.bin"
if ! command -v virt-customize &>/dev/null; then USERDATA_SNIPPET="/var/lib/vz/snippets/unifios-server-${VMID}-user-data.yaml"
msg_info "Installing required package: libguestfs-tools on Proxmox host" cat >"$USERDATA_SNIPPET" <<EOF
apt-get -qq update >/dev/null #cloud-config
apt-get -qq install libguestfs-tools lsb-release -y >/dev/null runcmd:
msg_ok "libguestfs-tools installed successfully" - apt-get update
fi - apt-get install -y ca-certificates curl podman lsb-release
- curl -fsSL "${UOS_URL}" -o /root/${UOS_INSTALLER}
- chmod +x /root/${UOS_INSTALLER}
- /root/${UOS_INSTALLER} --install
EOF
msg_info "Patching DNS resolver for apt inside the image" msg_ok "Cloud-Init user-data snippet for UniFi OS Server created at ${USERDATA_SNIPPET}"
virt-customize -q -a "${FILE}" --run-command 'echo "nameserver 1.1.1.1" > /etc/resolv.conf' >/dev/null
msg_info "Injecting UniFi OS Server dependencies and installer into Debian 12 image"
virt-customize -q -a "${FILE}" \
--install qemu-guest-agent,ca-certificates,curl,lsb-release,podman \
--run-command "curl -fsSL '${UOS_URL}' -o /root/${UOS_INSTALLER} && chmod +x /root/${UOS_INSTALLER}" >/dev/null
msg_info "Cleaning up temporary DNS resolver in image"
virt-customize -q -a "${FILE}" --run-command 'rm -f /etc/resolv.conf' >/dev/null
msg_ok "UniFi OS Server installer and dependencies successfully added to Debian 12 image"
msg_ok "After first VM boot, SSH to the VM as root and run:"
msg_ok "/root/${UOS_INSTALLER} --install"
msg_ok "Official UniFi OS Server Guide: https://help.ui.com/hc/en-us/articles/26951761949147-UniFi-OS-Server"
### UNI-FI OS BLOCK END
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
case $STORAGE_TYPE in case $STORAGE_TYPE in
@ -541,7 +523,7 @@ for i in {0,1}; do
eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk}
done done
msg_info "Creating a Debian 12 VM" msg_info "Creating a Debian 12 Cloud VM"
qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \ qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \
-name $HN -tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci -name $HN -tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
@ -560,7 +542,13 @@ else
qm resize $VMID scsi0 ${DEFAULT_DISK_SIZE} >/dev/null qm resize $VMID scsi0 ${DEFAULT_DISK_SIZE} >/dev/null
fi fi
msg_ok "Created a Debian 12 VM ${CL}${BL}(${HN})" # Attach Cloud-Init Drive & user-data to VM
msg_info "Attaching Cloud-Init Drive and custom user-data to VM"
qm set $VMID --ide2 $STORAGE:cloudinit
qm set $VMID --cicustom "user=local:snippets/unifios-server-${VMID}-user-data.yaml"
msg_ok "Created a Debian 12 Cloud-Init VM with UniFi OS Server auto-install"
if [ "$START_VM" == "yes" ]; then if [ "$START_VM" == "yes" ]; then
msg_info "Starting Debian 12 VM" msg_info "Starting Debian 12 VM"
qm start $VMID qm start $VMID
@ -568,4 +556,6 @@ if [ "$START_VM" == "yes" ]; then
fi fi
msg_ok "Completed Successfully!\n" msg_ok "Completed Successfully!\n"
msg_ok "After VM startup, UniFi OS Server will be installed automatically!"
msg_ok "Webinterface will be reachable after a few minutes: https://<VM-IP>:443"
msg_ok "More Info at https://github.com/community-scripts/ProxmoxVED/discussions/836" msg_ok "More Info at https://github.com/community-scripts/ProxmoxVED/discussions/836"