8000 unmount before mount · roubles/macmounter Wiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

unmount before mount

roubles edited this page Jul 23, 2015 · 5 revisions

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

Sometimes it is cleaner to unmount a drive before trying to mount it back. This is particularly true about sshfs mounts.

In this case, you can add an unmount to the PRE_MOUNT_CMD as follows:

PRE_MOUNT_CMD=/sbin/umount -f /Volumes/example; /bin/mkdir -p /Volumes/example

or

PRE_MOUNT_CMD=/sbin/umount -f /Volumes/example || /bin/mkdir -p /Volumes/example

Things to note:

  • The workflow engine does not care if PREMOUNT succeeds or not, that is, it does not check the exit status, it just continues.
  • The force unmount can fail, particularly, if the drive was never mounted to begin with. This is why we need to still run any following commands. For instance, the following PRE_MOUNT_CMD would be incorrect because if the force unmount failed, we would not create the folder required for the mount:
PRE_MOUNT_CMD=/sbin/umount -f /Volumes/example && /bin/mkdir -p /Volumes/example # THIS IS WRONG

Finally, in context this looks like this:

[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 //roubles@example.com/remotefolder /Volumes/example
Clone this wiki locally
0