Skip to content

Instantly share code, notes, and snippets.

@l-modolo
Created June 19, 2015 09:24
Show Gist options
  • Save l-modolo/b218cd87f7efdcae8b32 to your computer and use it in GitHub Desktop.
Save l-modolo/b218cd87f7efdcae8b32 to your computer and use it in GitHub Desktop.
/usr/local/sbin/udev-unmounter.sh
#!/bin/sh
#
# USAGE: udev-unmounter.sh MOUNTPT
# MOUNTPT is a mountpoint we want to unmount and delete.
MOUNTPT="$1"
if [ -z "$MOUNTPT" ]; then
exit 1
fi
# test mountpoint - it should exist
if [ -e "${MOUNTPT}" ]; then
# very naive; just run and pray
umount -l "${MOUNTPT}" && rmdir "${MOUNTPT}" && exit 0
echo "error: ${MOUNTPT} failed to unmount."
exit 1
fi
echo "error: ${MOUNTPT} does not exist"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment