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

usb_lib / usbmount: Refine, lint, clarify

This commit is contained in:
root 2025-01-31 01:41:23 -05:00
parent 80bdfc677e
commit 6b4b94dae2
11 changed files with 26 additions and 29 deletions

View file

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

@ -52,7 +52,7 @@
# deb: "{{ iiab_download_url }}/usbmount_0.0.22_all.deb" # deb: "{{ iiab_download_url }}/usbmount_0.0.22_all.deb"
# # when: is_debian # # when: is_debian
- name: Install lockfile-progs util-linux for usbmount from OS repo - name: Install lockfile-progs and util-linux for usbmount from OS repo
package: package:
name: name:
- lockfile-progs - lockfile-progs
@ -62,19 +62,16 @@
- name: Add dir {{ doc_root }}/local_content, where USB drive links can appear (0775) owned by {{ apache_user }}:{{ apache_user }} - name: Add dir {{ doc_root }}/local_content, where USB drive links can appear (0775) owned by {{ apache_user }}:{{ apache_user }}
file: file:
state: directory state: directory
path: "{{ doc_root }}/local_content" path: "{{ doc_root }}/local_content" # /library/www/html
owner: "{{ apache_user }}" owner: "{{ apache_user }}" # www-data
group: "{{ apache_user }}" # 2020-02-13: changed from iiab_admin_user, after discussion on weekly call (#1228, #2222) group: "{{ apache_user }}" # 2020-02-13: changed from iiab_admin_user, after discussion on weekly call (#1228, #2222)
mode: 0775 mode: 0775
- name: Set up dirs /etc/usbmount/mount.d, /etc/usbmount/umount.d, /media/usb0-7 - name: Set up dirs /etc/usbmount/mount.d, /etc/usbmount/umount.d, /media/usb0-7
file: file:
path: "{{ item }}"
# owner: root
# group: root
# mode: '0755'
mode: 0644
state: directory state: directory
path: "{{ item }}"
mode: 0755
with_items: with_items:
- /etc/usbmount/mount.d - /etc/usbmount/mount.d
- /etc/usbmount/umount.d - /etc/usbmount/umount.d
@ -87,7 +84,7 @@
- /media/usb6 - /media/usb6
- /media/usb7 - /media/usb7
- name: '2025-01-25: Copy files from files/usbmount to filesystem' - name: Copy files from files/usbmount to filesystem
copy: copy:
src: "{{ item.src }}" src: "{{ item.src }}"
dest: "{{ item.dest }}" dest: "{{ item.dest }}"
@ -106,7 +103,7 @@
- { src: 'usbmount@.service.j2', dest: '/etc/systemd/system/usbmount@.service', 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' } - { src: 'iiab-clean-usb.sh', dest: '/usr/local/sbin/', mode: '0755' }
- name: '2025-01-05: Add upload2usb app (#3875) directory to doc_root' - name: Add dir {{ doc_root }}/upload2usb (0775) owned by {{ apache_user }}:{{ apache_user }}
file: file:
state: directory state: directory
path: "{{ doc_root }}/upload2usb" path: "{{ doc_root }}/upload2usb"
@ -114,12 +111,12 @@
group: "{{ apache_user }}" group: "{{ apache_user }}"
mode: 0755 mode: 0755
- name: '2025-01-05: Copy upload2usb app (#3875) files from files/upload/ into {{ doc_root }}/upload2usb/' - name: Copy files from files/upload2usb/ into {{ doc_root }}/upload2usb/
copy: copy:
src: "{{ item }}" src: "{{ item }}"
dest: "{{ doc_root }}/upload2usb/" # /library/www/html dest: "{{ doc_root }}/upload2usb/"
with_fileglob: with_fileglob:
- upload/* - upload2usb/*
# 2021-03-21: If usbmount is repackaged by apt as a result of Linux kernel 5.4+ # 2021-03-21: If usbmount is repackaged by apt as a result of Linux kernel 5.4+
# supporting exFAT, the stanza below (might) in future no longer be needed... # supporting exFAT, the stanza below (might) in future no longer be needed...

View file

@ -1,14 +1,14 @@
#!/bin/bash #!/bin/bash
# Remove symlink in /library/content to automounted usb drive # Remove symlink in /library/www/html/local_content to automounted USB drive
#
DEVICE=$(echo $@ | sed -s 's|-|/|') DEVICE="/$(echo $1 | sed 's|-|/|')"
MNT_POINT=$(findmnt -n /$DEVICE | awk '{print $1}') MNT_POINT=$(findmnt -no target $DEVICE)
CONTENT_LINK_USB=$(basename $MNT_POINT | awk '{print toupper($0)}') CONTENT_LINK_USB=$(basename $MNT_POINT | awk '{print toupper($0)}')
CONTENT_LINK="/library/www/html/local_content/$CONTENT_LINK_USB" CONTENT_LINK="/library/www/html/local_content/$CONTENT_LINK_USB"
logger -p user.notice -t "usb_lib (iiab-clean-usb.sh)" -- "Attempting to remove link $CONTENT_LINK, as auto-created earlier by usbmount."
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 if [ -L $CONTENT_LINK ]; then
/bin/rm $CONTENT_LINK /usr/bin/rm $CONTENT_LINK
logger -p user.notice -t "usb_lib (iiab-clean-usb.sh)" -- "$CONTENT_LINK removed, as auto-created earlier by usbmount." logger -t "usb_lib (iiab-clean-usb.sh)" "Symlink $CONTENT_LINK removed, as auto-created earlier by usbmount."
fi fi

View file

@ -30,16 +30,16 @@ logger -t "usb_lib (70-usb-library)" "BOOT_DEV is: $BOOT_DEV"
logger -t "usb_lib (70-usb-library)" "BOOTFW_DEV is: $BOOTFW_DEV" logger -t "usb_lib (70-usb-library)" "BOOTFW_DEV is: $BOOTFW_DEV"
if [ "$UM_DEV" == "$LIB_DEV" ]; then if [ "$UM_DEV" == "$LIB_DEV" ]; then
logger -p user.notice -t "usb_lib (70-usb-library)" -- "Skipping $UM_MOUNTPOINT containing /library" logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /library"
exit exit
elif [ "$UM_DEV" == "$ROOT_DEV" ]; then elif [ "$UM_DEV" == "$ROOT_DEV" ]; then
logger -p user.notice -t "usb_lib (70-usb-library)" -- "Skipping $UM_MOUNTPOINT containing rootfs" logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing rootfs"
exit exit
elif [ "$UM_DEV" == "$BOOT_DEV" ]; then elif [ "$UM_DEV" == "$BOOT_DEV" ]; then
logger -p user.notice -t "usb_lib (70-usb-library)" -- "Skipping $UM_MOUNTPOINT containing /boot" logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /boot"
exit exit
elif [ "$UM_DEV" == "$BOOTFW_DEV" ]; then elif [ "$UM_DEV" == "$BOOTFW_DEV" ]; then
logger -p user.notice -t "usb_lib (70-usb-library)" -- "Skipping $UM_MOUNTPOINT containing /boot/firmware" logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /boot/firmware"
exit exit
fi fi
@ -48,13 +48,13 @@ 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 -p user.notice -t "usb_lib (70-usb-library)" -- "Found /PUBLIC on $UM_MOUNTPOINT" logger -t "usb_lib (70-usb-library)" "Found /PUBLIC on $UM_MOUNTPOINT"
else else
SHARE_DIR=$UM_MOUNTPOINT SHARE_DIR=$UM_MOUNTPOINT
logger -p user.notice -t "usb_lib (70-usb-library)" -- "Did not find /PUBLIC on $UM_MOUNTPOINT" logger -t "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)}')
CONTENT_LINK="{{ doc_root }}/local_content/$CONTENT_LINK_USB" 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" logger -t "usb_lib (70-usb-library)" "Creating link from $CONTENT_LINK to $SHARE_DIR"
ln -s $SHARE_DIR $CONTENT_LINK ln -sf $SHARE_DIR $CONTENT_LINK