#!/bin/bash # Hook script for Proxmox LXC # Arguments passed: ID=$1 PHASE=$2 # ID of NAS VM NASVMID=112 # Mountpoint of NAS SMB share on Proxmox host MOUNTPOINT="/mnt/paperless" case "$PHASE" in post-start) echo "Container $ID started. Checking NAS VM running and mountpoint..." # 1. Check if VM is running STATUS=$(qm status $NASVMID | awk '{print $2}') if [ "$STATUS" == "running" ]; then echo "VM $NASVMID is running." if mountpoint -q "$MOUNTPOINT"; then echo "$MOUNTPOINT is already mounted." else echo "$MOUNTPOINT is not mounted. Mounting..." mount "$MOUNTPOINT" if mountpoint -q "$MOUNTPOINT"; then echo "Mounted $MOUNTPOINT successfully." else echo "Failed to mount $MOUNTPOINT." fi fi else echo "VM $NASVMID is not running (status: $STATUS). No action taken." exit 0 fi ;; *) # Do nothing for other phases ;; esac