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

70-usb-library.j2: Cleaner logging & error handling (e.g. exit code 1)

This commit is contained in:
A Holt 2025-02-11 03:45:52 -05:00 committed by GitHub
parent 2398313918
commit 94ca58aa0c
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,9 +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/" might be dangerous!)"
exit 1
fi
CONTENT_LINK="{{ doc_root }}/local_content/$CONTENT_LINK_USB"
logger -t "usb_lib (70-usb-library)" "Creating link from $CONTENT_LINK to $SHARE_DIR"
# '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"
rm -rf $CONTENT_LINK
ln -s $SHARE_DIR $CONTENT_LINK