Skip to content

Instantly share code, notes, and snippets.

@paulsmith
Created January 28, 2009 23:56
Show Gist options
  • Save paulsmith/54275 to your computer and use it in GitHub Desktop.
Save paulsmith/54275 to your computer and use it in GitHub Desktop.
wrap a series of bash commands
#!/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