mirror of
https://github.com/iiab/iiab.git
synced 2025-02-12 11:12:06 +00:00
usb_lib/*, vars/*: prevent Cheating (Copying) of homeworks, when teacher creates 'PUBLIC' folder on their USB stick
This commit is contained in:
parent
b0ef084ac8
commit
7c2f0c9c6e
15 changed files with 85 additions and 106 deletions
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
?>
|
||||
ERROR: Please make sure <span style="color:red; font-weight:bold;"> one and ONLY one </span>(no more, no less) removable USB stick is plugged into your Internet-in-a-Box. Please see IIAB FAQ, <a href="https://wiki.iiab.io/go/FAQ#Can_students_upload_their_own_work%3F" style="font-style:italic;">Can students upload their own work?,</a> for additional support.
|
||||
ERROR: Please make sure <span style="color:red; font-weight:bold;"> one and ONLY one </span>(no more, no less) removable USB stick is plugged into your Internet-in-a-Box. Please see IIAB FAQ, "<a href="https://wiki.iiab.io/go/FAQ#Can_students_upload_their_own_work%3F" style="font-weight:bold;">Can students upload their own work?</a>", for additional support.
|
||||
|
||||
<br/><br/>
|
||||
|
||||
|
|
|
@ -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/*
|
||||
|
||||
|
|
|
@ -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 }}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <martin@laptop.org>
|
||||
#
|
||||
# and the adaptation for xs-activity-server by Douglas Bagnall
|
||||
# <douglas@paradise.net.nz>
|
||||
#
|
||||
# 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
|
45
roles/usb_lib/templates/mount.d/70-usb-library.j2
Normal file
45
roles/usb_lib/templates/mount.d/70-usb-library.j2
Normal file
|
@ -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 <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
|
||||
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
|
||||
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue