basic example - roubles/macmounter GitHub Wiki
In this example, we will mount a remote folder called 'remotefolder' from the remote server 'example.com' on to the local folder '/Volumes/example'.
$ cat ~/.macmounter/example.conf
[example.com]
MOUNT_TEST_CMD=/sbin/mount | grep -q example
PING_CMD=/sbin/ping -q -c3 -o example.com
PRE_MOUNT_CMD=/bin/mkdir -p /Volumes/example
MOUNT_CMD=/sbin/mount -t smbfs //[email protected]/remotefolder /Volumes/example
Before macmounter performs a mount, it is beneficial to quickly test if the remote folder is already mounted. If the remote folder is already mounted, there is no need to do anything else. For this reason, it is recommended to specify a MOUNT_TEST_CMD.
MOUNT_TEST_CMD=/sbin/mount | grep -q example
Notice, we specify a MOUNT_TEST_CMD. If the remote folder already exists, then macmounter will not re attempt the mount. We use a very simple mount test command for this basic example, but it is important to note that this mount test command can result in false positives. For a more foolproof mount test command refer to testing mounts.
Next, notice, we specify a PING_CMD. This can be anything to test that we have accessibility to the remote server 'example.com'. In this particular example we quietly ping example.com three times.
PING_CMD=/sbin/ping -q -c3 -o example.com
Next, once we know we have accessibility to 'example.com' we can begin the mount. However, there may be some house keeping we need to do before we do the mount. This is where PRE_MOUNT_CMD comes in.
PRE_MOUNT_CMD=/bin/mkdir -p /Volumes/example
In PRE_MOUNT_CMD in this example we create the local folder where we will mount 'example.com:/remotefolder'. We use a very simple premount command for this basic example, but it is important to note that to account for the possibility that the mount is in a weird state we should force an unmount as part of the pre mount as described in unmount before mount.
Finally, we specify the command that actually does the mount.
MOUNT_CMD=/sbin/mount -t smbfs //[email protected]/remotefolder /Volumes/example