1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00
This commit is contained in:
Jerry Vonau 2025-03-01 12:12:10 -05:00 committed by GitHub
commit 6736b1f23c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 148 additions and 148 deletions

View file

@ -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

View file

@ -24,8 +24,8 @@ exec > /dev/null 2>&1
# Log a string via the syslog facility. # Log a string via the syslog facility.
log() log()
{ {
if [ $1 != debug ] || expr "$VERBOSE" : "[yY]" > /dev/null; then if [ "$1" != debug ] || expr "$VERBOSE" : "[yY]" > /dev/null; then
logger -p user.$1 -t "usbmount[$$]" -- "$2" logger -p user."$1" -t "usbmount[$$]" -- "$2"
fi fi
} }
@ -83,22 +83,22 @@ if [ "$1" = add ]; then
# Acquire lock. # Acquire lock.
log debug "trying to acquire lock /var/run/usbmount/.mount.lock" log debug "trying to acquire lock /var/run/usbmount/.mount.lock"
lockfile-create --retry 6 /var/run/usbmount/.mount || \ 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 trap '( lockfile-remove /var/run/usbmount/.mount )' 0
log debug "acquired lock /var/run/usbmount/.mount.lock" log debug "acquired lock /var/run/usbmount/.mount.lock"
# Grab device information from device and "divide it" # Grab device information from device and "divide it"
# FIXME: improvement: implement mounting by label (notice that labels # FIXME: improvement: implement mounting by label (notice that labels
# can contain spaces, which makes things a little bit less comfortable). # 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;') FSTYPE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]TYPE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;')
UUID=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]UUID="\([^"]*\)".*/\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;') 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" log debug "/$DEVNAME does not contain a filesystem or disklabel"
lockfile-remove /var/run/usbmount/.mount lockfile-remove /var/run/usbmount/.mount
exit exit
fi fi
log debug "/$DEVNAME contains filesystem type $FSTYPE" log debug "/$DEVNAME contains filesystem type $FSTYPE"
@ -109,29 +109,29 @@ if [ "$1" = add ]; then
BOOT_DEV=$(/usr/bin/findmnt -no source /boot) BOOT_DEV=$(/usr/bin/findmnt -no source /boot)
log debug "BOOT_DEV $BOOT_DEV" log debug "BOOT_DEV $BOOT_DEV"
if [ $BOOTFW_DEV = /$DEVNAME ]; then if [ "$BOOTFW_DEV" = /"$DEVNAME" ]; then
log debug "skipping BOOTFS_DEV $BOOTFS_DEV mounted at /boot/firmware" log debug "skipping BOOTFW_DEV $BOOTFW_DEV mounted at /boot/firmware"
lockfile-remove /var/run/usbmount/.mount lockfile-remove /var/run/usbmount/.mount
exit exit
elif [ $ROOT_DEV = /$DEVNAME ]; then elif [ "$ROOT_DEV" = /"$DEVNAME" ]; then
log debug "skipping ROOT_DEV $ROOT_DEV mounted at /" log debug "skipping ROOT_DEV $ROOT_DEV mounted at /"
lockfile-remove /var/run/usbmount/.mount lockfile-remove /var/run/usbmount/.mount
exit exit
elif [ $BOOT_DEV = /$DEVNAME ]; then elif [ "$BOOT_DEV" = /"$DEVNAME" ]; then
log debug "skipping BOOT_DEV $BOOT_DEV mount as /boot" log debug "skipping BOOT_DEV $BOOT_DEV mount as /boot"
lockfile-remove /var/run/usbmount/.mount lockfile-remove /var/run/usbmount/.mount
exit exit
fi fi
# Try to use specifications in /etc/fstab to skip. # 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" log debug "skipping /$DEVNAME exit"
lockfile-remove /var/run/usbmount/.mount lockfile-remove /var/run/usbmount/.mount
exit exit
elif grep -q "^[[:blank:]]*UUID=$UUID" /etc/fstab; then elif grep -Eq "^[[:blank:]]*UUID=$UUID" /etc/fstab; then
log debug "skipping $UUID" log debug "skipping $UUID"
lockfile-remove /var/run/usbmount/.mount lockfile-remove /var/run/usbmount/.mount
exit exit
else else
log debug "/$DEVNAME contains filesystem type $FSTYPE" log debug "/$DEVNAME contains filesystem type $FSTYPE"
fstype=$FSTYPE fstype=$FSTYPE
@ -142,7 +142,7 @@ if [ "$1" = add ]; then
for v in $MOUNTPOINTS; do for v in $MOUNTPOINTS; do
if [ -d "$v" ] && ! grep -q "^[^ ][^ ]* *$v " /proc/mounts; then if [ -d "$v" ] && ! grep -q "^[^ ][^ ]* *$v " /proc/mounts; then
mountpoint="$v" mountpoint="$v"
log debug "mountpoint $mountpoint is available for /$DEVNAME" log debug "mountpoint $mountpoint is available for /$DEVNAME"
break break
fi fi
done done
@ -155,74 +155,76 @@ if [ "$1" = add ]; then
break break
fi fi
done done
if [ -n "$MOUNTOPTIONS" ]; then if [ -n "$MOUNTOPTIONS" ]; then
options="$MOUNTOPTIONS${options:+,$options}" 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 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
fi
elif [ "$1" = remove ]; then elif [ "$1" = remove ]; then
log debug "DEVNAME is /$DEVNAME"
# A block or partition device has been removed. # A block or partition device has been removed.
# Test if it is mounted. # Test if it is mounted.
while read device mountpoint fstype remainder; do while read -r device mountpoint fstype junk; do
if [ "$DEVNAME" = "$device" ]; then if [ "/$DEVNAME" = "$device" ]; then
# If the mountpoint and filesystem type are maintained by log debug "umount device is $device"
# this script, unmount the filesystem. log debug "umount fstype is $fstype"
if in_list "$mountpoint" "$MOUNTPOINTS" && # If the mountpoint and filesystem type are maintained by
in_list "$fstype" "$FILESYSTEMS"; then # this script, unmount the filesystem.
log info "executing command: umount -l $mountpoint" if in_list "$mountpoint" "$MOUNTPOINTS"; then
umount -l "$mountpoint"
# Run hook scripts; ignore errors. # 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_MOUNTPOINT="$mountpoint"
export UM_FILESYSTEM="$fstype" export UM_FILESYSTEM="$fstype"
log info "executing command: run-parts /etc/usbmount/umount.d" log info "executing command: run-parts /etc/usbmount/umount.d"
run-parts /etc/usbmount/umount.d || : run-parts /etc/usbmount/umount.d || :
log info "executing command: umount -l $mountpoint"
umount -l "$mountpoint"
fi fi
break break
fi fi

