Removed all echo "==="

Fixes for nginx
Fixes for rabbitmqctl commands
This commit is contained in:
Alexander Trost
2015-10-25 02:14:48 +01:00
parent c667a3bdfa
commit 3b8023c721
2 changed files with 14 additions and 46 deletions

View File

@@ -129,18 +129,17 @@ setConfigurationValue() {
;; ;;
esac esac
echo "$VALUE" >> "$FILE" echo "$VALUE" >> "$FILE"
echo "Setting key \"$KEY\" with value \"$VALUE\"." echo "Setting key \"$KEY\", type \"$TYPE\"."
} }
nginxConfiguration() { nginxConfiguration() {
echo "Executing nginx configuration ..." echo "Executing nginx configuration ..."
sed -i "s/worker_processes .*/worker_processes $NGINX_WORKERS;/g" /etc/nginx/nginx.conf sed -i "s/worker_processes .*/worker_processes $NGINX_WORKERS;/g" /etc/nginx/nginx.conf
sed -i "s/client_max_body_size .*/client_max_body_size $NGINX_MAX_UPLOAD_SIZE;/g" /etc/nginx/nginx.conf sed -i "s/client_max_body_size .*/client_max_body_size $NGINX_MAX_UPLOAD_SIZE;/g" /etc/nginx/nginx.conf
sed -i "s/proxy_buffering .*/proxy_buffering $NGINX_PROXY_BUFFERING;/g" /etc/nginx/zulip-include/app sed -i "s/proxy_buffering .*/proxy_buffering $NGINX_PROXY_BUFFERING;/g" /etc/nginx/zulip-include/proxy_longpolling
echo "Nginx configuration succeeded." echo "Nginx configuration succeeded."
} }
configureCerts() { configureCerts() {
echo "Exectuing certificates configuration..." echo "Exectuing certificates configuration..."
echo "==="
case "$ZULIP_AUTO_GENERATE_CERTS" in case "$ZULIP_AUTO_GENERATE_CERTS" in
[Tt][Rr][Uu][Ee]) [Tt][Rr][Uu][Ee])
ZULIP_AUTO_GENERATE_CERTS="True" ZULIP_AUTO_GENERATE_CERTS="True"
@@ -167,7 +166,6 @@ configureCerts() {
if [ -z "$ZULIP_CERTIFICATE_CN" ]; then if [ -z "$ZULIP_CERTIFICATE_CN" ]; then
if [ -z "$ZULIP_SETTINGS_EXTERNAL_HOST" ]; then if [ -z "$ZULIP_SETTINGS_EXTERNAL_HOST" ]; then
echo "Certificates generation failed. \"ZULIP_CERTIFICATE_CN\" and as fallback \"ZULIP_SETTINGS_EXTERNAL_HOST\" not given." echo "Certificates generation failed. \"ZULIP_CERTIFICATE_CN\" and as fallback \"ZULIP_SETTINGS_EXTERNAL_HOST\" not given."
echo "==="
echo "Certificates configuration failed." echo "Certificates configuration failed."
exit 1 exit 1
fi fi
@@ -187,22 +185,18 @@ configureCerts() {
fi fi
if [ ! -e "$DATA_DIR/certs/zulip.key" ]; then if [ ! -e "$DATA_DIR/certs/zulip.key" ]; then
echo "No zulip.key given in $DATA_DIR." echo "No zulip.key given in $DATA_DIR."
echo "==="
echo "Certificates configuration failed." echo "Certificates configuration failed."
exit 1 exit 1
fi fi
if [ ! -e "$DATA_DIR/certs/zulip.combined-chain.crt" ]; then if [ ! -e "$DATA_DIR/certs/zulip.combined-chain.crt" ]; then
echo "No zulip.combined-chain.crt given in $DATA_DIR." echo "No zulip.combined-chain.crt given in $DATA_DIR."
echo "==="
echo "Certificates configuration failed." echo "Certificates configuration failed."
exit 1 exit 1
fi fi
echo "==="
echo "Certificates configuration succeeded." echo "Certificates configuration succeeded."
} }
secretsConfiguration() { secretsConfiguration() {
echo "Setting Zulip secrets ..." echo "Setting Zulip secrets ..."
echo "==="
if [ ! -e "$DATA_DIR/zulip-secrets.conf" ]; then if [ ! -e "$DATA_DIR/zulip-secrets.conf" ]; then
echo "Generating Zulip secrets ..." echo "Generating Zulip secrets ..."
/root/zulip/scripts/setup/generate_secrets.py /root/zulip/scripts/setup/generate_secrets.py
@@ -232,7 +226,6 @@ secretsConfiguration() {
done done
set -e set -e
unset SECRET_KEY SECRET_VAR KEY unset SECRET_KEY SECRET_VAR KEY
echo "==="
echo "Zulip secrets configuration succeeded." echo "Zulip secrets configuration succeeded."
} }
databaseConfiguration() { databaseConfiguration() {
@@ -312,7 +305,6 @@ camoConfiguration() {
} }
zulipConfiguration() { zulipConfiguration() {
echo "Executing Zulip configuration ..." echo "Executing Zulip configuration ..."
echo "==="
if [ ! -z "$ZULIP_CUSTOM_SETTINGS" ]; then if [ ! -z "$ZULIP_CUSTOM_SETTINGS" ]; then
echo -e "\n$ZULIP_CUSTOM_SETTINGS" >> "$ZPROJECT_SETTINGS" echo -e "\n$ZULIP_CUSTOM_SETTINGS" >> "$ZPROJECT_SETTINGS"
fi fi
@@ -331,16 +323,15 @@ zulipConfiguration() {
echo "Error in Zulip configuration." echo "Error in Zulip configuration."
exit 1 exit 1
fi fi
echo "==="
echo "Zulip configuration succeeded." echo "Zulip configuration succeeded."
} }
log2zulipConfiguration() { log2zulipConfiguration() {
if [ "$LOG2ZULIP_ENABLED" != "True" ] || [ "$LOG2ZULIP_ENABLED" != "true" ]; then if [ "$LOG2ZULIP_ENABLED" != "True" ] || [ "$LOG2ZULIP_ENABLED" != "true" ]; then
rm -f /etc/cron/conf.d/log2zulip rm -f /etc/cron/conf.d/log2zulip
echo "Log2Zulip is disabled."
return 0 return 0
fi fi
echo "Executing Log2Zulip configuration ..." echo "Executing Log2Zulip configuration ..."
echo "==="
if ([ "$LOG2ZULIP_AUTO_CREATE" != "True" ] || [ "$LOG2ZULIP_AUTO_CREATE" != "true" ]) && [ ! -z "$LOG2ZULIP_EMAIL" ] && [ ! -z "$LOG2ZULIP_API_KEY" ] && [ ! -z "$LOG2ZULIP_SITE" ]; then if ([ "$LOG2ZULIP_AUTO_CREATE" != "True" ] || [ "$LOG2ZULIP_AUTO_CREATE" != "true" ]) && [ ! -z "$LOG2ZULIP_EMAIL" ] && [ ! -z "$LOG2ZULIP_API_KEY" ] && [ ! -z "$LOG2ZULIP_SITE" ]; then
sed -i "s/email = .*/email = $LOG2ZULIP_EMAIL/g" /etc/log2zulip.zuliprc sed -i "s/email = .*/email = $LOG2ZULIP_EMAIL/g" /etc/log2zulip.zuliprc
sed -i "s/key = .*/key = $LOG2ZULIP_API_KEY/g" /etc/log2zulip.zuliprc sed -i "s/key = .*/key = $LOG2ZULIP_API_KEY/g" /etc/log2zulip.zuliprc
@@ -352,7 +343,6 @@ log2zulipConfiguration() {
done done
echo "$(echo "$LOGFILES" | sed 's/,$//g')]" > /etc/log2zulip.conf echo "$(echo "$LOGFILES" | sed 's/,$//g')]" > /etc/log2zulip.conf
fi fi
echo "==="
echo "Log2Zulip configuration succeeded." echo "Log2Zulip configuration succeeded."
} }
autoBackupConfiguration() { autoBackupConfiguration() {
@@ -398,7 +388,6 @@ waitingForDatabase() {
} }
bootstrapDatabase() { bootstrapDatabase() {
echo "(Re)creating database structure ..." echo "(Re)creating database structure ..."
echo "==="
export PGPASSWORD="$DB_PASS" export PGPASSWORD="$DB_PASS"
echo """ echo """
CREATE USER zulip; CREATE USER zulip;
@@ -414,76 +403,66 @@ bootstrapDatabase() {
unset unset
fi fi
unset PGPASSWORD unset PGPASSWORD
echo "==="
echo "Database structure recreated." echo "Database structure recreated."
} }
bootstrapRabbitMQ() { bootstrapRabbitMQ() {
echo "Bootstrapping RabbitMQ ..." echo "Bootstrapping RabbitMQ ..."
echo "==="
echo "RabbitMQ deleting user \"guest\"." echo "RabbitMQ deleting user \"guest\"."
rabbitmqctl -n "$RABBITMQ_HOST" delete_user guest 2> /dev/null || : rabbitmqctl -n "$RABBITMQ_USER@$RABBITMQ_HOST" delete_user guest 2> /dev/null || :
echo "RabbitMQ adding user \"$RABBITMQ_USERNAME\"." echo "RabbitMQ adding user \"$RABBITMQ_USERNAME\"."
rabbitmqctl -n "$RABBITMQ_HOST" add_user "$RABBITMQ_USERNAME" "$ZULIP_SECRETS_rabbitmq_password" 2> /dev/null || : rabbitmqctl -n "$RABBITMQ_USER@$RABBITMQ_HOST" add_user "$RABBITMQ_USERNAME" "$ZULIP_SECRETS_rabbitmq_password" 2> /dev/null || :
echo "RabbitMQ setting user tags for \"$RABBITMQ_USERNAME\"." echo "RabbitMQ setting user tags for \"$RABBITMQ_USERNAME\"."
rabbitmqctl -n "$RABBITMQ_HOST" set_user_tags "$RABBITMQ_USERNAME" administrator 2> /dev/null || : rabbitmqctl -n "$RABBITMQ_USER@$RABBITMQ_HOST" set_user_tags "$RABBITMQ_USERNAME" administrator || :
echo "RabbitMQ setting permissions for user \"$RABBITMQ_USERNAME\"." echo "RabbitMQ setting permissions for user \"$RABBITMQ_USERNAME\"."
rabbitmqctl -n "$RABBITMQ_HOST" set_permissions -p / "$RABBITMQ_USERNAME" '.*' '.*' '.*' 2> /dev/null || : rabbitmqctl -n "$RABBITMQ_USER@$RABBITMQ_HOST" set_permissions -p / "$RABBITMQ_USERNAME" '.*' '.*' '.*' || :
echo "==="
echo "RabbitMQ bootstrap succeeded." echo "RabbitMQ bootstrap succeeded."
} }
zulipFirstStartInit() { zulipFirstStartInit() {
echo "Executing Zulip first start init ..."
if [ -z "$FORCE_FIRST_START_INIT" ] || [ -e "$DATA_DIR/.initiated" ]; then if [ -z "$FORCE_FIRST_START_INIT" ] || [ -e "$DATA_DIR/.initiated" ]; then
echo "First Start Init not needed." echo "First Start Init not needed."
return 0 return 0
fi fi
echo "Executing Zulip first start init ..."
echo "==="
set +e set +e
if ! su zulip -c "/home/zulip/deployments/current/manage.py migrate --noinput"; then if ! su zulip -c "/home/zulip/deployments/current/manage.py migrate --noinput"; then
local RETURN_CODE=$? local RETURN_CODE=$?
echo "==="
echo "Zulip first start init failed in \"migrate --noinput\". with exit code $RETURN_CODE" echo "Zulip first start init failed in \"migrate --noinput\". with exit code $RETURN_CODE"
exit $RETURN_CODE exit $RETURN_CODE
fi fi
echo "Creating Zulip cache and third_party_api_results tables ..." echo "Creating Zulip cache and third_party_api_results tables ..."
if ! su zulip -c "/home/zulip/deployments/current/manage.py createcachetable third_party_api_results"; then if ! su zulip -c "/home/zulip/deployments/current/manage.py createcachetable third_party_api_results"; then
local RETURN_CODE=$? local RETURN_CODE=$?
echo "==="
echo "Zulip first start init failed in \"createcachetable third_party_api_results\" with exit code $RETURN_CODE." echo "Zulip first start init failed in \"createcachetable third_party_api_results\" with exit code $RETURN_CODE."
exit $RETURN_CODE exit $RETURN_CODE
fi fi
echo "Initializing Zulip Voyager database ..." echo "Initializing Zulip Voyager database ..."
if ! su zulip -c "/home/zulip/deployments/current/manage.py initialize_voyager_db"; then if ! su zulip -c "/home/zulip/deployments/current/manage.py initialize_voyager_db"; then
local RETURN_CODE=$? local RETURN_CODE=$?
echo "==="
echo "Zulip first start init failed in \"initialize_voyager_db\" with exit code $RETURN_CODE." echo "Zulip first start init failed in \"initialize_voyager_db\" with exit code $RETURN_CODE."
exit $RETURN_CODE exit $RETURN_CODE
fi fi
set -e set -e
echo "==="
echo "Zulip first start init sucessful." echo "Zulip first start init sucessful."
} }
zulipMigration() { zulipMigration() {
echo "Migrating Zulip to new version ..."
if [ -e "$DATA_DIR/.zulip-$ZULIP_VERSION" ]; then if [ -e "$DATA_DIR/.zulip-$ZULIP_VERSION" ]; then
echo "No Zulip migration needed. Continuing." echo "No Zulip migration needed. Continuing."
return 0 return 0
fi fi
echo "Migrating Zulip to new version ..."
echo "==="
set +e set +e
if ! su zulip -c "/home/zulip/deployments/current/manage.py migrate"; then if ! su zulip -c "/home/zulip/deployments/current/manage.py migrate"; then
local RETURN_CODE=$? local RETURN_CODE=$?
echo "==="
echo "Zulip migration failed." echo "Zulip migration failed."
exit $RETURN_CODE exit $RETURN_CODE
fi fi
set -e set -e
rm -rf "$DATA_DIR/.zulip-*" rm -rf "$DATA_DIR/.zulip-*"
touch "$DATA_DIR/.zulip-$ZULIP_VERSION" touch "$DATA_DIR/.zulip-$ZULIP_VERSION"
echo "==="
echo "Zulip migration succeeded." echo "Zulip migration succeeded."
} }
runPostSetupScripts() { runPostSetupScripts() {
echo "Post setup scripts execution ..."
if [ "$ZULIP_RUN_POST_SETUP_SCRIPTS" != "True" ] || [ "$ZULIP_RUN_POST_SETUP_SCRIPTS" != "true" ]; then if [ "$ZULIP_RUN_POST_SETUP_SCRIPTS" != "True" ] || [ "$ZULIP_RUN_POST_SETUP_SCRIPTS" != "true" ]; then
echo "Not running post setup scripts. ZULIP_RUN_POST_SETUP_SCRIPTS isn't true." echo "Not running post setup scripts. ZULIP_RUN_POST_SETUP_SCRIPTS isn't true."
return 0 return 0
@@ -497,8 +476,6 @@ runPostSetupScripts() {
echo "No post setup scripts found in \"$DATA_DIR/post-setup.d/\"." echo "No post setup scripts found in \"$DATA_DIR/post-setup.d/\"."
return 0 return 0
fi fi
echo "Post setup scripts execution ..."
echo "==="
set +e set +e
for FILE in *; do for FILE in *; do
if [ -x "$FILE" ]; then if [ -x "$FILE" ]; then
@@ -507,13 +484,11 @@ runPostSetupScripts() {
echo "Executed \"$FILE\". Return code $?." echo "Executed \"$FILE\". Return code $?."
else else
echo "Permissions denied for \"$FILE\". Please check the permissions." echo "Permissions denied for \"$FILE\". Please check the permissions."
echo "==="
echo "Post setup scripts execution failed. Exiting." echo "Post setup scripts execution failed. Exiting."
exit 1 exit 1
fi fi
done done
set -e set -e
echo "==="
echo "Post setup scripts execution succeeded." echo "Post setup scripts execution succeeded."
} }
bootstrappingEnvironment() { bootstrappingEnvironment() {
@@ -533,7 +508,7 @@ appRun() {
bootstrappingEnvironment bootstrappingEnvironment
echo "=== Begin Run Phase ===" echo "=== Begin Run Phase ==="
echo "Starting Zulip using supervisor with \"/etc/supervisor/supervisord.conf\" ..." echo "Starting Zulip using supervisor with \"/etc/supervisor/supervisord.conf\" ..."
echo "===" echo ""
exec supervisord -c "/etc/supervisor/supervisord.conf" exec supervisord -c "/etc/supervisor/supervisord.conf"
} }
appManagePy() { appManagePy() {
@@ -544,17 +519,14 @@ appManagePy() {
COMMAND="shell" COMMAND="shell"
fi fi
echo "Running manage.py ..." echo "Running manage.py ..."
echo "==="
set +e set +e
su zulip -c "/home/zulip/deployments/current/manage.py $COMMAND $*" su zulip -c "/home/zulip/deployments/current/manage.py $COMMAND $*"
exit $? exit $?
} }
appBackup() { appBackup() {
echo "Starting backup process ..." echo "Starting backup process ..."
echo "==="
if [ -d "/tmp/backup-$(date "%D-%H-%M-%S")" ]; then if [ -d "/tmp/backup-$(date "%D-%H-%M-%S")" ]; then
echo "Temporary backup folder for \"$(date "%D-%H-%M-%S")\" already exists. Aborting." echo "Temporary backup folder for \"$(date "%D-%H-%M-%S")\" already exists. Aborting."
echo "==="
echo "Backup process failed." echo "Backup process failed."
exit 1 exit 1
fi fi
@@ -565,16 +537,13 @@ appBackup() {
pg_dump -h "$DB_HOST" -p "$DB_HOST_PORT" -U "$DB_USER" "$DB_NAME" > "$BACKUP_FOLDER/database-postgres.sql" pg_dump -h "$DB_HOST" -p "$DB_HOST_PORT" -U "$DB_USER" "$DB_NAME" > "$BACKUP_FOLDER/database-postgres.sql"
tar -zcvf "$DATA_DIR/backups/backup-$(date "%D-%H-%M-%S").tar.gz" "$BACKUP_FOLDER/" tar -zcvf "$DATA_DIR/backups/backup-$(date "%D-%H-%M-%S").tar.gz" "$BACKUP_FOLDER/"
rm -r "${BACKUP_FOLDER:?}/" rm -r "${BACKUP_FOLDER:?}/"
echo "==="
echo "Backup process succeeded." echo "Backup process succeeded."
exit 0 exit 0
} }
appRestore() { appRestore() {
echo "Starting restore process ..." echo "Starting restore process ..."
echo "==="
if [ "$(ls -A "$DATA_DIR/backups/")" ]; then if [ "$(ls -A "$DATA_DIR/backups/")" ]; then
echo "No backups to restore found in \"$DATA_DIR/backups/\"." echo "No backups to restore found in \"$DATA_DIR/backups/\"."
echo "==="
echo "Restore process failed." echo "Restore process failed."
exit 1 exit 1
fi fi
@@ -595,11 +564,11 @@ appRestore() {
done done
echo "File \"$BACKUP_FILE\" found." echo "File \"$BACKUP_FILE\" found."
echo "" echo ""
echo "==============================================================" echo "==============================================================="
echo "!! WARNING !! Your current data will be deleted!" echo "!! WARNING !! Your current data will be deleted!"
echo "!! WARNING !! YOU HAVE BEEN WARNED! You can abort with \"CTRL+C\"." echo "!! WARNING !! YOU HAVE BEEN WARNED! You can abort with \"CTRL+C\"."
echo "!! WARNING !! Waiting 10 seconds before continuing ..." echo "!! WARNING !! Waiting 10 seconds before continuing ..."
echo "==============================================================" echo "==============================================================="
echo "" echo ""
local TIMEOUT=10 local TIMEOUT=10
while true; do while true; do
@@ -615,7 +584,6 @@ appRestore() {
tar -zxvf "$DATA_DIR/backups/$BACKUP_FILE" -C /tmp tar -zxvf "$DATA_DIR/backups/$BACKUP_FILE" -C /tmp
psql -h "$DB_HOST" -p "$DB_HOST_PORT" -U "$DB_USER" "$DB_NAME" < "/tmp/$(basename "$BACKUP_FILE" | cut -d. -f1)/database-postgres.sql" psql -h "$DB_HOST" -p "$DB_HOST_PORT" -U "$DB_USER" "$DB_NAME" < "/tmp/$(basename "$BACKUP_FILE" | cut -d. -f1)/database-postgres.sql"
rm -r "/tmp/$(basename | cut -d. -f1)/" rm -r "/tmp/$(basename | cut -d. -f1)/"
echo "==="
echo "Restore process succeeded." echo "Restore process succeeded."
exit 0 exit 0
} }

View File

@@ -39,7 +39,7 @@ location /api/v1/events {
proxy_pass http://tornado; proxy_pass http://tornado;
include /etc/nginx/zulip-include/proxy_longpolling; include /etc/nginx/zulip-include/proxy_longpolling;
proxy_buffering on;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
} }