zulip/scripts/setup/initialize-database

45 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -xe
# Change to root directory of the checkout that we're running from
cd "$(dirname "$0")/../.."
./manage.py checkconfig
./manage.py migrate --noinput
./manage.py createcachetable third_party_api_results
if ! ./manage.py initialize_voyager_db; then
set +x
echo
echo -e "\033[32mPopulating default database failed."
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"
echo -e "\033[0m"
set -x
exit 1
fi
# 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
set +x
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."
set -x