Skip to content

Instantly share code, notes, and snippets.

@peterbe
Created June 11, 2018 00:42
Show Gist options
  • Save peterbe/0e676a4183167f54da5bf3d670acb7e3 to your computer and use it in GitHub Desktop.
Save peterbe/0e676a4183167f54da5bf3d670acb7e3 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eo pipefail
hostandport=$1
shift
curl -s "$hostandport" >/dev/null && \
echo "Already running on $hostandport" && \
exit 1 || exec "$@"
@peterbe
Copy link
Author

peterbe commented Jun 11, 2018

To install, run:

curl -L -o ~/bin/unlessalready.sh https://gist.github.com/peterbe/0e676a4183167f54da5bf3d670acb7e3/raw/unlessalready.sh
chmod +x ~/bin/unlessalready.sh

Read the blog post for more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment