Max2Play Home › Forums › Max2Play Add-ons › [SOLVED] Mount only if the NAS is running… › Reply To: [SOLVED] Mount only if the NAS is running…
28. Februar 2017 at 23:40
#27357
Alright, I got it working. Instead of delaying at boot, i added a script that does the following:
If the directory is mounted –> do nothing
If the directory is not mounted:
– check if the NAS is reachable (using ping)
– if yes, mount
here’s my code (don’t forget to add noauto to your mountpoint in fstab)
#!/bin/bash
if mount | grep /mnt/Music > /dev/null; then
echo "/mnt/Music already mounted - nothing to do"
else
echo "/mnt/Music not mounted, pinging discworld"
if ping -c 2 "myServer" >/dev/null; then
mount /mnt/Music
echo "/mnt/Music successfully mounted"
fi
fi
in the end, i’m calling this script every minute in crontab:
* * * * * root /usr/local/bin/mount_nas.sh
Thanks for your help heiner!