Created
June 19, 2015 09:24
-
-
Save l-modolo/b218cd87f7efdcae8b32 to your computer and use it in GitHub Desktop.
/usr/local/sbin/udev-unmounter.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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