mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Merge 419e4d0a0c
into 423e21c52c
This commit is contained in:
commit
6736b1f23c
10 changed files with 148 additions and 148 deletions
18
roles/usb_lib/files/usbmount/iiab-clean-usb.sh.unused
Normal file
18
roles/usb_lib/files/usbmount/iiab-clean-usb.sh.unused
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Remove symlink in /library/www/html/local_content to automounted USB drive
|
||||||
|
# exported
|
||||||
|
#UM_DEVICE="$DEVNAME"
|
||||||
|
#UM_MOUNTPOINT="$mountpoint"
|
||||||
|
#UM_FILESYSTEM="$fstype"
|
||||||
|
|
||||||
|
#DEVICE="/$(echo $1 | sed 's|-|/|')"
|
||||||
|
#MNT_POINT=$(findmnt -no target $DEVICE)
|
||||||
|
CONTENT_LINK_USB=$(basename "$UM_MOUNTPOINT" | awk '{print toupper($0)}')
|
||||||
|
CONTENT_LINK="/library/www/html/local_content/$CONTENT_LINK_USB"
|
||||||
|
|
||||||
|
logger -t "usbmount (iiab-clean-usb.sh)" "Attempting to remove symlink $CONTENT_LINK, as auto-created earlier by usb_lib."
|
||||||
|
|
||||||
|
if [ -L $CONTENT_LINK ]; then
|
||||||
|
/usr/bin/rm $CONTENT_LINK
|
||||||
|
logger -t "usbmount (iiab-clean-usb.sh)" "Symlink $CONTENT_LINK removed, as auto-created earlier by usb_lib."
|
||||||
|
fi
|
|
@ -24,8 +24,8 @@ exec > /dev/null 2>&1
|
||||||
# Log a string via the syslog facility.
|
# Log a string via the syslog facility.
|
||||||
log()
|
log()
|
||||||
{
|
{
|
||||||
if [ $1 != debug ] || expr "$VERBOSE" : "[yY]" > /dev/null; then
|
if [ "$1" != debug ] || expr "$VERBOSE" : "[yY]" > /dev/null; then
|
||||||
logger -p user.$1 -t "usbmount[$$]" -- "$2"
|
logger -p user."$1" -t "usbmount[$$]" -- "$2"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,12 +90,12 @@ if [ "$1" = add ]; then
|
||||||
# Grab device information from device and "divide it"
|
# Grab device information from device and "divide it"
|
||||||
# FIXME: improvement: implement mounting by label (notice that labels
|
# FIXME: improvement: implement mounting by label (notice that labels
|
||||||
# can contain spaces, which makes things a little bit less comfortable).
|
# can contain spaces, which makes things a little bit less comfortable).
|
||||||
DEVINFO=$(/sbin/blkid -p $DEVNAME)
|
DEVINFO=$(/sbin/blkid -p "/$DEVNAME")
|
||||||
FSTYPE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]TYPE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;')
|
FSTYPE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]TYPE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;')
|
||||||
UUID=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]UUID="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;')
|
UUID=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]UUID="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;')
|
||||||
USAGE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]USAGE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;')
|
USAGE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]USAGE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;')
|
||||||
|
|
||||||
if ! echo $USAGE | egrep -q "(filesystem|disklabel)"; then
|
if ! echo "$USAGE" | grep -E "(filesystem|disklabel)"; then
|
||||||
log debug "/$DEVNAME does not contain a filesystem or disklabel"
|
log debug "/$DEVNAME does not contain a filesystem or disklabel"
|
||||||
lockfile-remove /var/run/usbmount/.mount
|
lockfile-remove /var/run/usbmount/.mount
|
||||||
exit
|
exit
|
||||||
|
@ -109,26 +109,26 @@ if [ "$1" = add ]; then
|
||||||
BOOT_DEV=$(/usr/bin/findmnt -no source /boot)
|
BOOT_DEV=$(/usr/bin/findmnt -no source /boot)
|
||||||
log debug "BOOT_DEV $BOOT_DEV"
|
log debug "BOOT_DEV $BOOT_DEV"
|
||||||
|
|
||||||
if [ $BOOTFW_DEV = /$DEVNAME ]; then
|
if [ "$BOOTFW_DEV" = /"$DEVNAME" ]; then
|
||||||
log debug "skipping BOOTFS_DEV $BOOTFS_DEV mounted at /boot/firmware"
|
log debug "skipping BOOTFW_DEV $BOOTFW_DEV mounted at /boot/firmware"
|
||||||
lockfile-remove /var/run/usbmount/.mount
|
lockfile-remove /var/run/usbmount/.mount
|
||||||
exit
|
exit
|
||||||
elif [ $ROOT_DEV = /$DEVNAME ]; then
|
elif [ "$ROOT_DEV" = /"$DEVNAME" ]; then
|
||||||
log debug "skipping ROOT_DEV $ROOT_DEV mounted at /"
|
log debug "skipping ROOT_DEV $ROOT_DEV mounted at /"
|
||||||
lockfile-remove /var/run/usbmount/.mount
|
lockfile-remove /var/run/usbmount/.mount
|
||||||
exit
|
exit
|
||||||
elif [ $BOOT_DEV = /$DEVNAME ]; then
|
elif [ "$BOOT_DEV" = /"$DEVNAME" ]; then
|
||||||
log debug "skipping BOOT_DEV $BOOT_DEV mount as /boot"
|
log debug "skipping BOOT_DEV $BOOT_DEV mount as /boot"
|
||||||
lockfile-remove /var/run/usbmount/.mount
|
lockfile-remove /var/run/usbmount/.mount
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Try to use specifications in /etc/fstab to skip.
|
# Try to use specifications in /etc/fstab to skip.
|
||||||
if egrep -q "^[[:blank:]]*$DEVNAME" /etc/fstab; then
|
if grep -Eq "^[[:blank:]]*$DEVNAME" /etc/fstab; then
|
||||||
log debug "skipping /$DEVNAME exit"
|
log debug "skipping /$DEVNAME exit"
|
||||||
lockfile-remove /var/run/usbmount/.mount
|
lockfile-remove /var/run/usbmount/.mount
|
||||||
exit
|
exit
|
||||||
elif grep -q "^[[:blank:]]*UUID=$UUID" /etc/fstab; then
|
elif grep -Eq "^[[:blank:]]*UUID=$UUID" /etc/fstab; then
|
||||||
log debug "skipping $UUID"
|
log debug "skipping $UUID"
|
||||||
lockfile-remove /var/run/usbmount/.mount
|
lockfile-remove /var/run/usbmount/.mount
|
||||||
exit
|
exit
|
||||||
|
@ -160,36 +160,36 @@ if [ "$1" = add ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Mount the filesystem.
|
# Mount the filesystem.
|
||||||
log info "executing command: mount -t$fstype ${options:+-o$options} $DEVNAME $mountpoint"
|
log info "executing command: mount -t$fstype ${options:+-o$options} /$DEVNAME $mountpoint"
|
||||||
mount "-t$fstype" "${options:+-o$options}" "$DEVNAME" "$mountpoint"
|
mount "-t$fstype" "${options:+-o$options}" "/$DEVNAME" "$mountpoint"
|
||||||
|
|
||||||
# Determine vendor and model.
|
# Determine vendor and model.
|
||||||
vendor=
|
vendor=
|
||||||
if [ -r "/sys$DEVPATH/device/vendor" ]; then
|
if [ -r "/sys$DEVPATH/device/vendor" ]; then
|
||||||
vendor="`cat \"/sys$DEVPATH/device/vendor\"`"
|
vendor="$(cat \"/sys"$DEVPATH"/device/vendor\")"
|
||||||
elif [ -r "/sys$DEVPATH/../device/vendor" ]; then
|
elif [ -r "/sys$DEVPATH/../device/vendor" ]; then
|
||||||
vendor="`cat \"/sys$DEVPATH/../device/vendor\"`"
|
vendor="$(cat \"/sys"$DEVPATH"/../device/vendor\")"
|
||||||
elif [ -r "/sys$DEVPATH/device/../manufacturer" ]; then
|
elif [ -r "/sys$DEVPATH/device/../manufacturer" ]; then
|
||||||
vendor="`cat \"/sys$DEVPATH/device/../manufacturer\"`"
|
vendor="$(cat \"/sys"$DEVPATH"/device/../manufacturer\")"
|
||||||
elif [ -r "/sys$DEVPATH/../device/../manufacturer" ]; then
|
elif [ -r "/sys$DEVPATH/../device/../manufacturer" ]; then
|
||||||
vendor="`cat \"/sys$DEVPATH/../device/../manufacturer\"`"
|
vendor="$(cat \"/sys"$DEVPATH"/../device/../manufacturer\")"
|
||||||
fi
|
fi
|
||||||
vendor="$(echo "$vendor" | sed 's/^[[:blank:]]\+//; s/[[:blank:]]\+$//')"
|
vendor="$(echo "$vendor" | sed 's/^[[:blank:]]\+//; s/[[:blank:]]\+$//')"
|
||||||
|
|
||||||
model=
|
model=
|
||||||
if [ -r "/sys$DEVPATH/device/model" ]; then
|
if [ -r "/sys$DEVPATH/device/model" ]; then
|
||||||
model="`cat \"/sys$DEVPATH/device/model\"`"
|
model="$(cat \"/sys"$DEVPATH"/device/model\")"
|
||||||
elif [ -r "/sys$DEVPATH/../device/model" ]; then
|
elif [ -r "/sys$DEVPATH/../device/model" ]; then
|
||||||
model="`cat \"/sys$DEVPATH/../device/model\"`"
|
model="$(cat \"/sys"$DEVPATH"/../device/model\")"
|
||||||
elif [ -r "/sys$DEVPATH/device/../product" ]; then
|
elif [ -r "/sys$DEVPATH/device/../product" ]; then
|
||||||
model="`cat \"/sys$DEVPATH/device/../product\"`"
|
model="$(cat \"/sys"$DEVPATH"/device/../product\")"
|
||||||
elif [ -r "/sys$DEVPATH/../device/../product" ]; then
|
elif [ -r "/sys$DEVPATH/../device/../product" ]; then
|
||||||
model="`cat \"/sys$DEVPATH/../device/../product\"`"
|
model="$(cat \"/sys"$DEVPATH"/../device/../product\")"
|
||||||
fi
|
fi
|
||||||
model="$(echo "$model" | sed 's/^[[:blank:]]\+//; s/[[:blank:]]\+$//')"
|
model="$(echo "$model" | sed 's/^[[:blank:]]\+//; s/[[:blank:]]\+$//')"
|
||||||
|
|
||||||
# Run hook scripts; ignore errors.
|
# Run hook scripts; ignore errors.
|
||||||
export UM_DEVICE="$DEVNAME"
|
export UM_DEVICE="/$DEVNAME"
|
||||||
export UM_MOUNTPOINT="$mountpoint"
|
export UM_MOUNTPOINT="$mountpoint"
|
||||||
export UM_FILESYSTEM="$fstype"
|
export UM_FILESYSTEM="$fstype"
|
||||||
export UM_MOUNTOPTIONS="$options"
|
export UM_MOUNTOPTIONS="$options"
|
||||||
|
@ -199,30 +199,32 @@ if [ "$1" = add ]; then
|
||||||
run-parts /etc/usbmount/mount.d || :
|
run-parts /etc/usbmount/mount.d || :
|
||||||
else
|
else
|
||||||
# No suitable mount point found.
|
# No suitable mount point found.
|
||||||
log warning "no mountpoint found for $DEVNAME"
|
log warning "no mountpoint found for /$DEVNAME"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [ "$1" = remove ]; then
|
elif [ "$1" = remove ]; then
|
||||||
|
|
||||||
|
log debug "DEVNAME is /$DEVNAME"
|
||||||
# A block or partition device has been removed.
|
# A block or partition device has been removed.
|
||||||
# Test if it is mounted.
|
# Test if it is mounted.
|
||||||
while read device mountpoint fstype remainder; do
|
while read -r device mountpoint fstype junk; do
|
||||||
if [ "$DEVNAME" = "$device" ]; then
|
if [ "/$DEVNAME" = "$device" ]; then
|
||||||
|
log debug "umount device is $device"
|
||||||
|
log debug "umount fstype is $fstype"
|
||||||
# If the mountpoint and filesystem type are maintained by
|
# If the mountpoint and filesystem type are maintained by
|
||||||
# this script, unmount the filesystem.
|
# this script, unmount the filesystem.
|
||||||
if in_list "$mountpoint" "$MOUNTPOINTS" &&
|
if in_list "$mountpoint" "$MOUNTPOINTS"; then
|
||||||
in_list "$fstype" "$FILESYSTEMS"; then
|
|
||||||
log info "executing command: umount -l $mountpoint"
|
|
||||||
umount -l "$mountpoint"
|
|
||||||
|
|
||||||
# Run hook scripts; ignore errors.
|
# Run hook scripts; ignore errors.
|
||||||
export UM_DEVICE="$DEVNAME"
|
log debug "umount mountpoint is $mountpoint"
|
||||||
|
export UM_DEVICE="$device"
|
||||||
export UM_MOUNTPOINT="$mountpoint"
|
export UM_MOUNTPOINT="$mountpoint"
|
||||||
export UM_FILESYSTEM="$fstype"
|
export UM_FILESYSTEM="$fstype"
|
||||||
log info "executing command: run-parts /etc/usbmount/umount.d"
|
log info "executing command: run-parts /etc/usbmount/umount.d"
|
||||||
run-parts /etc/usbmount/umount.d || :
|
run-parts /etc/usbmount/umount.d || :
|
||||||
|
log info "executing command: umount -l $mountpoint"
|
||||||
|
umount -l "$mountpoint"
|
||||||
fi
|
fi
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
ACTION=="add", SUBSYSTEMS=="usb", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem" PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c"
|
ACTION=="add", SUBSYSTEMS=="usb", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem" PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c"
|
||||||
ACTION=="remove", SUBSYSTEMS=="usb", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem" PROGRAM="/bin/systemd-escape -p /usr/share/usbmount/usbmount remove"
|
ACTION=="remove", SUBSYSTEMS=="usb", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem" PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}"
|
||||||
|
|
|
@ -9,7 +9,6 @@ ConditionPathExists=/var/run
|
||||||
TimeoutStartSec=0
|
TimeoutStartSec=0
|
||||||
Environment=DEVNAME=%I
|
Environment=DEVNAME=%I
|
||||||
ExecStart=/usr/local/sbin/usbmount add
|
ExecStart=/usr/local/sbin/usbmount add
|
||||||
ExecStop=/usr/local/sbin/iiab-clean-usb.sh %I
|
ExecStop=/usr/local/sbin/usbmount remove
|
||||||
ExecStopPost=/bin/umount /%I
|
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
RuntimeDirectory=usbmount
|
RuntimeDirectory=usbmount
|
|
@ -93,16 +93,8 @@
|
||||||
with_items:
|
with_items:
|
||||||
- { src: 'usbmount/usbmount.conf', dest: '/etc/usbmount/', mode: '0644' }
|
- { src: 'usbmount/usbmount.conf', dest: '/etc/usbmount/', mode: '0644' }
|
||||||
- { src: 'usbmount/usbmount', dest: '/usr/local/sbin/', mode: '0755' }
|
- { src: 'usbmount/usbmount', dest: '/usr/local/sbin/', mode: '0755' }
|
||||||
|
- { src: 'usbmount/usbmount.rules', dest: '/etc/udev/rules.d/usbmount.rules', mode: '0644' }
|
||||||
- name: 'Install from template: /etc/udev/rules.d/usbmount.rules, /etc/systemd/system/usbmount@.service, /usr/local/sbin/iiab-clean-usb.sh'
|
- { src: 'usbmount/usbmount@.service', dest: '/etc/systemd/system/usbmount@.service', mode: '0644' }
|
||||||
template:
|
|
||||||
src: "{{ item.src }}"
|
|
||||||
dest: "{{ item.dest }}"
|
|
||||||
mode: "{{ item.mode }}"
|
|
||||||
with_items:
|
|
||||||
- { src: 'usbmount.rules.j2', dest: '/etc/udev/rules.d/usbmount.rules', mode: '0644' }
|
|
||||||
- { src: 'usbmount@.service.j2', dest: '/etc/systemd/system/usbmount@.service', mode: '0644' }
|
|
||||||
- { src: 'iiab-clean-usb.sh', dest: '/usr/local/sbin/', mode: '0755' }
|
|
||||||
|
|
||||||
- name: Add dir {{ doc_root }}/upload2usb (0775) owned by {{ apache_user }}:{{ apache_user }}
|
- name: Add dir {{ doc_root }}/upload2usb (0775) owned by {{ apache_user }}:{{ apache_user }}
|
||||||
file:
|
file:
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
- name: Install /etc/usbmount/umount.d/70-usb-library from template
|
||||||
|
template:
|
||||||
|
src: umount.d/70-usb-library.j2
|
||||||
|
dest: /etc/usbmount/umount.d/70-usb-library
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0751'
|
||||||
|
|
||||||
- name: Install /etc/usbmount/mount.d/70-usb-library from template, if usb_lib_enabled
|
- name: Install /etc/usbmount/mount.d/70-usb-library from template, if usb_lib_enabled
|
||||||
template:
|
template:
|
||||||
src: mount.d/70-usb-library.j2
|
src: mount.d/70-usb-library.j2
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Remove symlink in /library/www/html/local_content to automounted USB drive
|
|
||||||
|
|
||||||
DEVICE="/$(echo $1 | sed 's|-|/|')"
|
|
||||||
MNT_POINT=$(findmnt -no target $DEVICE)
|
|
||||||
CONTENT_LINK_USB=$(basename $MNT_POINT | awk '{print toupper($0)}')
|
|
||||||
CONTENT_LINK="/library/www/html/local_content/$CONTENT_LINK_USB"
|
|
||||||
|
|
||||||
logger -t "usb_lib (iiab-clean-usb.sh)" "Attempting to remove symlink $CONTENT_LINK, as auto-created earlier by usbmount."
|
|
||||||
|
|
||||||
if [ -L $CONTENT_LINK ]; then
|
|
||||||
/usr/bin/rm $CONTENT_LINK
|
|
||||||
logger -t "usb_lib (iiab-clean-usb.sh)" "Symlink $CONTENT_LINK removed, as auto-created earlier by usbmount."
|
|
||||||
fi
|
|
|
@ -8,38 +8,32 @@
|
||||||
# <douglas@paradise.net.nz>
|
# <douglas@paradise.net.nz>
|
||||||
#
|
#
|
||||||
# by Tim Moody tim@timmoody.com
|
# by Tim Moody tim@timmoody.com
|
||||||
|
# Jerry Vonau jvonau3@gmail.com
|
||||||
|
#
|
||||||
|
# exported from usbmount
|
||||||
|
# UM_DEVICE="$device"
|
||||||
|
# UM_MOUNTPOINT="$mountpoint"
|
||||||
|
# UM_FILESYSTEM="$fstype"
|
||||||
|
# UM_MOUNTOPTIONS="$options"
|
||||||
|
# UM_VENDOR="$vendor"
|
||||||
|
# UM_MODEL="$model"
|
||||||
|
# UM_MOUNTPOINT is documented at: https://github.com/rbrito/usbmount#hook-scripts
|
||||||
|
|
||||||
# Better to set this in /etc/usbmount/usbmount.conf
|
# Better to set this in /etc/usbmount/usbmount.conf
|
||||||
# VERBOSE=yes
|
# VERBOSE=yes
|
||||||
|
|
||||||
# UM_MOUNTPOINT is documented at: https://github.com/rbrito/usbmount#hook-scripts
|
logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "UM_MOUNTPOINT is: $UM_MOUNTPOINT"
|
||||||
UM_DEV=$(findmnt -no source $UM_MOUNTPOINT)
|
logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "UM_DEVICE is: $UM_DEVICE"
|
||||||
|
|
||||||
# 2022-06-16 better security thanks to @tim-moody and @jvonau:
|
# 2022-06-16 better security thanks to @tim-moody and @jvonau:
|
||||||
# https://github.com/iiab/iiab/pull/3254
|
# https://github.com/iiab/iiab/pull/3254
|
||||||
LIB_DEV=$(findmnt -no source /library | cut -d '[' -f 1)
|
LIB_DEV=$(findmnt -no source /library | cut -d '[' -f 1)
|
||||||
ROOT_DEV=$(findmnt -no source /)
|
|
||||||
BOOT_DEV=$(findmnt -no source /boot)
|
|
||||||
BOOTFW_DEV=$(findmnt -no source /boot/firmware)
|
|
||||||
|
|
||||||
# Verbose logging to illuminate occasional boot bugginess:
|
# Verbose logging to illuminate occasional boot bugginess:
|
||||||
logger -t "usb_lib (70-usb-library)" "UM_DEV is: $UM_DEV"
|
logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "LIB_DEV is: $LIB_DEV"
|
||||||
logger -t "usb_lib (70-usb-library)" "LIB_DEV is: $LIB_DEV"
|
|
||||||
logger -t "usb_lib (70-usb-library)" "ROOT_DEV is: $ROOT_DEV"
|
|
||||||
logger -t "usb_lib (70-usb-library)" "BOOT_DEV is: $BOOT_DEV"
|
|
||||||
logger -t "usb_lib (70-usb-library)" "BOOTFW_DEV is: $BOOTFW_DEV"
|
|
||||||
|
|
||||||
if [ "$UM_DEV" == "$LIB_DEV" ]; then
|
if [ "$UM_DEVICE" == "$LIB_DEV" ]; then
|
||||||
logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /library"
|
logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /library"
|
||||||
exit 1
|
|
||||||
elif [ "$UM_DEV" == "$ROOT_DEV" ]; then
|
|
||||||
logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing rootfs"
|
|
||||||
exit 1
|
|
||||||
elif [ "$UM_DEV" == "$BOOT_DEV" ]; then
|
|
||||||
logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /boot"
|
|
||||||
exit 1
|
|
||||||
elif [ "$UM_DEV" == "$BOOTFW_DEV" ]; then
|
|
||||||
logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /boot/firmware"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -48,20 +42,20 @@ fi
|
||||||
# "public artwork" — as summarized here: https://github.com/iiab/iiab/blob/master/roles/usb_lib/README.rst
|
# "public artwork" — as summarized here: https://github.com/iiab/iiab/blob/master/roles/usb_lib/README.rst
|
||||||
if [ -d $UM_MOUNTPOINT/PUBLIC ]; then
|
if [ -d $UM_MOUNTPOINT/PUBLIC ]; then
|
||||||
SHARE_DIR=$UM_MOUNTPOINT/PUBLIC
|
SHARE_DIR=$UM_MOUNTPOINT/PUBLIC
|
||||||
logger -t "usb_lib (70-usb-library)" "Found /PUBLIC on $UM_MOUNTPOINT"
|
logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "Found /PUBLIC on $UM_MOUNTPOINT"
|
||||||
else
|
else
|
||||||
SHARE_DIR=$UM_MOUNTPOINT
|
SHARE_DIR=$UM_MOUNTPOINT
|
||||||
logger -t "usb_lib (70-usb-library)" "Did not find /PUBLIC on $UM_MOUNTPOINT"
|
logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "Did not find /PUBLIC on $UM_MOUNTPOINT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CONTENT_LINK_USB=$(basename $UM_MOUNTPOINT | awk '{print toupper($0)}')
|
CONTENT_LINK_USB=$(basename $UM_MOUNTPOINT | awk '{print toupper($0)}')
|
||||||
if [ -z "$CONTENT_LINK_USB" ]; then
|
if [ -z "$CONTENT_LINK_USB" ]; then
|
||||||
logger -t "usb_lib (70-usb-library)" 'ERROR: Var CONTENT_LINK_USB is empty ("rm -rf /library/www/html/local_content/" would be dangerous!)'
|
logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" 'ERROR: Var CONTENT_LINK_USB is empty ("rm -rf /library/www/html/local_content/" would be dangerous!)'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
CONTENT_LINK="{{ doc_root }}/local_content/$CONTENT_LINK_USB"
|
CONTENT_LINK="{{ doc_root }}/local_content/$CONTENT_LINK_USB"
|
||||||
# 'rm -rf' even stronger than 'ln -nsf' and 'ln -Tsf'
|
# 'rm -rf' even stronger than 'ln -nsf' and 'ln -Tsf'
|
||||||
# https://serverfault.com/questions/147787/how-to-update-a-symbolic-link-target-ln-f-s-not-working/522483#522483
|
# https://serverfault.com/questions/147787/how-to-update-a-symbolic-link-target-ln-f-s-not-working/522483#522483
|
||||||
logger -t "usb_lib (70-usb-library)" "Creating link from $CONTENT_LINK to $SHARE_DIR"
|
logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "Creating link from $CONTENT_LINK to $SHARE_DIR"
|
||||||
rm -rf $CONTENT_LINK
|
rm -rf $CONTENT_LINK
|
||||||
ln -s $SHARE_DIR $CONTENT_LINK
|
ln -s $SHARE_DIR $CONTENT_LINK
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Remove symlink in /library/content to autmounted usb drive
|
|
||||||
#
|
|
||||||
# based on a similar script in the xs-rsync package
|
|
||||||
# by Martin Langhoff <martin@laptop.org>
|
|
||||||
#
|
|
||||||
# and the adaptation for xs-activity-server by Douglas Bagnall
|
|
||||||
# <douglas@paradise.net.nz>
|
|
||||||
#
|
|
||||||
# by Tim Moody tim@timmoody.com
|
|
||||||
|
|
||||||
CONTENT_LINK_USB=`basename $UM_MOUNTPOINT | awk '{print toupper($0)}'`
|
|
||||||
CONTENT_LINK="{{ doc_root }}/local_content/$CONTENT_LINK_USB"
|
|
||||||
|
|
||||||
logger -p user.notice -t "usb_lib (70-usb-library)" -- "Attempting to remove link $CONTENT_LINK."
|
|
||||||
|
|
||||||
if [ -L $CONTENT_LINK ]; then
|
|
||||||
{% if is_debuntu %}
|
|
||||||
/bin/rm -f $CONTENT_LINK
|
|
||||||
{% else %}
|
|
||||||
/usr/bin/rm -f $CONTENT_LINK
|
|
||||||
{% endif %}
|
|
||||||
logger -p user.notice -t "usb_lib (70-usb-library)" -- "$CONTENT_LINK removed."
|
|
||||||
fi
|
|
26
roles/usb_lib/templates/umount.d/70-usb-library.j2
Normal file
26
roles/usb_lib/templates/umount.d/70-usb-library.j2
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Remove symlink in /library/content to autmounted usb drive
|
||||||
|
#
|
||||||
|
# based on a similar script in the xs-rsync package
|
||||||
|
# by Martin Langhoff <martin@laptop.org>
|
||||||
|
#
|
||||||
|
# and the adaptation for xs-activity-server by Douglas Bagnall
|
||||||
|
# <douglas@paradise.net.nz>
|
||||||
|
#
|
||||||
|
# by Tim Moody tim@timmoody.com
|
||||||
|
# Jerry Vonau jvonau3@gmail.com
|
||||||
|
#
|
||||||
|
# exported from usbmount
|
||||||
|
# UM_DEVICE="$device"
|
||||||
|
# UM_MOUNTPOINT="$mountpoint"
|
||||||
|
# UM_FILESYSTEM="$fstype"
|
||||||
|
|
||||||
|
CONTENT_LINK_USB=$(basename $UM_MOUNTPOINT | awk '{print toupper($0)}')
|
||||||
|
CONTENT_LINK="{{ doc_root }}/local_content/$CONTENT_LINK_USB"
|
||||||
|
|
||||||
|
logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" -- "Attempting to remove link $CONTENT_LINK."
|
||||||
|
|
||||||
|
if [ -L $CONTENT_LINK ]; then
|
||||||
|
rm -f $CONTENT_LINK
|
||||||
|
logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" -- "$CONTENT_LINK removed."
|
||||||
|
fi
|
Loading…
Add table
Add a link
Reference in a new issue