Permalink
Browse files

scripts/lib/install: Add flag to specify key settings.

This should make it easier to script the installation process, and
also conveniently are the options one would want for the --certbot
option.

Significantly modified by tabbott to have a sane right interface,
include --help, and avoid printing all the `set -x` garbage before the
usage notices.
  • Loading branch information...
rht authored and timabbott committed Oct 1, 2017
1 parent a7f602f commit 9ab54e5bd70b04a9be932d85ae65c5863b21b777
Showing with 45 additions and 2 deletions.
  1. +45 −2 scripts/lib/install
View
@@ -1,7 +1,43 @@
#!/usr/bin/env bash
set -xe
set -e
usage() {
echo "Usage: install [--hostname=zulip.example.com] [--email=admin@example.com] [--help]"
exit 0
};
# Shell option parsing. Over time, we'll want to move some of the
# environment variables below into this self-documenting system.
args="$(getopt -o '' --long help,hostname:,email: -n "$0" -- "$@")"
eval "set -- $args"
while true; do
case "$1" in
--hostname)
EXTERNAL_HOST="$2"
shift
shift
;;
--email)
ZULIP_ADMINISTRATOR="$2"
shift
shift
;;
--help)
show_help=1
shift
;;
--)
break
;;
esac
done
if [ -n "$show_help" ]; then
usage
fi
# Assumes we've already been untarred
# Do set -x after option parsing is complete
set -x
# Specify options for apt.
APT_OPTIONS="${APT_OPTIONS:-}"
@@ -28,6 +64,7 @@ if ! [ -e /usr/bin/realpath ]; then
# realpath is in coreutils on Xenial, but not in Trusty
apt-get install -y realpath
fi
ZULIP_PATH="$(realpath $(dirname $0)/../..)"
# setup-apt-repo does an `apt-get update`
@@ -103,6 +140,12 @@ fi
if [ "$has_appserver" = 0 ]; then
"$ZULIP_PATH"/scripts/setup/generate_secrets.py --production
cp -a "$ZULIP_PATH"/zproject/prod_settings_template.py /etc/zulip/settings.py
if [ -n "$EXTERNAL_HOST" ]; then
sed -i "s/^EXTERNAL_HOST =.*/EXTERNAL_HOST = '$EXTERNAL_HOST'/" /etc/zulip/settings.py
fi
if [ -n "ZULIP_ADMINISTRATOR" ]; then
sed -i "s/^ZULIP_ADMINISTRATOR =.*/ZULIP_ADMINISTRATOR = '$ZULIP_ADMINISTRATOR'/" /etc/zulip/settings.py
fi
ln -nsf /etc/zulip/settings.py "$ZULIP_PATH"/zproject/prod_settings.py
fi

0 comments on commit 9ab54e5

Please sign in to comment.