1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-12 03:05:34 +00:00

Merge pull request #3939 from holta/force-link-to-usb

70-usb-library.j2: Forcibly delete e.g. stale symlink /library/www/html/local_content/USB0 during USB stick insertion
This commit is contained in:
A Holt 2025-02-11 11:38:10 -05:00 committed by GitHub
commit 543a0e9b0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,16 +31,16 @@ logger -t "usb_lib (70-usb-library)" "BOOTFW_DEV is: $BOOTFW_DEV"
if [ "$UM_DEV" == "$LIB_DEV" ]; then
logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /library"
exit
exit 1
elif [ "$UM_DEV" == "$ROOT_DEV" ]; then
logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing rootfs"
exit
exit 1
elif [ "$UM_DEV" == "$BOOT_DEV" ]; then
logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /boot"
exit
exit 1
elif [ "$UM_DEV" == "$BOOTFW_DEV" ]; then
logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /boot/firmware"
exit
exit 1
fi
# 2025-01-25: Check for existence of folder PUBLIC on USB stick: if found, the stick will not be completely browsable.
@ -55,6 +55,13 @@ else
fi
CONTENT_LINK_USB=$(basename $UM_MOUNTPOINT | awk '{print toupper($0)}')
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!)'
exit 1
fi
CONTENT_LINK="{{ doc_root }}/local_content/$CONTENT_LINK_USB"
# '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
logger -t "usb_lib (70-usb-library)" "Creating link from $CONTENT_LINK to $SHARE_DIR"
ln -sf $SHARE_DIR $CONTENT_LINK
rm -rf $CONTENT_LINK
ln -s $SHARE_DIR $CONTENT_LINK