mirror of
https://github.com/iiab/iiab.git
synced 2025-02-15 04:32:11 +00:00
47 lines
1.9 KiB
Django/Jinja
47 lines
1.9 KiB
Django/Jinja
#!/bin/bash
|
|
# Create symlink in DocumentRoot/content to automounted 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
|
|
|
|
VERBOSE=yes
|
|
|
|
# UM_MOUNTPOINT and UM_DEVICE are documented at: https://github.com/rbrito/usbmount#hook-scripts
|
|
|
|
# 2022-06-16 better security thanks to @tim-moody and @jvonau:
|
|
# https://github.com/iiab/iiab/pull/3254
|
|
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)
|
|
if [ "$UM_DEVICE" == "$LIB_DEV" ]; then
|
|
logger -p user.notice -t "usb_lib (70-usb-library)" -- "Skipping $UM_MOUNTPOINT containing /library"
|
|
exit
|
|
elif [ "$UM_DEVICE" == "$ROOT_DEV" ]; then
|
|
logger -p user.notice -t "usb_lib (70-usb-library)" -- "Skipping $UM_MOUNTPOINT containing rootfs"
|
|
exit
|
|
elif [ "$UM_DEVICE" == "$BOOT_DEV" ]; then
|
|
logger -p user.notice -t "usb_lib (70-usb-library)" -- "Skipping $UM_MOUNTPOINT containing /boot"
|
|
exit
|
|
elif [ "$UM_DEVICE" == "$BOOTFW_DEV" ]; then
|
|
logger -p user.notice -t "usb_lib (70-usb-library)" -- "Skipping $UM_MOUNTPOINT containing /boot/firmware"
|
|
exit
|
|
fi
|
|
|
|
if [ -d $UM_MOUNTPOINT/PUBLIC ]; then
|
|
SHARE_DIR=$UM_MOUNTPOINT/PUBLIC
|
|
logger -p user.notice -t "usb_lib (70-usb-library)" -- "Found /PUBLIC on $UM_MOUNTPOINT"
|
|
else
|
|
SHARE_DIR=$UM_MOUNTPOINT
|
|
logger -p user.notice -t "usb_lib (70-usb-library)" -- "Did not find /PUBLIC on $UM_MOUNTPOINT"
|
|
fi
|
|
|
|
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)" -- "Creating link from $CONTENT_LINK to $SHARE_DIR"
|
|
ln -s $SHARE_DIR $CONTENT_LINK
|