Last active
June 21, 2019 03:03
-
-
Save cauethenorio/86cf8ff276a03fb945792f7777121d03 to your computer and use it in GitHub Desktop.
Revisions
-
cauethenorio revised this gist
Jun 21, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -48,9 +48,9 @@ FS_LABEL=\`lsblk -o name,label,UUID | grep \${PART} | awk '{print \$2"-"\$3}'\` if [ -z \${FS_LABEL} ] then /usr/bin/pmount --umask 000 --noatime -w /dev/\${PART} /media/\${PART} else /usr/bin/pmount --umask 000 --noatime -w /dev/\${PART} /media/\${FS_LABEL} fi EOM -
cauethenorio revised this gist
Jun 21, 2019 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -43,14 +43,14 @@ EOM cat > /usr/local/bin/automount <<-EOM #!/bin/bash PART=\$1 FS_LABEL=\`lsblk -o name,label,UUID | grep \${PART} | awk '{print \$2"-"\$3}'\` if [ -z \${FS_LABEL} ] then /usr/bin/pmount --umask 000 --noatime -w --sync /dev/\${PART} /media/\${PART} else /usr/bin/pmount --umask 000 --noatime -w --sync /dev/\${PART} /media/\${FS_LABEL}_\${PART} fi EOM -
cauethenorio revised this gist
Jun 21, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ set -e if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" exit 1 fi -
cauethenorio created this gist
Jun 21, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ #! /bin/bash # Source # https://www.raspberrypi.org/forums/viewtopic.php?t=192291 # https://raspberrypi.stackexchange.com/questions/66169/auto-mount-usb-stick-on-plug-in-without-uuid set -e f [[ $EUID -ne 0 ]]; then echo "This script must be run as root" exit 1 fi # This script mounts drives to /media/usb*, so make sure those # folders aren't occupied. # If you want a cleaner look, don't create any folders. apt-get install pmount # Udev rule cat > /etc/udev/rules.d/usbstick.rules <<- EOM ACTION=="add", KERNEL=="sd[a-z][0-9]", TAG+="systemd", ENV{SYSTEMD_WANTS}="usbstick-handler@%k" EOM # Systemd service cat > /lib/systemd/system/[email protected] <<-EOM [Unit] Description=Mount USB sticks BindsTo=dev-%i.device After=dev-%i.device [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/local/bin/automount %I ExecStop=/usr/bin/pumount /dev/%I EOM cat > /usr/local/bin/automount <<-EOM #!/bin/bash PART=$1 FS_LABEL=`lsblk -o name,label,UUID | grep ${PART} | awk '{print $2"-"$3}'` if [ -z ${FS_LABEL} ] then /usr/bin/pmount --umask 000 --noatime -w --sync /dev/${PART} /media/${PART} else /usr/bin/pmount --umask 000 --noatime -w --sync /dev/${PART} /media/${FS_LABEL}_${PART} fi EOM chmod +x /usr/local/bin/automount echo "Reboot to continue"