diff --git a/roles/usb_lib/files/upload/error.php b/roles/usb_lib/files/upload/error.php
index 2e51003e0..46dd0e667 100644
--- a/roles/usb_lib/files/upload/error.php
+++ b/roles/usb_lib/files/upload/error.php
@@ -5,7 +5,7 @@
*/
?>
-ERROR: Please make sure one and ONLY one (no more, no less) removable USB stick is plugged into your Internet-in-a-Box. Please see IIAB FAQ, Can students upload their own work?, for additional support.
+ERROR: Please make sure one and ONLY one (no more, no less) removable USB stick is plugged into your Internet-in-a-Box. Please see IIAB FAQ, "Can students upload their own work?", for additional support.
diff --git a/roles/usb_lib/tasks/install.yml b/roles/usb_lib/tasks/install.yml
index e435719dc..f4c5d671e 100644
--- a/roles/usb_lib/tasks/install.yml
+++ b/roles/usb_lib/tasks/install.yml
@@ -67,7 +67,7 @@
group: "{{ apache_user }}" # 2020-02-13: changed from iiab_admin_user, after discussion on weekly call (#1228, #2222)
mode: 0775
-- name: 'Install from template: /etc/udev/rules.d/usbmount.rules, /etc/systemd/system/usbmount@.service, /usr/bin/iiab-usb_lib-show-all-on, /usr/bin/iiab-usb_lib-show-all-off, /usr/sbin/iiab-clean-usb.sh'
+- name: 'Install from template: /etc/udev/rules.d/usbmount.rules, /etc/systemd/system/usbmount@.service, /usr/sbin/iiab-clean-usb.sh'
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
@@ -75,8 +75,6 @@
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-usb_lib-show-all-on', dest: '/usr/bin/', mode: '0755' }
- - { src: 'iiab-usb_lib-show-all-off', dest: '/usr/bin/', mode: '0755' }
- { src: 'iiab-clean-usb.sh', dest: '/usr/sbin/', mode: '0755' }
- name: '2025-01-05: Add upload2usb app (#3875) directory to local_content'
@@ -90,7 +88,7 @@
- name: '2025-01-05: Copy upload2usb app (#3875) files from files/upload/ to local_content'
copy:
src: "{{ item }}"
- dest: "{{ doc_root }}/local_content/upload" # /library/www/html
+ dest: "{{ doc_root }}/local_content/upload/" # /library/www/html
with_fileglob:
- upload/*
diff --git a/roles/usb_lib/tasks/main.yml b/roles/usb_lib/tasks/main.yml
index 7836f2d3a..af9d22790 100644
--- a/roles/usb_lib/tasks/main.yml
+++ b/roles/usb_lib/tasks/main.yml
@@ -66,11 +66,12 @@
path: /etc/usbmount/mount.d/00_create_model_symlink
state: absent
-- name: Put variable in iiab.env that enables display of content at root of USB
- lineinfile:
- path: "{{ iiab_env_file }}"
- regexp: "^IIAB_USB_LIB_SHOW_ALL.*"
- line: "IIAB_USB_LIB_SHOW_ALL={{ iiab_usb_lib_show_all }}"
+# 20250125: using existence of PUBLIC folder on USB stick in lieu of this env variable.
+#- name: Put variable in iiab.env that enables display of content at root of USB
+# lineinfile:
+# path: "{{ iiab_env_file }}"
+# regexp: "^IIAB_USB_LIB_SHOW_ALL.*"
+# line: "IIAB_USB_LIB_SHOW_ALL={{ iiab_usb_lib_show_all }}"
- name: Add 'usb_lib' variable values to {{ iiab_ini_file }}
diff --git a/roles/usb_lib/tasks/nginx.yml b/roles/usb_lib/tasks/nginx.yml
index 7e572142a..1e6be6d21 100644
--- a/roles/usb_lib/tasks/nginx.yml
+++ b/roles/usb_lib/tasks/nginx.yml
@@ -1,20 +1,21 @@
- name: Install /etc/usbmount/mount.d/70-usb-library from template, if usb_lib_enabled
template:
- src: mount.d/70-usb-library
- dest: /etc/usbmount/mount.d/
+ src: mount.d/70-usb-library.j2
+ dest: /etc/usbmount/mount.d/70-usb-library
owner: root
group: root
mode: '0751'
when: usb_lib_enabled
-- name: Install /etc/usbmount/umount.d/70-usb-library from template, if usb_lib_enabled
- template:
- src: umount.d/70-usb-library
- dest: /etc/usbmount/umount.d
- owner: root
- group: root
- mode: '0751'
- when: usb_lib_enabled
+# 20250125: commenting out stale file, superseded by iiab-clean-usb.sh
+# - name: Install /etc/usbmount/umount.d/70-usb-library from template, if usb_lib_enabled
+# template:
+# src: umount.d/70-usb-library
+# dest: /etc/usbmount/umount.d
+# owner: root
+# group: root
+# mode: '0751'
+# when: usb_lib_enabled
- name: Remove /etc/usbmount/mount.d/70-usb-library if not usb_lib_enabled
file:
@@ -22,11 +23,12 @@
state: absent
when: not usb_lib_enabled
-- name: Remove /etc/usbmount/umount.d/70-usb-library if not usb_lib_enabled
- file:
- path: /etc/usbmount/umount.d/70-usb-library
- state: absent
- when: not usb_lib_enabled
+# 20250125: commenting out stale file, superseded by iiab-clean-usb.sh
+# - name: Remove /etc/usbmount/umount.d/70-usb-library if not usb_lib_enabled
+# file:
+# path: /etc/usbmount/umount.d/70-usb-library
+# state: absent
+# when: not usb_lib_enabled
- name: Restart 'nginx' systemd service
systemd:
diff --git a/roles/usb_lib/templates/iiab-clean-usb.sh b/roles/usb_lib/templates/iiab-clean-usb.sh
index a1876551c..56d63292d 100644
--- a/roles/usb_lib/templates/iiab-clean-usb.sh
+++ b/roles/usb_lib/templates/iiab-clean-usb.sh
@@ -5,10 +5,10 @@ DEVICE=`echo $@ | sed -s 's|-|/|'`
MNT_POINT=`findmnt -n /$DEVICE | awk '{print $1}'`
CONTENT_LINK_USB=`basename $MNT_POINT | awk '{print toupper($0)}'`
CONTENT_LINK="/library/www/html/local_content/$CONTENT_LINK_USB"
-logger -p user.notice -t "usbmount" -- "Attempting to remove link $CONTENT_LINK."
+logger -p user.notice -t "usb_lib (iiab-clean-usb.sh)" -- "Attempting to remove link $CONTENT_LINK."
if [ -L $CONTENT_LINK ]; then
/bin/rm $CONTENT_LINK
- logger -p user.notice -t "usbmount" -- "$CONTENT_LINK removed."
+ logger -p user.notice -t "usb_lib (iiab-clean-usb.sh)" -- "$CONTENT_LINK removed."
fi
diff --git a/roles/usb_lib/templates/iiab-usb_lib-show-all-off b/roles/usb_lib/templates/iiab-usb_lib-show-all-off.unused
similarity index 100%
rename from roles/usb_lib/templates/iiab-usb_lib-show-all-off
rename to roles/usb_lib/templates/iiab-usb_lib-show-all-off.unused
diff --git a/roles/usb_lib/templates/iiab-usb_lib-show-all-on b/roles/usb_lib/templates/iiab-usb_lib-show-all-on.unused
similarity index 100%
rename from roles/usb_lib/templates/iiab-usb_lib-show-all-on
rename to roles/usb_lib/templates/iiab-usb_lib-show-all-on.unused
diff --git a/roles/usb_lib/templates/mount.d/70-usb-library b/roles/usb_lib/templates/mount.d/70-usb-library
deleted file mode 100644
index 5b9cfefe8..000000000
--- a/roles/usb_lib/templates/mount.d/70-usb-library
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/bash
-# Create symlink in DocumentRoot/content to autmounted usb drive
-#
-# based on a similar script in the xs-rsync package
-# by Martin Langhoff
-#
-# and the adaptation for xs-activity-server by Douglas Bagnall
-#
-#
-# by Tim Moody tim@timmoody.com
-
-source {{ iiab_env_file }}
-case $IIAB_USB_LIB_SHOW_ALL in
-'True'|'true'|'TRUE')
- logger -p user.notice -t "70-usb-library" -- "Display entire USB drive is True. Checking for rootfs or /library on $UM_MOUNTPOINT."
- # regularize the variable
- IIAB_USB_LIB_SHOW_ALL=True
- ;;
-*)
- logger -p user.notice -t "70-usb-library" -- "Looking for /share, /Share, /Piratebox/Share, /USB, or /usb on $UM_MOUNTPOINT."
- ;;
-esac
-
-VERBOSE=yes
-
-SHARE_DIR=""
-# Only show content if in these directories
-
-if [ -d $UM_MOUNTPOINT/share ]; then
- SHARE_DIR="$UM_MOUNTPOINT/share"
-fi
-if [ -d $UM_MOUNTPOINT/Share ]; then
- SHARE_DIR="$UM_MOUNTPOINT/Share"
-fi
-if [ -d $UM_MOUNTPOINT/Piratebox/Share ]; then
- SHARE_DIR="$UM_MOUNTPOINT/Piratebox/Share"
-fi
-if [ -d $UM_MOUNTPOINT/USB ]; then
- SHARE_DIR="$UM_MOUNTPOINT/USB"
-fi
-if [ -d $UM_MOUNTPOINT/usb ]; then
- SHARE_DIR="$UM_MOUNTPOINT/usb"
-fi
-
-if [ "$IIAB_USB_LIB_SHOW_ALL" == "True" ]; then
- UM_DEV=`findmnt $UM_MOUNTPOINT | grep / | awk '{print $2}'`
- LIB_DEV=`findmnt /library | grep / | awk '{print $2}' |awk -F '[' '{print $1}'`
- ROOT_DEV=`findmnt / | grep / | awk '{print $2}'`
- if [ "$UM_DEV" == "$LIB_DEV" ]; then
- logger -p user.notice -t "70-usb-library" -- "skipping $UM_MOUNTPOINT containing /library"
- #echo "lib on dev"
- elif [ "$UM_DEV" == "$ROOT_DEV" ]; then
- logger -p user.notice -t "70-usb-library" -- "skipping $UM_MOUNTPOINT containing rootfs"
- #echo "rootfs on dev"
- else
- SHARE_DIR="$UM_MOUNTPOINT"
- fi
-fi
-
-if [ ! -z "$SHARE_DIR" ]; then
- logger -p user.notice -t "70-usb-library" -- "Found Share Directory $SHARE_DIR."
-else
- logger -p user.notice -t "70-usb-library" -- "did not find /share, /Share, /Piratebox/Share, /USB, or /usb on USB"
-fi
-
-
-if [ "$SHARE_DIR" != "" ];then
- CONTENT_LINK_USB=`basename $UM_MOUNTPOINT | awk '{print toupper($0)}'`
- CONTENT_LINK="{{ doc_root }}/local_content/$CONTENT_LINK_USB"
- logger -p user.notice -t "70-usb-library" -- "Creating link to $CONTENT_LINK."
- ln -s $SHARE_DIR $CONTENT_LINK
-fi
diff --git a/roles/usb_lib/templates/mount.d/70-usb-library.j2 b/roles/usb_lib/templates/mount.d/70-usb-library.j2
new file mode 100644
index 000000000..d124e79c0
--- /dev/null
+++ b/roles/usb_lib/templates/mount.d/70-usb-library.j2
@@ -0,0 +1,45 @@
+#!/bin/bash
+# Create symlink in DocumentRoot/content to automounted usb drive
+#
+# based on a similar script in the xs-rsync package
+# by Martin Langhoff
+#
+# and the adaptation for xs-activity-server by Douglas Bagnall
+#
+#
+# by Tim Moody tim@timmoody.com
+
+VERBOSE=yes
+
+# UM_MOUNTPOINT and UM_DEVICE are documented at: https://github.com/rbrito/usbmount#hook-scripts
+SHARE_DIR=$UM_MOUNTPOINT
+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
+ logger -p user.notice -t "usb_lib (70-usb-library)" -- "Did not find /PUBLIC on $UM_MOUNTPOINT"
+fi
+
+LIB_DEV=`findmnt /library | grep / | awk '{print $2}' | awk -F '[' '{print $1}'`
+ROOT_DEV=`findmnt / | grep / | awk '{print $2}'`
+BOOT_DEV=`findmnt /boot | grep / | awk '{print $2}'`
+BOOTFW_DEV=`findmnt /boot/firmware | grep / | awk '{print $2}'`
+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
+
+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 $SHARE_DIR to $CONTENT_LINK"
+ln -s $SHARE_DIR $CONTENT_LINK
+
diff --git a/roles/usb_lib/templates/umount.d/70-usb-library b/roles/usb_lib/templates/umount.d.unused/70-usb-library
similarity index 75%
rename from roles/usb_lib/templates/umount.d/70-usb-library
rename to roles/usb_lib/templates/umount.d.unused/70-usb-library
index 5af914c01..d8e095008 100644
--- a/roles/usb_lib/templates/umount.d/70-usb-library
+++ b/roles/usb_lib/templates/umount.d.unused/70-usb-library
@@ -12,7 +12,7 @@
CONTENT_LINK_USB=`basename $UM_MOUNTPOINT | awk '{print toupper($0)}'`
CONTENT_LINK="{{ doc_root }}/local_content/$CONTENT_LINK_USB"
-logger -p user.notice -t "70-usb-library" -- "Attempting to remove link $CONTENT_LINK."
+logger -p user.notice -t "usb_lib (70-usb-library)" -- "Attempting to remove link $CONTENT_LINK."
if [ -L $CONTENT_LINK ]; then
{% if is_debuntu %}
@@ -20,5 +20,5 @@ if [ -L $CONTENT_LINK ]; then
{% else %}
/usr/bin/rm -f $CONTENT_LINK
{% endif %}
- logger -p user.notice -t "70-usb-library" -- "$CONTENT_LINK removed."
+ logger -p user.notice -t "usb_lib (70-usb-library)" -- "$CONTENT_LINK removed."
fi
diff --git a/vars/default_vars.yml b/vars/default_vars.yml
index 4494cbd72..c42a4ca99 100644
--- a/vars/default_vars.yml
+++ b/vars/default_vars.yml
@@ -308,7 +308,8 @@ bluetooth_term_enabled: False
usb_lib_install: True
usb_lib_enabled: True
# Show entire contents of USB sticks/drives (at http://box/usb)
-iiab_usb_lib_show_all: True
+# 20250125: using existence of PUBLIC folder on USB stick in lieu of this env variable.
+# iiab_usb_lib_show_all: True
# Set umask=0000 for VFAT, NTFS and exFAT in /etc/usbmount/usbmount.conf so
# Kolibri can export & import channels to USB sticks/drive:
usb_lib_umask0000_for_kolibri: True
diff --git a/vars/local_vars_large.yml b/vars/local_vars_large.yml
index 920cf7ba1..c84b30736 100644
--- a/vars/local_vars_large.yml
+++ b/vars/local_vars_large.yml
@@ -193,7 +193,8 @@ bluetooth_enabled: False
bluetooth_term_enabled: False
# Show entire contents of USB sticks/drives (at http://box/usb)
-iiab_usb_lib_show_all: True
+# 20250125: using existence of PUBLIC folder on USB stick in lieu of this env variable.
+# iiab_usb_lib_show_all: True
# Set umask=0000 for VFAT, NTFS and exFAT in /etc/usbmount/usbmount.conf so
# Kolibri can export & import channels to USB sticks/drive:
usb_lib_umask0000_for_kolibri: True
diff --git a/vars/local_vars_medium.yml b/vars/local_vars_medium.yml
index a554dc34b..ff46f8a9b 100644
--- a/vars/local_vars_medium.yml
+++ b/vars/local_vars_medium.yml
@@ -193,7 +193,8 @@ bluetooth_enabled: False
bluetooth_term_enabled: False
# Show entire contents of USB sticks/drives (at http://box/usb)
-iiab_usb_lib_show_all: True
+# 20250125: using existence of PUBLIC folder on USB stick in lieu of this env variable.
+# iiab_usb_lib_show_all: True
# Set umask=0000 for VFAT, NTFS and exFAT in /etc/usbmount/usbmount.conf so
# Kolibri can export & import channels to USB sticks/drive:
usb_lib_umask0000_for_kolibri: True
diff --git a/vars/local_vars_small.yml b/vars/local_vars_small.yml
index 8689b3ae9..1190ec377 100644
--- a/vars/local_vars_small.yml
+++ b/vars/local_vars_small.yml
@@ -193,7 +193,8 @@ bluetooth_enabled: False
bluetooth_term_enabled: False
# Show entire contents of USB sticks/drives (at http://box/usb)
-iiab_usb_lib_show_all: True
+# 20250125: using existence of PUBLIC folder on USB stick in lieu of this env variable.
+# iiab_usb_lib_show_all: True
# Set umask=0000 for VFAT, NTFS and exFAT in /etc/usbmount/usbmount.conf so
# Kolibri can export & import channels to USB sticks/drive:
usb_lib_umask0000_for_kolibri: True
diff --git a/vars/local_vars_unittest.yml b/vars/local_vars_unittest.yml
index 30720a49e..744148cc0 100644
--- a/vars/local_vars_unittest.yml
+++ b/vars/local_vars_unittest.yml
@@ -199,7 +199,8 @@ bluetooth_enabled: False
bluetooth_term_enabled: False
# Show entire contents of USB sticks/drives (at http://box/usb)
-iiab_usb_lib_show_all: True
+# 20250125: using existence of PUBLIC folder on USB stick in lieu of this env variable.
+# iiab_usb_lib_show_all: True
# Set umask=0000 for VFAT, NTFS and exFAT in /etc/usbmount/usbmount.conf so
# Kolibri can export & import channels to USB sticks/drive:
usb_lib_umask0000_for_kolibri: True