Last active
May 12, 2023 01:43
-
-
Save afriza/bacd11597ef1d83e41fa4dbbe9e716e2 to your computer and use it in GitHub Desktop.
mount disk filesystem by LABEL from Linux and mount Samba shares from macOS via AppleScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
domnt() { | |
local lbl="$1" mnt="$2" | |
if ! mount | grep -qF " $mnt " ; then | |
mkdir -p "$mnt" | |
if mount "LABEL=$lbl" "$mnt" ; then | |
echo "'LABEL=$lbl' has been mounted at '$mnt'" | |
fi | |
fi | |
} | |
while true; do | |
for lbl in label-one 'label two' "label three" ; do | |
domnt "$lbl" "/mnt/$lbl" | |
done | |
domnt 'MY DATA' /mnt/data | |
domnt 'ORICO_DISK_01' /mnt/disk1 | |
sleep 15 | |
done | |
# Linux Note: | |
# The order of filesystem types to be tried can be specified | |
# in /etc/filesystems | |
# It is better to combine with nofail option in /etc/fstab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# mount SMB/CIFS from macOS using AppleScript. | |
# Ref: https://apple.stackexchange.com/questions/697/how-can-i-mount-an-smb-share-from-the-command-line#comment475611_303595 | |
domnt() { | |
local loc="$1" mnt="$2" | |
if ! mount | grep -qF " $mnt " ; then | |
if timeout 7 osascript -e 'mount volume "'"$loc"'"' ; then | |
echo "'$loc' has been mounted at '$mnt'" | |
fi | |
fi | |
} | |
while true; do | |
domnt 'smb://user:[email protected]/share1' /Volumes/share1 | |
domnt 'smb://user:[email protected]/share2' /Volumes/share2 | |
sleep 15 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment