jellyfin-wol/mount_nas.sh
2025-06-09 22:24:39 +02:00

25 lines
561 B
Bash
Executable file

#!/bin/bash
# Automatically mount NFS share if NAs becomes available.
# Restart jellyfin container after mounting.
DIR="/mnt/Medien"
ping 192.168.1.3 -c 1 > /dev/null 2>&1
PING_STATUS=$?
mount | grep "$DIR" > /dev/null 2>&1
NAS_MOUNT=$?
if [ "$PING_STATUS" -eq 0 ]; then
# Host reachable
if [ "$NAS_MOUNT" -eq 1 ]; then
# nout mounted yet
mount "$DIR" && cd /opt/stacks/jellyfin/ && docker compose down && docker compose up -d
fi
else
if [ $NAS_MOUNT -eq 0 ]; then
# still mounted
umount -l "$DIR"
fi
fi