Automount drives in Slax
parent
d775cf882f
commit
78661a48f9
|
|
@ -0,0 +1,2 @@
|
|||
# we don't care about loop* and ram* devices
|
||||
KERNEL=="[!lr]*", SUBSYSTEM=="block", RUN+="/sbin/slax-automount %r/%k"
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
# Recreate fstab entries in /etc/fstab and make /media directories
|
||||
# This script is called by udev rules, see /etc/udev/
|
||||
#
|
||||
# Author: Tomas M <http://slax.linux-live.org/>
|
||||
|
||||
# Variables available in udev environment:
|
||||
# $ACTION (eg: add, remove)
|
||||
# $DEVNAME (full device node name including path)
|
||||
# $DEVTYPE (eg: disk)
|
||||
# $ID_FS_TYPE (eg: ext3)
|
||||
# $MAJOR and $MINOR numbers
|
||||
# $SUBSYSTEM (eg: block)
|
||||
|
||||
PATH=$PATH:/usr/bin:/usr/sbin:/bin:/sbin
|
||||
BOOKMARKS="/root/.gtk-bookmarks"
|
||||
|
||||
BAS="$(basename "$DEVNAME")"
|
||||
UNIT="media-$BAS.mount"
|
||||
MNT="/media/$BAS"
|
||||
TARGET="/etc/systemd/system/$UNIT"
|
||||
|
||||
if [ "$ACTION" = "add" -o "$ACTION" = "change" ]; then
|
||||
if [ ! -r "$TARGET" ]; then # skip if exists
|
||||
|
||||
if [ "$ID_FS_TYPE" != "" -a "$(cat /proc/filesystems | grep "$ID_FS_TYPE")" != "" ]; then
|
||||
|
||||
mkdir -p "$MNT"
|
||||
|
||||
echo "[Unit]" >$TARGET
|
||||
echo "Description=Disk $BAS" >>$TARGET
|
||||
echo "" >>$TARGET
|
||||
echo "[Mount]" >>$TARGET
|
||||
echo "What=$DEVNAME" >>$TARGET
|
||||
echo "where=$MNT" >>$TARGET
|
||||
echo "Type=$ID_FS_TYPE" >>$TARGET
|
||||
echo "Options=defaults" >>$TARGET
|
||||
echo "" >>$TARGET
|
||||
echo "[Install]" >>$TARGET
|
||||
echo "WantedBy=multi-user.target" >>$TARGET
|
||||
|
||||
systemctl enable $UNIT
|
||||
systemctl start $UNIT
|
||||
|
||||
echo "file://$MNT" "$BAS" >>$BOOKMARKS
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$ACTION" = "remove" ]; then
|
||||
systemctl disable $UNIT
|
||||
rm $TARGET
|
||||
sed -i -r "\\;^file://$MNT;d" $BOOKMARKS
|
||||
fi
|
||||
|
||||
Loading…
Reference in New Issue