#!/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