mirror of
https://github.com/wanderleihuttel/vchanger.git
synced 2025-06-28 17:27:01 +00:00
29 lines
1.2 KiB
Plaintext
29 lines
1.2 KiB
Plaintext
|
#!/bin/bash
|
||
|
#
|
||
|
# vchanger-genudevrules ( vchanger v.1.0.1 ) 2015-06-03
|
||
|
#
|
||
|
# Search all autochanger configuration files for magazines being defined
|
||
|
# by filesystem UUID and print to stdout the udev rules for launching
|
||
|
# mount and umount scripts for those filesystems whenever the corresponding
|
||
|
# disk drives are attached or detached from the system.
|
||
|
#
|
||
|
LEDIR=/usr/libexec/vchanger
|
||
|
echo "# This file contains udev rules to launch mount and umount scripts"
|
||
|
echo "# for magazines defined by filesystem UUID in the autochanger configuration"
|
||
|
echo "# files under /etc/vchanger."
|
||
|
echo "#"
|
||
|
echo "# This file was generated by the vchanger-genudevrules script."
|
||
|
echo "#"
|
||
|
for cf in `ls -1 /etc/vchanger/*.conf` ; do
|
||
|
for tmp in `cat ${cf} | grep -v "^#" | tr -d " \t" | grep -i "^magazine="` ; do
|
||
|
tmp=`echo $tmp | grep -i "^magazine=uuid:"`
|
||
|
if [ -n "$tmp" ]; then
|
||
|
tmp=`echo $tmp | cut -d ':' -f 2 | tr -d ' \t\r\n'`
|
||
|
uuid=${tmp,,}
|
||
|
echo "ACTION==\"add\",SUBSYSTEM==\"block\", ENV{ID_FS_UUID}==\"$uuid\", RUN+=\"$LEDIR/vchanger-launch-mount.sh $uuid\""
|
||
|
echo "ACTION==\"remove\",SUBSYSTEM==\"block\", ENV{ID_FS_UUID}==\"$uuid\", RUN+=\"$LEDIR/vchanger-launch-umount.sh $uuid\""
|
||
|
fi
|
||
|
done
|
||
|
done
|
||
|
exit 0
|