status notification commands - roubles/macmounter GitHub Wiki

Building on the examples in basic example and wakeup server before mounting

You may want to perform certain tasks on success, failure or losing mounts. One common example is sending emails when mounts succeed, or are lost.

For this you can use MOUNT_SUCCESS_CMD, MOUNT_FAILURE_CMD, LOST_MOUNT_CMD, FOUND_MOUNT_CMD respectively.

Note, that MOUNT_SUCCESS_CMD is called every time the mount succeeds. FOUND_MOUNT_CMD is called only once when we go from a unmounted state to a mounted state.

Also, MOUNT_FAILURE_CMD is called every time the mount fails. LOST_MOUNT_CMD is called only once when we go from a mounted state to an unmounted state.

[example.com]
MOUNT_TEST_CMD=ls -l /Volumes/example && /sbin/mount | grep -q example
WAKE_CMD=/usr/local/bin/wakeonlan
WAKE_ATTEMPTS=5
PING_CMD=/sbin/ping -q -c3 -o example.com
PRE_MOUNT_CMD=/sbin/umount -f /Volumes/example; /bin/mkdir -p /Volumes/example
MOUNT_CMD=/sbin/mount -t smbfs //[email protected]/remotefolder /Volumes/example
MOUNT_SUCCESS_CMD=/bin/echo "" | /usr/bin/mail -s "re-mounted example.com!" [email protected]
MOUNT_FAILURE_CMD=/bin/echo "${REASON}" | /usr/bin/mail -s "unable to mount example.com!" [email protected]
LOST_MOUNT_CMD=/bin/echo "" | /usr/bin/mail -s "lost mount for example.com!" [email protected]
FOUND_MOUNT_CMD=/bin/echo "" | /usr/bin/mail -s "Just mounted example.com!" [email protected]

Note: For advanced users, the environment variable $REASON is set on failure. You can use that environment variable in your MOUNT_FAILURE_CMD