Skip to content

Instantly share code, notes, and snippets.

@lorello
Created December 12, 2019 13:34
Show Gist options
  • Select an option

  • Save lorello/ae53d431f8670fe56ee60eff6423c27c to your computer and use it in GitHub Desktop.

Select an option

Save lorello/ae53d431f8670fe56ee60eff6423c27c to your computer and use it in GitHub Desktop.
run-one: cron utilities from Ubuntu not available on other distros
#!/bin/bash
source_file="https://bazaar.launchpad.net/~run-one/run-one/trunk/download/head:/runone-20110124065624-91p2i9nu34o1aq4k-2/run-one"
other_commands="keep-one-running
run-one-constantly
run-one-until-failure
run-one-until-success
run-this-one"
bin_path=${INSTALL_PATH:-/usr/local/bin}
curl=$(which curl)
if [ ! -d ${bin_path} ]; then
echo "Error, missing installation path '$bin_path', create it and relaunch the script or change the path setting variable INSTALL_PATH"
exit 1
fi
if ${curl} --silent ${source_file} > ${bin_path}/run-one; then
echo "${bin_path}/run-one ... [OK]"
else
echo -e "Error downloading file run-one at \n\t'$source_file'\n in\n\t'$bin_path/run-one'"
exit 2
fi
chmod +x ${bin_path}/run-one
for command in $other_commands; do
[ ! -f ${bin_path}/${command} ] && \
ln -s ${bin_path}/run-one ${bin_path}/${command} && \
echo "${bin_path}/${command} -> ${bin_path}/run-one ... [OK]"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment