2016-01-12 13:08:43 +01:00
|
|
|
#!/usr/bin/env bash
|
2018-03-03 00:13:34 +01:00
|
|
|
set -e
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
echo "usage: initialize-database [--quiet]" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
args="$(getopt -o '' --long help,quiet -- "$@")"
|
|
|
|
eval "set -- $args"
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
--help) usage;;
|
|
|
|
--quiet) QUIET=1; shift;;
|
|
|
|
--) shift; break;;
|
|
|
|
*) usage;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$#" -gt 0 ]; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -x
|
2013-11-13 05:38:54 +01:00
|
|
|
|
|
|
|
# Change to root directory of the checkout that we're running from
|
2018-03-03 00:13:34 +01:00
|
|
|
THIS_DIR="$(dirname "$(readlink -f "$0")")"
|
|
|
|
cd "$THIS_DIR/../.."
|
2013-11-10 17:18:24 +01:00
|
|
|
|
2016-11-22 01:44:16 +01:00
|
|
|
./manage.py checkconfig
|
2013-11-13 05:38:54 +01:00
|
|
|
|
2016-11-22 01:44:16 +01:00
|
|
|
./manage.py migrate --noinput
|
|
|
|
./manage.py createcachetable third_party_api_results
|
2015-09-30 03:24:46 +02:00
|
|
|
|
2020-01-30 21:23:36 +01:00
|
|
|
if ! ./manage.py initialize_production_database; then
|
2015-09-30 03:24:46 +02:00
|
|
|
set +x
|
|
|
|
echo
|
2018-08-03 02:14:47 +02:00
|
|
|
echo -e '\033[32mPopulating default database failed.'
|
2015-09-30 03:24:46 +02:00
|
|
|
echo "After you fix the problem, you will need to do the following before rerunning this:"
|
|
|
|
echo " * supervisorctl stop all # to stop all services that might be accessing the database"
|
|
|
|
echo " * scripts/setup/postgres-init-db # run as root to drop and re-create the database"
|
2018-08-03 02:14:47 +02:00
|
|
|
echo -e '\033[0m'
|
2015-10-15 05:07:17 +02:00
|
|
|
exit 1
|
2015-09-30 03:24:46 +02:00
|
|
|
fi
|
2013-11-13 05:38:54 +01:00
|
|
|
|
2016-08-05 07:52:52 +02:00
|
|
|
# Check if the supervisor socket exists. If not, it could be:
|
|
|
|
#
|
|
|
|
# A) A normal installation went bad (supervisor hasn't started)
|
|
|
|
# B) We are in a Docker container and don't have supervisor running
|
|
|
|
#
|
|
|
|
# In either case, it doesn't make sense to restart supervisor jobs
|
|
|
|
if [ -e "/var/run/supervisor.sock" ]; then
|
|
|
|
supervisorctl restart all
|
|
|
|
fi
|
2015-09-30 07:23:25 +02:00
|
|
|
|
2015-12-20 14:59:21 +01:00
|
|
|
set +x
|
2018-03-03 00:13:34 +01:00
|
|
|
if [ -z "$QUIET" ]; then
|
|
|
|
echo "Congratulations! You have successfully configured your Zulip database."
|
|
|
|
echo "If you haven't already, you should configure email in /etc/zulip/settings.py."
|
|
|
|
echo
|
|
|
|
echo "Next, run as the zulip user (use 'su zulip' if needed):"
|
|
|
|
echo
|
|
|
|
echo " /home/zulip/deployments/current/manage.py generate_realm_creation_link"
|
|
|
|
echo
|
|
|
|
echo "This generates a secure, single-use link that you you can use to setup "
|
|
|
|
echo "a Zulip organization from the convenience of your web browser."
|
|
|
|
fi
|