Created
January 20, 2012 17:22
-
-
Save io41/1648537 to your computer and use it in GitHub Desktop.
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 | |
# Save this in a file in an empty dir, then run. | |
__global=./ | |
__object=__mytype | |
__object_id=my-id | |
# All events go here | |
exec 10>$__global/post_config_events | |
# Make a test script | |
cat > myscript <<EOF | |
#!/bin/sh | |
echo "Hi, from my script. About to emit an event, foo" | |
echo "$__object/$__object_id foo" >&10 | |
echo "Event 'foo' emitted. k, thx, bye" | |
EOF | |
# Make a test event handler | |
mkdir -p __mytype/my-id | |
cat > __mytype/my-id/post_config <<EOF | |
#!/bin/sh | |
echo "Handling event $1" | |
EOF | |
chmod +x myscript | |
chmod +x __mytype/my-id/post_config | |
# Run the thing that emits the event | |
$(pwd)/myscript | |
# Run post config event handlers | |
sh <<EOF | |
$(sort -u post_config_events | sed "s#\([^ ]*\) \(.*\)#$__global\1/post_config \2#") | |
EOF | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment