Skip to content

Commit de78ce6

Browse files
committed
entrypoint: Run shfmt.
1 parent f2a7288 commit de78ce6

File tree

1 file changed

+63
-64
lines changed

1 file changed

+63
-64
lines changed

entrypoint.sh

Lines changed: 63 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -86,37 +86,37 @@ setConfigurationValue() {
8686
local TYPE="$4"
8787
if [ -z "$TYPE" ]; then
8888
case "$2" in
89-
[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|[Nn]one)
90-
TYPE="bool"
91-
;;
89+
[Tt][Rr][Uu][Ee] | [Ff][Aa][Ll][Ss][Ee] | [Nn]one)
90+
TYPE="bool"
91+
;;
9292
+([0-9]))
93-
TYPE="integer"
94-
;;
93+
TYPE="integer"
94+
;;
9595
[\[\(]*[\]\)])
96-
TYPE="array"
97-
;;
96+
TYPE="array"
97+
;;
9898
*)
99-
TYPE="string"
100-
;;
99+
TYPE="string"
100+
;;
101101
esac
102102
fi
103103
case "$TYPE" in
104104
emptyreturn)
105-
if [ -z "$2" ]; then
106-
return 0
107-
fi
108-
;;
105+
if [ -z "$2" ]; then
106+
return 0
107+
fi
108+
;;
109109
literal)
110-
VALUE="$1"
111-
;;
112-
bool|boolean|int|integer|array)
113-
VALUE="$KEY = $2"
114-
;;
115-
string|*)
116-
VALUE="$KEY = '${2//\'/\'}'"
117-
;;
110+
VALUE="$1"
111+
;;
112+
bool | boolean | int | integer | array)
113+
VALUE="$KEY = $2"
114+
;;
115+
string | *)
116+
VALUE="$KEY = '${2//\'/\'}'"
117+
;;
118118
esac
119-
echo "$VALUE" >> "$FILE"
119+
echo "$VALUE" >>"$FILE"
120120
echo "Setting key \"$KEY\", type \"$TYPE\" in file \"$FILE\"."
121121
}
122122
nginxConfiguration() {
@@ -260,7 +260,7 @@ authenticationBackends() {
260260
echo "Activating authentication backends ..."
261261
local FIRST=true
262262
local auth_backends
263-
IFS=, read -r -a auth_backends <<< "$ZULIP_AUTH_BACKENDS"
263+
IFS=, read -r -a auth_backends <<<"$ZULIP_AUTH_BACKENDS"
264264
for AUTH_BACKEND in "${auth_backends[@]}"; do
265265
if [ "$FIRST" = true ]; then
266266
setConfigurationValue "AUTHENTICATION_BACKENDS" "('zproject.backends.${AUTH_BACKEND//\'/\'}',)" "$SETTINGS_PY" "array"
@@ -275,7 +275,7 @@ authenticationBackends() {
275275
zulipConfiguration() {
276276
echo "Executing Zulip configuration ..."
277277
if [ -n "$ZULIP_CUSTOM_SETTINGS" ]; then
278-
echo -e "\n$ZULIP_CUSTOM_SETTINGS" >> "$SETTINGS_PY"
278+
echo -e "\n$ZULIP_CUSTOM_SETTINGS" >>"$SETTINGS_PY"
279279
fi
280280
local key
281281
for key in "${!SETTING_@}"; do
@@ -288,35 +288,35 @@ zulipConfiguration() {
288288
continue
289289
fi
290290
# Zulip settings.py / zproject specific overrides here
291-
if [ "$setting_key" = "AUTH_LDAP_CONNECTION_OPTIONS" ] || \
292-
[ "$setting_key" = "AUTH_LDAP_GLOBAL_OPTIONS" ] || \
293-
[ "$setting_key" = "AUTH_LDAP_USER_SEARCH" ] || \
294-
[ "$setting_key" = "AUTH_LDAP_GROUP_SEARCH" ] || \
295-
[ "$setting_key" = "AUTH_LDAP_REVERSE_EMAIL_SEARCH" ] || \
296-
[ "$setting_key" = "AUTH_LDAP_USER_ATTR_MAP" ] || \
297-
[ "$setting_key" = "AUTH_LDAP_USER_FLAGS_BY_GROUP" ] || \
298-
[ "$setting_key" = "AUTH_LDAP_GROUP_TYPE" ] || \
299-
[ "$setting_key" = "AUTH_LDAP_ADVANCED_REALM_ACCESS_CONTROL" ] || \
300-
[ "$setting_key" = "LDAP_SYNCHRONIZED_GROUPS_BY_REALM" ] || \
301-
[ "$setting_key" = "SOCIAL_AUTH_OIDC_ENABLED_IDPS" ] || \
302-
[ "$setting_key" = "SOCIAL_AUTH_SAML_ENABLED_IDPS" ] || \
303-
[ "$setting_key" = "SOCIAL_AUTH_SAML_ORG_INFO" ] || \
304-
[ "$setting_key" = "SOCIAL_AUTH_SYNC_ATTRS_DICT" ] || \
305-
{ [ "$setting_key" = "LDAP_APPEND_DOMAIN" ] && [ "$setting_var" = "None" ]; } || \
306-
[ "$setting_key" = "SCIM_CONFIG" ] || \
307-
[ "$setting_key" = "SECURE_PROXY_SSL_HEADER" ] || \
308-
[[ "$setting_key" = "CSRF_"* ]] || \
309-
[ "$setting_key" = "REALM_HOSTS" ] || \
310-
[ "$setting_key" = "ALLOWED_HOSTS" ]; then
291+
if [ "$setting_key" = "AUTH_LDAP_CONNECTION_OPTIONS" ] \
292+
|| [ "$setting_key" = "AUTH_LDAP_GLOBAL_OPTIONS" ] \
293+
|| [ "$setting_key" = "AUTH_LDAP_USER_SEARCH" ] \
294+
|| [ "$setting_key" = "AUTH_LDAP_GROUP_SEARCH" ] \
295+
|| [ "$setting_key" = "AUTH_LDAP_REVERSE_EMAIL_SEARCH" ] \
296+
|| [ "$setting_key" = "AUTH_LDAP_USER_ATTR_MAP" ] \
297+
|| [ "$setting_key" = "AUTH_LDAP_USER_FLAGS_BY_GROUP" ] \
298+
|| [ "$setting_key" = "AUTH_LDAP_GROUP_TYPE" ] \
299+
|| [ "$setting_key" = "AUTH_LDAP_ADVANCED_REALM_ACCESS_CONTROL" ] \
300+
|| [ "$setting_key" = "LDAP_SYNCHRONIZED_GROUPS_BY_REALM" ] \
301+
|| [ "$setting_key" = "SOCIAL_AUTH_OIDC_ENABLED_IDPS" ] \
302+
|| [ "$setting_key" = "SOCIAL_AUTH_SAML_ENABLED_IDPS" ] \
303+
|| [ "$setting_key" = "SOCIAL_AUTH_SAML_ORG_INFO" ] \
304+
|| [ "$setting_key" = "SOCIAL_AUTH_SYNC_ATTRS_DICT" ] \
305+
|| { [ "$setting_key" = "LDAP_APPEND_DOMAIN" ] && [ "$setting_var" = "None" ]; } \
306+
|| [ "$setting_key" = "SCIM_CONFIG" ] \
307+
|| [ "$setting_key" = "SECURE_PROXY_SSL_HEADER" ] \
308+
|| [[ "$setting_key" = "CSRF_"* ]] \
309+
|| [ "$setting_key" = "REALM_HOSTS" ] \
310+
|| [ "$setting_key" = "ALLOWED_HOSTS" ]; then
311311
type="array"
312312
fi
313-
if [ "$SPECIAL_SETTING_DETECTION_MODE" = "True" ] || [ "$SPECIAL_SETTING_DETECTION_MODE" = "true" ] || \
314-
[ "$type" = "string" ]; then
313+
if [ "$SPECIAL_SETTING_DETECTION_MODE" = "True" ] || [ "$SPECIAL_SETTING_DETECTION_MODE" = "true" ] \
314+
|| [ "$type" = "string" ]; then
315315
type=""
316316
fi
317-
if [ "$setting_key" = "EMAIL_HOST_USER" ] || \
318-
[ "$setting_key" = "EMAIL_HOST_PASSWORD" ] || \
319-
[ "$setting_key" = "EXTERNAL_HOST" ]; then
317+
if [ "$setting_key" = "EMAIL_HOST_USER" ] \
318+
|| [ "$setting_key" = "EMAIL_HOST_PASSWORD" ] \
319+
|| [ "$setting_key" = "EXTERNAL_HOST" ]; then
320320
type="string"
321321
fi
322322
setConfigurationValue "$setting_key" "$setting_var" "$SETTINGS_PY" "$type"
@@ -333,7 +333,7 @@ autoBackupConfiguration() {
333333
echo "Auto backup is disabled. Continuing."
334334
return 0
335335
fi
336-
printf 'MAILTO=""\n%s cd /;/sbin/entrypoint.sh app:backup\n' "$AUTO_BACKUP_INTERVAL" > /etc/cron.d/autobackup
336+
printf 'MAILTO=""\n%s cd /;/sbin/entrypoint.sh app:backup\n' "$AUTO_BACKUP_INTERVAL" >/etc/cron.d/autobackup
337337
echo "Auto backup enabled."
338338
}
339339
initialConfiguration() {
@@ -357,8 +357,7 @@ initialConfiguration() {
357357
waitingForDatabase() {
358358
local TIMEOUT=60
359359
echo "Waiting for database server to allow connections ..."
360-
while ! PGPASSWORD="${SECRETS_postgres_password?}" /usr/bin/pg_isready -h "$DB_HOST" -p "$DB_HOST_PORT" -U "$DB_USER" -t 1 >/dev/null 2>&1
361-
do
360+
while ! PGPASSWORD="${SECRETS_postgres_password?}" /usr/bin/pg_isready -h "$DB_HOST" -p "$DB_HOST_PORT" -U "$DB_USER" -t 1 >/dev/null 2>&1; do
362361
if ! ((TIMEOUT--)); then
363362
echo "Could not connect to database server. Exiting."
364363
exit 1
@@ -435,7 +434,7 @@ function runCertbotAsNeeded() {
435434

436435
echo "Waiting for nginx to come online before generating certbot certificate ..."
437436
while ! curl -sk "$SETTING_EXTERNAL_HOST" >/dev/null 2>&1; do
438-
sleep 1;
437+
sleep 1
439438
done
440439

441440
echo "Generating LetsEncrypt/certbot certificate ..."
@@ -507,7 +506,7 @@ appBackup() {
507506
BACKUP_FOLDER="/tmp/backup-$TIMESTAMP)"
508507
mkdir -p "$BACKUP_FOLDER"
509508
waitingForDatabase
510-
pg_dump -h "$DB_HOST" -p "$DB_HOST_PORT" -U "$DB_USER" "$DB_NAME" > "$BACKUP_FOLDER/database-postgres.sql"
509+
pg_dump -h "$DB_HOST" -p "$DB_HOST_PORT" -U "$DB_USER" "$DB_NAME" >"$BACKUP_FOLDER/database-postgres.sql"
511510
tar -zcvf "$DATA_DIR/backups/backup-$TIMESTAMP.tar.gz" "$BACKUP_FOLDER/"
512511
rm -r "${BACKUP_FOLDER:?}/"
513512
echo "Backup process succeeded."
@@ -552,7 +551,7 @@ appRestore() {
552551
echo "!! WARNING !! Starting restore process ... !! WARNING !!"
553552
waitingForDatabase
554553
tar -zxvf "$DATA_DIR/backups/$BACKUP_FILE" -C /tmp
555-
psql -h "$DB_HOST" -p "$DB_HOST_PORT" -U "$DB_USER" "$DB_NAME" < "/tmp/$(basename "$BACKUP_FILE" | cut -d. -f1)/database-postgres.sql"
554+
psql -h "$DB_HOST" -p "$DB_HOST_PORT" -U "$DB_USER" "$DB_NAME" <"/tmp/$(basename "$BACKUP_FILE" | cut -d. -f1)/database-postgres.sql"
556555
rm -r "/tmp/$(basename "$BACKUP_FILE" | cut -d. -f1)/"
557556
echo "Restore process succeeded. Exiting."
558557
exit 0
@@ -583,30 +582,30 @@ appVersion() {
583582
case "$1" in
584583
app:run)
585584
appRun
586-
;;
585+
;;
587586
app:init)
588587
appInit
589-
;;
588+
;;
590589
app:managepy)
591590
shift 1
592591
appManagePy "$@"
593-
;;
592+
;;
594593
app:backup)
595594
appBackup
596-
;;
595+
;;
597596
app:restore)
598597
appRestore
599-
;;
598+
;;
600599
app:certs)
601600
appCerts
602-
;;
601+
;;
603602
app:help)
604603
appHelp
605-
;;
604+
;;
606605
app:version)
607606
appVersion
608-
;;
607+
;;
609608
*)
610609
exec "$@" || appHelp
611-
;;
610+
;;
612611
esac

0 commit comments

Comments
 (0)