From c46338f7f822f09d4a95b612be63606b674460a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20V=C3=A1squez=20P=C3=A9rez?= Date: Wed, 7 Oct 2020 10:04:51 -0700 Subject: [PATCH] Started tracking my linux preferences. --- etc/hosts | 20 +++++++++++++++++++ etc/profile.d/aliases.sh | 3 +++ etc/systemd/system/automount_external.service | 13 ++++++++++++ etc/tmpfiles.d/media.conf | 1 + .../rules.d/100-remount-on-plug.rules.bkp | 2 ++ etc/udev/rules.d/99-udisks2.rules | 5 +++++ root/scripts/automount.sh | 12 +++++++++++ 7 files changed, 56 insertions(+) create mode 100644 etc/hosts create mode 100755 etc/profile.d/aliases.sh create mode 100644 etc/systemd/system/automount_external.service create mode 100644 etc/tmpfiles.d/media.conf create mode 100644 etc/udev/rules.d/100-remount-on-plug.rules.bkp create mode 100644 etc/udev/rules.d/99-udisks2.rules create mode 100644 root/scripts/automount.sh diff --git a/etc/hosts b/etc/hosts new file mode 100644 index 0000000..b1a0d67 --- /dev/null +++ b/etc/hosts @@ -0,0 +1,20 @@ +# +# /etc/hosts: static lookup table for host names +# + +# +127.0.0.1 localhost.localdomain localhost +192.168.1.1 router.casa.vm router +#abe 10:BF:48:00:2B:AA +192.168.1.106 abe.casa.vm abe +#bmo 00:24:8C:9C:01:FD +192.168.1.101 bmo.casa.vm bmo +192.168.1.102 saturno.casa.vm saturno +192.168.1.10 impresora.casa.vm impresora +#paraulata eth0 40:62:31:08:53:05 +#paraulata eth1 40:62:31:08:53:06 +#paraulata wl1 74:2F:68:54:A3:C1 +192.168.1.142 paraulata.casa.vm paraulata +::1 localhost.localdomain localhost + +# End of file diff --git a/etc/profile.d/aliases.sh b/etc/profile.d/aliases.sh new file mode 100755 index 0000000..f6d693d --- /dev/null +++ b/etc/profile.d/aliases.sh @@ -0,0 +1,3 @@ +#!/bin/bash +alias lsblk="lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,UUID" +alias ls='ls --color=auto' diff --git a/etc/systemd/system/automount_external.service b/etc/systemd/system/automount_external.service new file mode 100644 index 0000000..9bac2fa --- /dev/null +++ b/etc/systemd/system/automount_external.service @@ -0,0 +1,13 @@ +[Unit] +Description=Monitor with udevadm for inserter external drives and mount them +After=network.target + +[Service] +User=root +Group=root +ExecStart=/root/scripts/automount.sh +Restart=always +RestartSec=5 + +[Install] +WantedBy=multi-user.target diff --git a/etc/tmpfiles.d/media.conf b/etc/tmpfiles.d/media.conf new file mode 100644 index 0000000..1d83176 --- /dev/null +++ b/etc/tmpfiles.d/media.conf @@ -0,0 +1 @@ +D /media 0775 jorge casavm 0 - diff --git a/etc/udev/rules.d/100-remount-on-plug.rules.bkp b/etc/udev/rules.d/100-remount-on-plug.rules.bkp new file mode 100644 index 0000000..62f6cd2 --- /dev/null +++ b/etc/udev/rules.d/100-remount-on-plug.rules.bkp @@ -0,0 +1,2 @@ +SUBSYSTEM=="block" ACTION=="add" \ +RUN+="/root/scripts/remount.sh" diff --git a/etc/udev/rules.d/99-udisks2.rules b/etc/udev/rules.d/99-udisks2.rules new file mode 100644 index 0000000..996e434 --- /dev/null +++ b/etc/udev/rules.d/99-udisks2.rules @@ -0,0 +1,5 @@ +# UDISKS_FILESYSTEM_SHARED +# ==1: mount filesystem to a shared directory (/media/VolumeName) +# ==0: mount filesystem to a private directory (/run/media/$USER/VolumeName) +# See udisks(8) +ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1" diff --git a/root/scripts/automount.sh b/root/scripts/automount.sh new file mode 100644 index 0000000..f09871f --- /dev/null +++ b/root/scripts/automount.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +pathtoname() { + udevadm info -p /sys/"$1" | awk -v FS== '/DEVNAME/ {print $2}' +} + +stdbuf -oL -- udevadm monitor --udev -s block | while read -r -- _ _ event devpath _; do + if [ "$event" = add ]; then + devname=$(pathtoname "$devpath") + udisksctl mount --block-device "$devname" --no-user-interaction + fi +done