mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
When the install script is successful, one of the final things it wants to do is to move the tree that Zulip was installed from into the deployments directory. It can't do that, at least not in a naive way with `mv`, if the tree is actually a mount point. So, stick the tree inside some other directory that we create just for the purpose of being the mount point and containing the install tree.
80 lines
2.0 KiB
Bash
Executable File
80 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
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 -ex
|
|
|
|
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
|
|
CONTAINER_NAME="$(mktemp -u zulip-install-"$RELEASE"-XXXXX)"
|
|
done
|
|
|
|
if [ -d "$INSTALLER" ]; then
|
|
installer_dir="$(readlink -f $INSTALLER)"
|
|
else
|
|
installer_dir="$(mktemp -d --tmpdir zulip-server-XXXXX)"
|
|
tar -xf "$INSTALLER" -C "$installer_dir" --transform='s,^[^/]*,zulip-server,'
|
|
fi
|
|
|
|
mkdir -p /srv/zulip/test-install/pip-cache
|
|
|
|
lxc-copy --ephemeral --keepdata -n "$BASE_CONTAINER_NAME" -N "$CONTAINER_NAME" \
|
|
-m overlay="$installer_dir":/tmp/src/,bind=/srv/zulip/test-install/pip-cache:/root/.cache/pip
|
|
|
|
run() {
|
|
lxc-attach -n "$CONTAINER_NAME" -- "$@"
|
|
}
|
|
|
|
# Wait for the container to boot, polling.
|
|
ok=
|
|
for i in {1..60}; do
|
|
runlevel="$(run runlevel 2>/dev/null)" || { sleep 1; continue; }
|
|
if [ "$runlevel" != "${0%[0-9]}" ]; then
|
|
ok=1
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
if [ -z "ok" ]; then
|
|
echo "error: timeout waiting for container to boot" >&2
|
|
exit 1
|
|
fi
|
|
|
|
run /tmp/src/zulip-server/scripts/setup/install --snakeoil-cert "${INSTALLER_ARGS[@]}"
|
|
# TODO install ends as a zombie (workaround: `sudo ps aux | grep lxc-attach`, kill that)
|
|
|
|
# TODO settings.py, initialize-database, create realm
|
|
|
|
# TODO eatmydata, for speed
|