Last active
May 29, 2019 16:12
-
-
Save JosefJezek/6390561 to your computer and use it in GitHub Desktop.
Auto Mount CIFS / SMB / Samba Share on Ubuntu / Debian
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 | |
# Auto Mount CIFS / SMB / Samba Share on Ubuntu / Debian | |
# Author: [Josef Jezek](http://about.me/josefjezek) | |
# Donate: [Gittip](https://www.gittip.com/josefjezek) | |
# Link: [Gist](https://gist.github.com/6390561) | |
# Hourly cron job: 0 */1 * * * /root/auto-mount.sh > /dev/null 2>&1 | |
MOUNT_POINT=/media/data | |
SHARE=//example.com/data | |
DOMAIN=example.com | |
USERNAME=administrator | |
PASSWORD=ubuntu | |
if ! mountpoint -q $MOUNT_POINT; then | |
echo "Mount $MOUNT_POINT" | |
mount.cifs $SHARE $MOUNT_POINT -o username=$USERNAME,password=$PASSWORD,domain=$DOMAIN,iocharset=utf8,file_mode=0777,dir_mode=0777 | |
fi |
HI Josefjezek,
I would suggest that you include package update and manual check/install nfs-common, some times the mount.cifs is not available.
http://askubuntu.com/questions/525243/why-do-i-get-wrong-fs-type-bad-option-bad-superblock-error
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can download this using a one-liner:
wget https://gist.github.com/josefjezek/6390561/raw/auto-mount.sh && chmod +x auto-mount.sh