Skip to content

Instantly share code, notes, and snippets.

@frennkie
Created September 28, 2025 10:37
Show Gist options
  • Save frennkie/08f1e1d31b99b85185b11c1cb44fdd55 to your computer and use it in GitHub Desktop.
Save frennkie/08f1e1d31b99b85185b11c1cb44fdd55 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Hook script for Proxmox LXC
# Arguments passed: <id> <phase>
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment