Files
zulip/scripts/setup/initialize-database
Alex Vandiver a4d0f03319 scripts: Switch to stop-server/restart-server.
stop-server and restart-server address all services which talk to the
database, and are thus more correct than restarting or stopping
everything in supervisor.

This is possible now that the previous commit ensures that the zulip
user can read the zulip installation directory during
`create-database`; previously, that directory was still owned by root
when `create-database` was run, whereas now it is in
`~zulip/deployments/`.
2022-03-21 16:33:28 -07:00

63 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
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
# Change to root directory of the checkout that we're running from
THIS_DIR="$(dirname "$(readlink -f "$0")")"
cd "$THIS_DIR/../.."
./manage.py checkconfig
./manage.py migrate --noinput
./manage.py createcachetable third_party_api_results
# 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
./scripts/restart-server
fi
set +x
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 set up "
echo "a Zulip organization from the convenience of your web browser."
fi