Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -e
- apt-get update
- apt-get dist-upgrade
- apt-get install -y \
- vim \
- pmount \
- exfat-fuse
- cat <<'EOF' >/lib/systemd/system/usbstick-handler@.service
- [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
- EOF
- cat <<'EOF' >/usr/local/bin/automount
- #!/bin/bash
- PART=$1
- FS_LABEL=$(lsblk -o name,label | grep ${PART} | awk '{print $2}')
- 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
- EOF
- chmod +x /usr/local/bin/automount
- echo "Process complete, rebooting..."
- reboot
Add Comment
Please, Sign In to add comment