#!/bin/bash # ============================================================================= # plugin/sbin/podman-mount-managed-disk.sh # # Remounts, on every boot, a disk the WebUI's "Format a Disk for Podman # Storage" flow (webui/plugins/podman/ajax/disks.php's "format" action) # formatted and mounted for a single-disk system with no cache pool — # that disk is deliberately outside Unraid's own array/cache pool # management (it's just a plain XFS filesystem on an otherwise-unassigned # disk), so nothing else on the system would remount it after a reboot. # # Called from plugin/event/disks_mounted, BEFORE rc.podman start, so # $STORAGE_PATH (pointed at this disk's mountpoint via Settings) is a real # mounted filesystem by the time podman-storage.sh's `create`/`mount` # steps run — see that script's "does not exist or is not mounted" check. # # Does nothing (exit 0) if the plugin was never used to format a disk — # /boot/config/plugins/podman/managed-disk.cfg only exists after that flow # has actually run at least once. # ============================================================================= set -eu SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=./podman-common.sh . "$SCRIPT_DIR/podman-common.sh" MANAGED_DISK_CFG="$PODMAN_BOOT_DIR/managed-disk.cfg" [ -f "$MANAGED_DISK_CFG" ] || exit 0 UUID="" MOUNTPOINT="" # shellcheck source=/dev/null . "$MANAGED_DISK_CFG" if [ -z "$UUID" ] || [ -z "$MOUNTPOINT" ]; then podman_log_error "mount-managed-disk: $MANAGED_DISK_CFG is missing UUID/MOUNTPOINT, skipping" exit 0 fi if mountpoint -q "$MOUNTPOINT" 2> /dev/null; then podman_log "mount-managed-disk: $MOUNTPOINT already mounted" exit 0 fi mkdir -p "$MOUNTPOINT" if mount "UUID=$UUID" "$MOUNTPOINT"; then podman_log "mount-managed-disk: mounted UUID=$UUID at $MOUNTPOINT" else podman_log_error "mount-managed-disk: failed to mount UUID=$UUID at $MOUNTPOINT (disk removed/renamed?)" fi