Created
September 28, 2025 10:37
-
-
Save frennkie/08f1e1d31b99b85185b11c1cb44fdd55 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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