#!/usr/bin/env bash set -e usage() { echo "usage: install -r RELEASE {TARBALL|DIR} [...installer opts..]" >&2 exit 1 } args="$(getopt -o +r: --long help,release: -- "$@")" eval "set -- $args" while true; do case "$1" in --help) usage;; -r|--release) RELEASE="$2"; shift; shift;; --) shift; break;; *) usage;; esac done INSTALLER="$1"; shift INSTALLER_ARGS=("$@"); set -- if [ -z "$RELEASE" ] || [ -z "$INSTALLER" ]; then usage fi if [ "$EUID" -ne 0 ]; then echo "error: this script must be run as root" >&2 exit 1 fi set -x THIS_DIR="$(dirname "$(readlink -f "$0")")" BASE_CONTAINER_NAME=zulip-install-"$RELEASE"-base if ! lxc-info -n "$BASE_CONTAINER_NAME" >/dev/null 2>&1; then "$THIS_DIR"/prepare-base "$RELEASE" fi while [ -z "$CONTAINER_NAME" ] || lxc-info -n "$CONTAINER_NAME" >/dev/null 2>&1; do shared_dir="$(mktemp -d --tmpdir "$RELEASE"-XXXXX)" CONTAINER_NAME=zulip-install-"$(basename "$shared_dir")" done message="$(cat <