View file

@ -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=="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}"

View file

@ -9,7 +9,6 @@ ConditionPathExists=/var/run
TimeoutStartSec=0 TimeoutStartSec=0
Environment=DEVNAME=%I Environment=DEVNAME=%I
ExecStart=/usr/local/sbin/usbmount add ExecStart=/usr/local/sbin/usbmount add
ExecStop=/usr/local/sbin/iiab-clean-usb.sh %I ExecStop=/usr/local/sbin/usbmount remove
ExecStopPost=/bin/umount /%I
RemainAfterExit=yes RemainAfterExit=yes
RuntimeDirectory=usbmount RuntimeDirectory=usbmount

View file

@ -93,16 +93,8 @@
with_items: with_items:
- { src: 'usbmount/usbmount.conf', dest: '/etc/usbmount/', mode: '0644' } - { src: 'usbmount/usbmount.conf', dest: '/etc/usbmount/', mode: '0644' }
- { src: 'usbmount/usbmount', dest: '/usr/local/sbin/', mode: '0755' } - { src: 'usbmount/usbmount', dest: '/usr/local/sbin/', mode: '0755' }
- { src: 'usbmount/usbmount.rules', dest: '/etc/udev/rules.d/usbmount.rules', mode: '0644' }
- name: 'Install from template: /etc/udev/rules.d/usbmount.rules, /etc/systemd/system/usbmount@.service, /usr/local/sbin/iiab-clean-usb.sh' - { src: 'usbmount/usbmount@.service', dest: '/etc/systemd/system/usbmount@.service', mode: '0644' }
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' }
- name: Add dir {{ doc_root }}/upload2usb (0775) owned by {{ apache_user }}:{{ apache_user }} - name: Add dir {{ doc_root }}/upload2usb (0775) owned by {{ apache_user }}:{{ apache_user }}
file: file:

View file

@ -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 - name: Install /etc/usbmount/mount.d/70-usb-library from template, if usb_lib_enabled
template: template:
src: mount.d/70-usb-library.j2 src: mount.d/70-usb-library.j2

View file

@ -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

View file

@ -8,38 +8,32 @@
# <douglas@paradise.net.nz> # <douglas@paradise.net.nz>
# #
# by Tim Moody tim@timmoody.com # 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 # Better to set this in /etc/usbmount/usbmount.conf
# VERBOSE=yes # VERBOSE=yes
# UM_MOUNTPOINT is documented at: https://github.com/rbrito/usbmount#hook-scripts logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "UM_MOUNTPOINT is: $UM_MOUNTPOINT"
UM_DEV=$(findmnt -no source $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: # 2022-06-16 better security thanks to @tim-moody and @jvonau:
# https://github.com/iiab/iiab/pull/3254 # https://github.com/iiab/iiab/pull/3254
LIB_DEV=$(findmnt -no source /library | cut -d '[' -f 1) 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: # Verbose logging to illuminate occasional boot bugginess:
logger -t "usb_lib (70-usb-library)" "UM_DEV is: $UM_DEV" logger -p user.notice -t "usbmount - usb_lib (70-usb-library)" "LIB_DEV is: $LIB_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"
if [ "$UM_DEV" == "$LIB_DEV" ]; then if [ "$UM_DEVICE" == "$LIB_DEV" ]; then
logger -t "usb_lib (70-usb-library)" "Skipping $UM_MOUNTPOINT containing /library" logger -p user.notice -t "usbmount - 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"
exit 1 exit 1
fi fi
@ -48,20 +42,20 @@ 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 -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 else
SHARE_DIR=$UM_MOUNTPOINT 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 fi
CONTENT_LINK_USB=$(basename $UM_MOUNTPOINT | awk '{print toupper($0)}') CONTENT_LINK_USB=$(basename $UM_MOUNTPOINT | awk '{print toupper($0)}')
if [ -z "$CONTENT_LINK_USB" ]; then 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 exit 1
fi fi
CONTENT_LINK="{{ doc_root }}/local_content/$CONTENT_LINK_USB" CONTENT_LINK="{{ doc_root }}/local_content/$CONTENT_LINK_USB"
# 'rm -rf' even stronger than 'ln -nsf' and 'ln -Tsf' # '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 # 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 rm -rf $CONTENT_LINK
ln -s $SHARE_DIR $CONTENT_LINK ln -s $SHARE_DIR $CONTENT_LINK

View file

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

View file

@ -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 <martin@laptop.org>
#
# and the adaptation for xs-activity-server by Douglas Bagnall
# <douglas@paradise.net.nz>
#
# 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