Refactor OCI image handling in oci-deploy.sh

This commit is contained in:
CanbiZ (MickLesk) 2025-12-29 17:35:10 +01:00 committed by GitHub
parent dae69a6690
commit 3f490abff1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -98,7 +98,10 @@ if [[ -z "${OCI_IMAGE:-}" ]]; then
5) OCI_IMAGE="ghcr.io/linkwarden/linkwarden:latest" ;; 5) OCI_IMAGE="ghcr.io/linkwarden/linkwarden:latest" ;;
6) 6)
read -r -p "Enter OCI image (e.g., ghcr.io/user/repo:tag): " OCI_IMAGE read -r -p "Enter OCI image (e.g., ghcr.io/user/repo:tag): " OCI_IMAGE
[[ -z "$OCI_IMAGE" ]] && { msg_error "No image specified"; exit 1; } [[ -z "$OCI_IMAGE" ]] && {
msg_error "No image specified"
exit 1
}
;; ;;
*) *)
msg_error "Invalid choice" msg_error "Invalid choice"
@ -168,7 +171,7 @@ fi
declare -a ENV_VARS=() declare -a ENV_VARS=()
case "$OCI_IMAGE" in case "$OCI_IMAGE" in
postgres*|postgresql*) postgres* | postgresql*)
echo "" echo ""
msg_info "PostgreSQL requires environment variables" msg_info "PostgreSQL requires environment variables"
read -r -p "PostgreSQL password: " -s PG_PASS read -r -p "PostgreSQL password: " -s PG_PASS
@ -182,7 +185,7 @@ case "$OCI_IMAGE" in
[[ -n "$PG_USER" ]] && ENV_VARS+=("POSTGRES_USER=$PG_USER") [[ -n "$PG_USER" ]] && ENV_VARS+=("POSTGRES_USER=$PG_USER")
;; ;;
mariadb*|mysql*) mariadb* | mysql*)
echo "" echo ""
msg_info "MariaDB/MySQL requires environment variables" msg_info "MariaDB/MySQL requires environment variables"
read -r -p "Root password: " -s MYSQL_PASS read -r -p "Root password: " -s MYSQL_PASS
@ -201,7 +204,7 @@ case "$OCI_IMAGE" in
fi fi
;; ;;
*linkwarden*) *linkwarden*)
echo "" echo ""
msg_info "Linkwarden configuration" msg_info "Linkwarden configuration"
read -r -p "NEXTAUTH_SECRET (press Enter to generate): " NEXTAUTH_SECRET read -r -p "NEXTAUTH_SECRET (press Enter to generate): " NEXTAUTH_SECRET
@ -271,11 +274,12 @@ fi
# Create container # Create container
msg_info "Creating container $VMID" msg_info "Creating container $VMID"
PCT_CMD="pct create $VMID --ostemplate oci://$FULL_IMAGE" # Build pct create command
PCT_CMD="pct create $VMID"
PCT_CMD+=" --hostname $CT_NAME" PCT_CMD+=" --hostname $CT_NAME"
PCT_CMD+=" --cores $CORES" PCT_CMD+=" --cores $CORES"
PCT_CMD+=" --memory $MEMORY" PCT_CMD+=" --memory $MEMORY"
PCT_CMD+=" --rootfs ${STORAGE}:${DISK}" PCT_CMD+=" --rootfs ${STORAGE}:${DISK},oci=${FULL_IMAGE}"
PCT_CMD+=" --unprivileged $UNPRIVILEGED" PCT_CMD+=" --unprivileged $UNPRIVILEGED"
if [[ "$IP_MODE" == "static" && -n "$STATIC_IP" ]]; then if [[ "$IP_MODE" == "static" && -n "$STATIC_IP" ]]; then