Skip to content

Instantly share code, notes, and snippets.

@martinhbramwell
Last active October 6, 2016 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinhbramwell/78e7257a76bad4db47baf32bcf1ad775 to your computer and use it in GitHub Desktop.
Save martinhbramwell/78e7257a76bad4db47baf32bcf1ad775 to your computer and use it in GitHub Desktop.
Script to launch a Habitat package in the Director
# Launch billmeyer.mongodb with --group todos and --org your0rg
# Additionally, pass in --permanent-peer to the start command
[cfg.services.billmeyer.mongodb.todos.your0rg]
start = "--permanent-peer --strategy at-once"
# Launch the todos into the same group and org. No config required
[cfg.services.your0rg.todos.todos.your0rg]
#!/bin/sh
#
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
YOUR_ORG=your0rg;
YOUR_PKG=todos;
YOUR_PKG_VERSION=0.0.2;
YOUR_PKG_TSTMP=20160930125319;
SERVICE=${YOUR_ORG}_${YOUR_PKG};
SERVICE_PATH=${YOUR_ORG}/${YOUR_PKG};
PACKAGE_PATH=${SERVICE_PATH}/${YOUR_PKG_VERSION}/${YOUR_PKG_TSTMP};
UNIT_FILE=${SERVICE}.service;
TOML_FILE=${SERVICE}.toml;
TOML_FILE_PATH=/hab/pkgs/${SERVICE_PATH}/Director;
BASE_DIR=/hab/svc/${SERVICE};
PRETTY="\n ==> On target server :";
# echo "${PRETTY} Stopping the '${SERVICE}' systemd service, in case it's running . . .";
# sudo systemctl stop ${UNIT_FILE};
# echo "${PRETTY} Disabling the '${SERVICE}' systemd service, in case it's enabled . . .";
# sudo systemctl disable ${UNIT_FILE};
# echo "${PRETTY} Deleting the '${SERVICE}' systemd unit file, in case there's one already . . .";
# sudo rm /etc/systemd/system/${UNIT_FILE};
echo "${PRETTY} Deleting director toml file from '${TOML_FILE_PATH}', in case there's one already . . .";
sudo mkdir -p ${TOML_FILE_PATH};
sudo cp ${SCRIPTPATH}/${TOML_FILE} ${TOML_FILE_PATH}/${TOML_FILE} > /dev/null;
echo "${PRETTY} Ensuring Habitat Supervisor is available";
sudo hab install core/hab-sup > /dev/null 2>&1;
sudo hab pkg binlink core/hab-sup hab-sup;
echo "${PRETTY} Ensuring Habitat Director is available";
sudo hab install core/hab-director > /dev/null 2>&1;
sudo hab pkg binlink core/hab-director hab-director;
echo "${PRETTY} Ensuring package '${PACKAGE_PATH}' is available";
echo "${PRETTY} sudo hab pkg install ${PACKAGE_PATH}";
sudo hab pkg install ${PACKAGE_PATH};
sudo hab pkg install billmeyer/mongodb;
echo "Now run --> sudo hab-director start -c your0rg_todos.toml;";
exit 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment