diff --git a/roles/usb_lib/files/usbmount/iiab-clean-usb.sh.unused b/roles/usb_lib/files/usbmount/iiab-clean-usb.sh.unused new file mode 100644 index 000000000..ee4eee19b --- /dev/null +++ b/roles/usb_lib/files/usbmount/iiab-clean-usb.sh.unused @@ -0,0 +1,18 @@ +#!/bin/bash +# Remove symlink in /library/www/html/local_content to automounted USB drive +# exported +#UM_DEVICE="$DEVNAME" +#UM_MOUNTPOINT="$mountpoint" +#UM_FILESYSTEM="$fstype" + +#DEVICE="/$(echo $1 | sed 's|-|/|')" +#MNT_POINT=$(findmnt -no target $DEVICE) +CONTENT_LINK_USB=$(basename "$UM_MOUNTPOINT" | awk '{print toupper($0)}') +CONTENT_LINK="/library/www/html/local_content/$CONTENT_LINK_USB" + +logger -t "usbmount (iiab-clean-usb.sh)" "Attempting to remove symlink $CONTENT_LINK, as auto-created earlier by usb_lib." + +if [ -L $CONTENT_LINK ]; then + /usr/bin/rm $CONTENT_LINK + logger -t "usbmount (iiab-clean-usb.sh)" "Symlink $CONTENT_LINK removed, as auto-created earlier by usb_lib." +fi diff --git a/roles/usb_lib/files/usbmount/usbmount b/roles/usb_lib/files/usbmount/usbmount index 8104564e7..e6a153966 100644 --- a/roles/usb_lib/files/usbmount/usbmount +++ b/roles/usb_lib/files/usbmount/usbmount @@ -24,8 +24,8 @@ exec > /dev/null 2>&1 # Log a string via the syslog facility. log() { - if [ $1 != debug ] || expr "$VERBOSE" : "[yY]" > /dev/null; then - logger -p user.$1 -t "usbmount[$$]" -- "$2" + if [ "$1" != debug ] || expr "$VERBOSE" : "[yY]" > /dev/null; then + logger -p user."$1" -t "usbmount[$$]" -- "$2" fi } @@ -83,22 +83,22 @@ if [ "$1" = add ]; then # Acquire lock. log debug "trying to acquire lock /var/run/usbmount/.mount.lock" lockfile-create --retry 6 /var/run/usbmount/.mount || \ - { log err "cannot acquire lock /var/run/usbmount/.mount.lock"; exit 1; } + { log err "cannot acquire lock /var/run/usbmount/.mount.lock"; exit 1; } trap '( lockfile-remove /var/run/usbmount/.mount )' 0 log debug "acquired lock /var/run/usbmount/.mount.lock" # Grab device information from device and "divide it" # FIXME: improvement: implement mounting by label (notice that labels # can contain spaces, which makes things a little bit less comfortable). - DEVINFO=$(/sbin/blkid -p $DEVNAME) + DEVINFO=$(/sbin/blkid -p "/$DEVNAME") FSTYPE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]TYPE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;') UUID=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]UUID="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;') USAGE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]USAGE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;') - if ! echo $USAGE | egrep -q "(filesystem|disklabel)"; then + if ! echo "$USAGE" | grep -E "(filesystem|disklabel)"; then log debug "/$DEVNAME does not contain a filesystem or disklabel" lockfile-remove /var/run/usbmount/.mount - exit + exit fi log debug "/$DEVNAME contains filesystem type $FSTYPE" @@ -109,29 +109,29 @@ if [ "$1" = add ]; then BOOT_DEV=$(/usr/bin/findmnt -no source /boot) log debug "BOOT_DEV $BOOT_DEV" - if [ $BOOTFW_DEV = /$DEVNAME ]; then - log debug "skipping BOOTFS_DEV $BOOTFS_DEV mounted at /boot/firmware" + if [ "$BOOTFW_DEV" = /"$DEVNAME" ]; then + log debug "skipping BOOTFW_DEV $BOOTFW_DEV mounted at /boot/firmware" lockfile-remove /var/run/usbmount/.mount exit - elif [ $ROOT_DEV = /$DEVNAME ]; then + elif [ "$ROOT_DEV" = /"$DEVNAME" ]; then log debug "skipping ROOT_DEV $ROOT_DEV mounted at /" lockfile-remove /var/run/usbmount/.mount exit - elif [ $BOOT_DEV = /$DEVNAME ]; then + elif [ "$BOOT_DEV" = /"$DEVNAME" ]; then log debug "skipping BOOT_DEV $BOOT_DEV mount as /boot" lockfile-remove /var/run/usbmount/.mount exit fi # Try to use specifications in /etc/fstab to skip. - if egrep -q "^[[:blank:]]*$DEVNAME" /etc/fstab; then + if grep -Eq "^[[:blank:]]*$DEVNAME" /etc/fstab; then log debug "skipping /$DEVNAME exit" lockfile-remove /var/run/usbmount/.mount exit - elif grep -q "^[[:blank:]]*UUID=$UUID" /etc/fstab; then + elif grep -Eq "^[[:blank:]]*UUID=$UUID" /etc/fstab; then log debug "skipping $UUID" lockfile-remove /var/run/usbmount/.mount - exit + exit else log debug "/$DEVNAME contains filesystem type $FSTYPE" fstype=$FSTYPE @@ -142,7 +142,7 @@ if [ "$1" = add ]; then for v in $MOUNTPOINTS; do if [ -d "$v" ] && ! grep -q "^[^ ][^ ]* *$v " /proc/mounts; then mountpoint="$v" - log debug "mountpoint $mountpoint is available for /$DEVNAME" + log debug "mountpoint $mountpoint is available for /$DEVNAME" break fi done @@ -155,74 +155,76 @@ if [ "$1" = add ]; then break fi done - if [ -n "$MOUNTOPTIONS" ]; then - options="$MOUNTOPTIONS${options:+,$options}" + if [ -n "$MOUNTOPTIONS" ]; then + options="$MOUNTOPTIONS${options:+,$options}" + fi + + # Mount the filesystem. + log info "executing command: mount -t$fstype ${options:+-o$options} /$DEVNAME $mountpoint" + mount "-t$fstype" "${options:+-o$options}" "/$DEVNAME" "$mountpoint" + + # Determine vendor and model. + vendor= + if [ -r "/sys$DEVPATH/device/vendor" ]; then + vendor="$(cat \"/sys"$DEVPATH"/device/vendor\")" + elif [ -r "/sys$DEVPATH/../device/vendor" ]; then + vendor="$(cat \"/sys"$DEVPATH"/../device/vendor\")" + elif [ -r "/sys$DEVPATH/device/../manufacturer" ]; then + vendor="$(cat \"/sys"$DEVPATH"/device/../manufacturer\")" + elif [ -r "/sys$DEVPATH/../device/../manufacturer" ]; then + vendor="$(cat \"/sys"$DEVPATH"/../device/../manufacturer\")" + fi + vendor="$(echo "$vendor" | sed 's/^[[:blank:]]\+//; s/[[:blank:]]\+$//')" + + model= + if [ -r "/sys$DEVPATH/device/model" ]; then + model="$(cat \"/sys"$DEVPATH"/device/model\")" + elif [ -r "/sys$DEVPATH/../device/model" ]; then + model="$(cat \"/sys"$DEVPATH"/../device/model\")" + elif [ -r "/sys$DEVPATH/device/../product" ]; then + model="$(cat \"/sys"$DEVPATH"/device/../product\")" + elif [ -r "/sys$DEVPATH/../device/../product" ]; then + model="$(cat \"/sys"$DEVPATH"/../device/../product\")" + fi + model="$(echo "$model" | sed 's/^[[:blank:]]\+//; s/[[:blank:]]\+$//')" + + # Run hook scripts; ignore errors. + export UM_DEVICE="/$DEVNAME" + export UM_MOUNTPOINT="$mountpoint" + export UM_FILESYSTEM="$fstype" + export UM_MOUNTOPTIONS="$options" + export UM_VENDOR="$vendor" + export UM_MODEL="$model" + log info "executing command: run-parts /etc/usbmount/mount.d" + run-parts /etc/usbmount/mount.d || : + else + # No suitable mount point found. + log warning "no mountpoint found for /$DEVNAME" + exit 1 fi - - # Mount the filesystem. - log info "executing command: mount -t$fstype ${options:+-o$options} $DEVNAME $mountpoint" - mount "-t$fstype" "${options:+-o$options}" "$DEVNAME" "$mountpoint" - - # Determine vendor and model. - vendor= - if [ -r "/sys$DEVPATH/device/vendor" ]; then - vendor="`cat \"/sys$DEVPATH/device/vendor\"`" - elif [ -r "/sys$DEVPATH/../device/vendor" ]; then - vendor="`cat \"/sys$DEVPATH/../device/vendor\"`" - elif [ -r "/sys$DEVPATH/device/../manufacturer" ]; then - vendor="`cat \"/sys$DEVPATH/device/../manufacturer\"`" - elif [ -r "/sys$DEVPATH/../device/../manufacturer" ]; then - vendor="`cat \"/sys$DEVPATH/../device/../manufacturer\"`" - fi - vendor="$(echo "$vendor" | sed 's/^[[:blank:]]\+//; s/[[:blank:]]\+$//')" - - model= - if [ -r "/sys$DEVPATH/device/model" ]; then - model="`cat \"/sys$DEVPATH/device/model\"`" - elif [ -r "/sys$DEVPATH/../device/model" ]; then - model="`cat \"/sys$DEVPATH/../device/model\"`" - elif [ -r "/sys$DEVPATH/device/../product" ]; then - model="`cat \"/sys$DEVPATH/device/../product\"`" - elif [ -r "/sys$DEVPATH/../device/../product" ]; then - model="`cat \"/sys$DEVPATH/../device/../product\"`" - fi - model="$(echo "$model" | sed 's/^[[:blank:]]\+//; s/[[:blank:]]\+$//')" - - # Run hook scripts; ignore errors. - export UM_DEVICE="$DEVNAME" - export UM_MOUNTPOINT="$mountpoint" - export UM_FILESYSTEM="$fstype" - export UM_MOUNTOPTIONS="$options" - export UM_VENDOR="$vendor" - export UM_MODEL="$model" - log info "executing command: run-parts /etc/usbmount/mount.d" - run-parts /etc/usbmount/mount.d || : - else - # No suitable mount point found. - log warning "no mountpoint found for $DEVNAME" - exit 1 fi - fi -fi + fi elif [ "$1" = remove ]; then + log debug "DEVNAME is /$DEVNAME" # A block or partition device has been removed. # Test if it is mounted. - while read device mountpoint fstype remainder; do - if [ "$DEVNAME" = "$device" ]; then - # If the mountpoint and filesystem type are maintained by - # this script, unmount the filesystem. - if in_list "$mountpoint" "$MOUNTPOINTS" && - in_list "$fstype" "$FILESYSTEMS"; then - log info "executing command: umount -l $mountpoint" - umount -l "$mountpoint" - + while read -r device mountpoint fstype junk; do + if [ "/$DEVNAME" = "$device" ]; then + log debug "umount device is $device" + log debug "umount fstype is $fstype" + # If the mountpoint and filesystem type are maintained by + # this script, unmount the filesystem. + if in_list "$mountpoint" "$MOUNTPOINTS"; then # Run hook scripts; ignore errors. - export UM_DEVICE="$DEVNAME" + log debug "umount mountpoint is $mountpoint" + export UM_DEVICE="$device" export UM_MOUNTPOINT="$mountpoint" export UM_FILESYSTEM="$fstype" log info "executing command: run-parts /etc/usbmount/umount.d" run-parts /etc/usbmount/umount.d || : + log info "executing command: umount -l $mountpoint" + umount -l "$mountpoint" fi break fi diff --git a/roles/usb_lib/templates/usbmount.rules.j2 b/roles/usb_lib/files/usbmount/usbmount.rules similarity index 71% rename from roles/usb_lib/templates/usbmount.rules.j2 rename to roles/usb_lib/files/usbmount/usbmount.rules index 939a31041..0e64d56e3 100644 --- a/roles/usb_lib/templates/usbmount.rules.j2 +++ b/roles/usb_lib/files/usbmount/usbmount.rules @@ -1,3 +1,2 @@ ACTION=="add", SUBSYSTEMS=="usb", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem" PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c" -ACTION=="remove", SUBSYSTEMS=="usb", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem" PROGRAM="/bin/systemd-escape -p /usr/share/usbmount/usbmount remove" - +ACTION=="remove", SUBSYSTEMS=="usb", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem" PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}" diff --git a/roles/usb_lib/templates/usbmount@.service.j2 b/roles/usb_lib/files/usbmount/usbmount@.service similarity index 77% rename from roles/usb_lib/templates/usbmount@.service.j2 rename to roles/usb_lib/files/usbmount/usbmount@.service index 6cf1f990b..dc0025915 100644 --- a/roles/usb_lib/templates/usbmount@.service.j2 +++ b/roles/usb_lib/files/usbmount/usbmount@.service @@ -9,7 +9,6 @@ ConditionPathExists=/var/run TimeoutStartSec=0 Environment=DEVNAME=%I ExecStart=/usr/local/sbin/usbmount add -ExecStop=/usr/local/sbin/iiab-clean-usb.sh %I -ExecStopPost=/bin/umount /%I +ExecStop=/usr/local/sbin/usbmount remove RemainAfterExit=yes RuntimeDirectory=usbmount diff --git a/roles/usb_lib/tasks/install.yml b/roles/usb_lib/tasks/install.yml index 660df7eb2..96ec0eaa2 100644 --- a/roles/usb_lib/tasks/install.yml +++ b/roles/usb_lib/tasks/install.yml @@ -93,16 +93,8 @@ with_items: - { src: 'usbmount/usbmount.conf', dest: '/etc/usbmount/', mode: '0644' } - { src: 'usbmount/usbmount', dest: '/usr/local/sbin/', mode: '0755' } - -- name: 'Install from template: /etc/udev/rules.d/usbmount.rules, /etc/systemd/system/usbmount@.service, /usr/local/sbin/iiab-clean-usb.sh' - template: - src: "{{ item.src }}" - dest: "{{ item.dest }}" - mode: "{{ item.mode }}" - 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-clean-usb.sh', dest: '/usr/local/sbin/', mode: '0755' } + - { src: 'usbmount/usbmount.rules', dest: '/etc/udev/rules.d/usbmount.rules', mode: '0644' } + - { src: 'usbmount/usbmount@.service', dest: '/etc/systemd/system/usbmount@.service', mode: '0644' } - name: Add dir {{ doc_root }}/upload2usb (0775) owned by {{ apache_user }}:{{ apache_user }} file: diff --git a/roles/usb_lib/tasks/nginx.yml b/roles/usb_lib/tasks/nginx.yml index 1e6be6d21..3e47dad8f 100644 --- a/roles/usb_lib/tasks/nginx.yml +++ b/roles/usb_lib/tasks/nginx.yml @@ -1,3 +1,11 @@ +- name: Install /etc/usbmount/umount.d/70-usb-library from template + template: + src: umount.d/70-usb-library.j2 + dest: /etc/usbmount/umount.d/70-usb-library + owner: root + group: root + mode: '0751' + - name: Install /etc/usbmount/mount.d/70-usb-library from template, if usb_lib_enabled template: src: mount.d/70-usb-library.j2 diff --git a/roles/usb_lib/templates/iiab-clean-usb.sh b/roles/usb_lib/templates/iiab-clean-usb.sh deleted file mode 100644 index 360d737f4..000000000 --- a/roles/usb_lib/templates/iiab-clean-usb.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# Remove symlink in /library/www/html/local_content to automounted USB drive - -DEVICE="/$(echo $1 | sed 's|-|/|')" -MNT_POINT=$(findmnt -no target $DEVICE) -CONTENT_LINK_USB=$(basename $MNT_POINT | awk '{print toupper($0)}') -CONTENT_LINK="/library/www/html/local_content/$CONTENT_LINK_USB" - -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 - /usr/bin/rm $CONTENT_LINK - logger -t "usb_lib (iiab-clean-usb.sh)" "Symlink $CONTENT_LINK removed, as auto-created earlier by usbmount." -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 index 8263bde1f..b8df7613f 100644 --- a/roles/usb_lib/templates/mount.d/70-usb-library.j2 +++ b/roles/usb_lib/templates/mount.d/70-usb-library.j2 @@ -8,38 +8,32 @@ # # # by Tim Moody tim@timmoody.com +# Jerry Vonau jvonau3@gmail.com +# +# exported from usbmount +# UM_DEVICE="$device" +# UM_MOUNTPOINT="$mountpoint" +# UM_FILESYSTEM="$fstype" +# UM_MOUNTOPTIONS="$options" +# UM_VENDOR="$vendor" +# UM_MODEL="$model" +# UM_MOUNTPOINT is documented at: https://github.com/rbrito/usbmount#hook-scripts # Better to set this in /etc/usbmount/usbmount.conf # VERBOSE=yes -# UM_MOUNTPOINT is documented at: https://github.com/rbrito/usbmount#hook-scripts -UM_DEV=$(findmnt -no source $UM_MOUNTPOINT) +logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "UM_MOUNTPOINT is: $UM_MOUNTPOINT" +logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "UM_DEVICE is: $UM_DEVICE" # 2022-06-16 better security thanks to @tim-moody and @jvonau: # https://github.com/iiab/iiab/pull/3254 LIB_DEV=$(findmnt -no source /library | cut -d '[' -f 1) -ROOT_DEV=$(findmnt -no source /) -BOOT_DEV=$(findmnt -no source /boot) -BOOTFW_DEV=$(findmnt -no source /boot/firmware) # Verbose logging to illuminate occasional boot bugginess: -logger -t "usb_lib (70-usb-library)" "UM_DEV is: $UM_DEV" -logger -t "usb_lib (70-usb-library)" "LIB_DEV is: $LIB_DEV" -logger -t "usb_lib (70-usb-library)" "ROOT_DEV is: $ROOT_DEV" -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 -p user.notice -t "usbmount - usb_lib (70-usb-library)" "LIB_DEV is: $LIB_DEV" -if [ "$UM_DEV" == "$LIB_DEV" ]; then - logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /library" - exit 1 -elif [ "$UM_DEV" == "$ROOT_DEV" ]; then - logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing rootfs" - exit 1 -elif [ "$UM_DEV" == "$BOOT_DEV" ]; then - logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /boot" - exit 1 -elif [ "$UM_DEV" == "$BOOTFW_DEV" ]; then - logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /boot/firmware" +if [ "$UM_DEVICE" == "$LIB_DEV" ]; then + logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /library" exit 1 fi @@ -48,20 +42,20 @@ fi # "public artwork" — as summarized here: https://github.com/iiab/iiab/blob/master/roles/usb_lib/README.rst if [ -d $UM_MOUNTPOINT/PUBLIC ]; then SHARE_DIR=$UM_MOUNTPOINT/PUBLIC - logger -t "usb_lib (70-usb-library)" "Found /PUBLIC on $UM_MOUNTPOINT" + logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "Found /PUBLIC on $UM_MOUNTPOINT" else SHARE_DIR=$UM_MOUNTPOINT - logger -t "usb_lib (70-usb-library)" "Did not find /PUBLIC on $UM_MOUNTPOINT" + logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "Did not find /PUBLIC on $UM_MOUNTPOINT" 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!)' + logger -p user.notice -t "usbmount - 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" +logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "Creating link from $CONTENT_LINK to $SHARE_DIR" rm -rf $CONTENT_LINK ln -s $SHARE_DIR $CONTENT_LINK diff --git a/roles/usb_lib/templates/umount.d.unused/70-usb-library b/roles/usb_lib/templates/umount.d.unused/70-usb-library deleted file mode 100644 index d8e095008..000000000 --- a/roles/usb_lib/templates/umount.d.unused/70-usb-library +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# Remove symlink in /library/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 - -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)" -- "Attempting to remove link $CONTENT_LINK." - -if [ -L $CONTENT_LINK ]; then -{% if is_debuntu %} - /bin/rm -f $CONTENT_LINK -{% else %} - /usr/bin/rm -f $CONTENT_LINK -{% endif %} - logger -p user.notice -t "usb_lib (70-usb-library)" -- "$CONTENT_LINK removed." -fi diff --git a/roles/usb_lib/templates/umount.d/70-usb-library.j2 b/roles/usb_lib/templates/umount.d/70-usb-library.j2 new file mode 100644 index 000000000..6ee2afc42 --- /dev/null +++ b/roles/usb_lib/templates/umount.d/70-usb-library.j2 @@ -0,0 +1,26 @@ +#!/bin/bash +# Remove symlink in /library/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 +# Jerry Vonau jvonau3@gmail.com +# +# exported from usbmount +# UM_DEVICE="$device" +# UM_MOUNTPOINT="$mountpoint" +# UM_FILESYSTEM="$fstype" + +CONTENT_LINK_USB=$(basename $UM_MOUNTPOINT | awk '{print toupper($0)}') +CONTENT_LINK="{{ doc_root }}/local_content/$CONTENT_LINK_USB" + +logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" -- "Attempting to remove link $CONTENT_LINK." + +if [ -L $CONTENT_LINK ]; then + rm -f $CONTENT_LINK + logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" -- "$CONTENT_LINK removed." +fi