diff options
| -rw-r--r-- | roles/shared.nix | 104 |
1 files changed, 2 insertions, 102 deletions
diff --git a/roles/shared.nix b/roles/shared.nix index 35f0d44..91c41a8 100644 --- a/roles/shared.nix +++ b/roles/shared.nix @@ -798,106 +798,6 @@ }; environment.etc = { - "usb-mount.sh" = { - mode = "0755"; - source = pkgs.writeShellScript "usb-mount" '' - # This script is called from our systemd unit file to mount or unmount - # a USB drive. - - usage() - { - echo "Usage: $0 {add|remove} device_name (e.g. sdb1)" - exit 1 - } - - if [[ $# -ne 2 ]]; then - usage - fi - - ACTION=$1 - DEVBASE=$2 - DEVICE="/dev/$DEVBASE" - - # See if this drive is already mounted, and if so where - MOUNT_POINT=$(${pkgs.util-linux}/bin/mount | ${pkgs.gnugrep}/bin/grep $DEVICE | ${pkgs.gawk}/bin/awk '{ print $3 }') - - do_mount() - { - if [[ -n $MOUNT_POINT ]]; then - echo "Warning: $DEVICE is already mounted at $MOUNT_POINT" - exit 1 - fi - - # Get info for this drive: $ID_FS_LABEL, $ID_FS_UUID, and $ID_FS_TYPE - eval $(${pkgs.util-linux}/bin/blkid -o udev $DEVICE) - - # Figure out a mount point to use - LABEL=$ID_FS_LABEL - if [[ -z "$LABEL" ]]; then - LABEL=$DEVBASE - elif ${pkgs.gnugrep}/bin/grep -q " /media/$LABEL " /etc/mtab; then - # Already in use, make a unique one - LABEL+="-$DEVBASE" - fi - MOUNT_POINT="/media/$LABEL" - - echo "Mount point: $MOUNT_POINT" - - ${pkgs.coreutils}/bin/mkdir -p $MOUNT_POINT - - # Global mount options - OPTS="rw,relatime" - - # File system type specific mount options - if [[ $ID_FS_TYPE == "vfat" ]]; then - OPTS+=",users,gid=100,umask=000,shortname=mixed,utf8=1,flush" - fi - - if ! /bin/mount -o $OPTS $DEVICE $MOUNT_POINT; then - echo "Error mounting $DEVICE (status = $?)" - ${pkgs.coreutils}/bin/rmdir $MOUNT_POINT - exit 1 - fi - - echo "**** Mounted $DEVICE at $MOUNT_POINT ****" - } - - do_unmount() - { - if [[ -z $MOUNT_POINT ]]; then - echo "Warning: $DEVICE is not mounted" - else - ${pkgs.coreutils}/bin/umount -l $DEVICE - echo "**** Unmounted $DEVICE" - fi - - # Delete all empty dirs in /media that aren't being used as mount - # points. This is kind of overkill, but if the drive was unmounted - # prior to removal we no longer know its mount point, and we don't - # want to leave it orphaned... - for f in /media/* ; do - if [[ -n $(${pkgs.findutils}/bin/find "$f" -maxdepth 0 -type d -empty) ]]; then - if ! ${pkgs.gnugrep}/bin/grep -q " $f " /etc/mtab; then - echo "**** Removing mount point $f" - ${pkgs.coreutils}/bin/rmdir "$f" - fi - fi - done - } - - case "$ACTION" in - add) - do_mount - ;; - remove) - do_unmount - ;; - *) - usage - ;; - esac - ''; - }; "greetd/hyprland-wrapper.sh" = { source = pkgs.writeShellScript "hyperland-wrapper" '' export XDG_SESSION_TYPE=wayland @@ -966,8 +866,8 @@ serviceConfig = { Type = "oneshot"; RemainAfterExit = true; - ExecStart = "/etc/usb-mount.sh add %i"; - ExecStop = "/etc/usb-mount.sh remove %i"; + ExecStart = "${pkgs.pmount}/bin/pmount --umask 000 /dev/%i /media/%i"; + ExecStop = "${pkgs.pmount}/bin/pumount /dev/%i"; }; }; }; |
