#!/bin/bash
# Remove symlink in /library/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

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."

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 "70-usb-library" -- "$CONTENT_LINK removed."
fi
