Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # Configure OSX to auto-mount an SMB share on boot.
- # Adjust any of these variables as needed.
- set -ex
- sudo -v
- # Hostname or IP of the remote machine running the SMB share.
- VM_HOST="vm.local"
- # Remote SMB user and password.
- SMB_USER="devadmin"
- SMB_PASS="devadmin"
- # The name of the SMB instance hosted by the remote SMB server. If no
- # configuration was provided to the Samba server, it will, by default, share
- # the user's home directory and name the instance after the user.
- SMB_DIR="devadmin"
- SMB_CONFIG="/etc/auto_smb"
- # This will create the SMB mount at /mnt/vm/dcms.
- LOCAL_MOUNT_ROOT="/mnt/vm"
- LOCAL_MOUNT="dcms"
- # Configuration for the /mnt/vm directory.
- sudo sh -c "echo '$LOCAL_MOUNT_ROOT auto_smb -nosuid' >> /etc/auto_master"
- # Configuration for the SMB shared directory.
- [ -f $SMB_CONFIG ] || touch $SMB_CONFIG
- sudo sh -c "echo '$LOCAL_MOUNT -fstype=smbfs,soft,nosuid ://$SMB_USER:$SMB_PASS@$VM_HOST/$SMB_DIR' >> $SMB_CONFIG"
- sudo chmod 600 $SMB_CONFIG
- # Mount shared directories
- sudo automount -vc
- echo "SMB sharing has been configured. Folder accessible at $LOCAL_MOUNT_ROOT/$LOCAL_MOUNT"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement