You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
TGC3/sbin/thewhispererindarkness.sh

28 lines
520 B
Bash

#!/bin/sh
pathtoname() {
udevadm info -p /sys/"$1" | awk -v FS== '/DEVNAME/ {print $2}'
}
stdbuf -oL -- udevadm monitor --udev -p /sys/block/sda | while read -r -- STATE _ EVENT DEVPATH _
do
#echo $STATE
#echo $EVENT
#echo $DEVPATH
if [ "$STATE" = "DISK_MEDIA_CHANGE=1" ]
then
echo "change detected"
if udisksctl info -b /dev/sda | grep filesystem
then
#echo "filesystem detected"
DEVNAME=$(pathtoname "$DEVPATH")
udisksctl mount --block-device "$DEVNAME" --no-user-interaction
fi
fi
done