mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
This commit must be simultaneously deployed on both staging and prod0. It also requires completely taking down the app. To deploy these changes, do: * check out this commit at /root/zulip on postgres0, postgres1, staging, and prod0 * stop the process_fts_updates job on postgres0 and postgres1 * stop the app on staging and prod0 * do a puppet apply on postgres0, postgres1, staging, and prod0 * move the new client certificates into place on staging and app * move the new server certificates into place on postgres0 and postgres1 * reload the database config on postgres0 and postgres1 (this might actually require a restart) * run tools/migrate-db on postgres0 as root * do a deploy through this commit on staging and prod0 * start the process_fts_updates job on postgres0 and postgres1 * do a puppet apply on nagios (imported from commit 819bdd14326c1425e2d3041a491a8ca3b9716506)
51 lines
1.0 KiB
Plaintext
Executable File
51 lines
1.0 KiB
Plaintext
Executable File
#/bin/sh -xe
|
|
|
|
ROOT_POSTGRES="sudo -u postgres psql"
|
|
DEFAULT_DB=""
|
|
if [ "$(uname)" = "Darwin" ]; then
|
|
ROOT_POSTGRES="psql"
|
|
DEFAULT_DB="postgres"
|
|
fi
|
|
|
|
if [[ $# == 0 ]]; then
|
|
USERNAME=zulip
|
|
PASSWORD=xxxxxxxxxxxx
|
|
DBNAME=zulip
|
|
SEARCH_PATH="$USERNAME",public
|
|
elif [[ $# == 4 ]]; then
|
|
USERNAME=$1
|
|
PASSWORD=$2
|
|
DBNAME=$3
|
|
SEARCH_PATH=$4
|
|
else
|
|
echo "Usage Instructions"
|
|
echo "Run with either no arguments (sets up devel db for local deploy--zulip with user zulip)"
|
|
echo "or specify <db-username> <password> <db-name> <user-schema-search-path>"
|
|
exit
|
|
fi
|
|
|
|
|
|
$ROOT_POSTGRES $DEFAULT_DB << EOF
|
|
CREATE USER $USERNAME WITH PASSWORD '$PASSWORD';
|
|
ALTER USER $USERNAME CREATEDB;
|
|
ALTER ROLE $USERNAME SET search_path TO $SEARCH_PATH;
|
|
EOF
|
|
|
|
umask go-rw
|
|
echo "*:*:*:$USERNAME:$PASSWORD" >> ~/.pgpass
|
|
chmod go-rw ~/.pgpass
|
|
|
|
psql -h localhost postgres $USERNAME <<EOF
|
|
DROP DATABASE IF EXISTS $DBNAME;
|
|
CREATE DATABASE $DBNAME;
|
|
EOF
|
|
|
|
DEFAULT_DB=$DBNAME
|
|
|
|
$ROOT_POSTGRES $DEFAULT_DB << EOF
|
|
DROP SCHEMA public CASCADE;
|
|
EOF
|
|
|
|
echo "Database created"
|
|
|