Skip to content

Instantly share code, notes, and snippets.

@deepcube
Created February 27, 2015 22:42
Show Gist options
  • Save deepcube/32962fdb45b93b4ac7f6 to your computer and use it in GitHub Desktop.
Save deepcube/32962fdb45b93b4ac7f6 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Simulate add/remove events by writing directly
# into the uevent files.
if [ "$#" -ne 1 ] || [ "$1" != add ] && [ "$1" != remove ]; then
# warning: can't trust $0, better off just hard coding the name
# echo "usage: simevent add|remove" 1>&2
printf "usage: %s add|remove\n" "${0##*/}" 1>&2
exit 1
fi
find /sys/devices -type f -path '*/dev' -exec \
sh -c 'for f do printf %s\\n "$0" > "${f%/*}"/uevent; done' "$1" {} +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment