Last active
August 29, 2015 14:23
-
-
Save andykais/d948751a6ca978dd6824 to your computer and use it in GitHub Desktop.
script for mounting the usb/hdd drives on my pi upon startup
This file contains hidden or 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/bash | |
sudo blkid | grep sda | while read -r line | |
do | |
USB=$(echo $line | perl -pe 's/\:(.*)//') | |
TYPE=$(echo $line | perl -pe 's/(.*)TYPE=// and s/"//g') | |
DIR=$(echo $line | perl -pe 's/(.*)\/// and s/\:(.*)//') | |
if [ -z "$(mount | grep $USB)" ] | |
then | |
mountinfo="mounting $USB of type $TYPE on /media/$DIR" | |
sudo mkdir -p /media/$DIR | |
sudo mount -t $TYPE $USB /media/$DIR | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment