Guest User

Untitled

a guest
Jul 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #!/bin/bash
  2. set -e
  3.  
  4. apt-get update
  5. apt-get dist-upgrade
  6. apt-get install -y \
  7. vim \
  8. pmount \
  9. exfat-fuse
  10.  
  11. cat <<'EOF' >/lib/systemd/system/usbstick-handler@.service
  12. [Unit]
  13. Description=Mount USB sticks
  14. BindsTo=dev-%i.device
  15. After=dev-%i.device
  16.  
  17. [Service]
  18. Type=oneshot
  19. RemainAfterExit=yes
  20. ExecStart=/usr/local/bin/automount %I
  21. ExecStop=/usr/bin/pumount /dev/%I
  22. EOF
  23.  
  24. cat <<'EOF' >/usr/local/bin/automount
  25. #!/bin/bash
  26.  
  27. PART=$1
  28. FS_LABEL=$(lsblk -o name,label | grep ${PART} | awk '{print $2}')
  29.  
  30. if [ -z ${FS_LABEL} ]
  31. then
  32. /usr/bin/pmount --umask 000 --noatime -w --sync /dev/${PART} /media/${PART}
  33. else
  34. /usr/bin/pmount --umask 000 --noatime -w --sync /dev/${PART} /media/${FS_LABEL}_${PART}
  35. fi
  36. EOF
  37. chmod +x /usr/local/bin/automount
  38.  
  39. echo "Process complete, rebooting..."
  40.  
  41. reboot
Add Comment
Please, Sign In to add comment