Created
January 28, 2009 23:56
-
-
Save paulsmith/54275 to your computer and use it in GitHub Desktop.
wrap a series of bash commands
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/bash | |
prog=$(basename $0) | |
logger="logger -t $prog" | |
# Logs to syslog and stderr | |
gripe () { | |
$logger -s "$*" | |
} | |
bomb () { | |
gripe "$*" | |
exit 1 | |
} | |
attempt () { | |
eval $* || bomb "failed $*" | |
} | |
# doit must be called with a tag as the first argument, in front of a | |
# command. The tag is a way to label the command without echoing all | |
# of the command args. | |
doit () { | |
$logger $1 | |
shift | |
attempt $* | |
} | |
# Bootstrap begins here | |
doit install_base_packages apt-get install python # &c. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment