Fix for lost SAMBA / SMB / Windows Shares to NAS

My set up is a home network with consumer grade networking. As a result some of the devices on the network need periodic rebooting. Occasionally the protocols in use on the LAN mean that connections can be lost. This does not happen all the time but it can be annoying when it happens.

To accommodate this I've got small script that I used to check an SMB mount from a Linux Box (Orange Pi One running Armbian) connected to a Seagate Storage Central Single Drive NAS

I've a Cron entry that runs this script and pipes the output plus time / date info to a log file

if [ ! -d "/media/windowsshare/recordings" ]; then
  # Control will enter here if $DIRECTORY doesn't exist.
  sudo service transmission-daemon stop
  sudo service smbd stop
  sleep 20
  sudo service smbd start
  sudo service transmission-daemon start
fi