From f617a52ca35ece83a818248e5d4f61d34868b9f4 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Tue, 24 Nov 2015 11:53:21 -0800 Subject: [PATCH] Check if ldap setup succeeded --- start.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/start.sh b/start.sh index 13409d9..7794ea7 100755 --- a/start.sh +++ b/start.sh @@ -5,6 +5,8 @@ set -eu -o pipefail readonly fqdn=$(hostname -f) setup_ldap_source() { + set -eu + # Wait for gogs to finish db setup, before we insert ldap source in db while ! curl --fail http://localhost:3000/healthcheck; do echo "Waiting for gogs to come up" @@ -12,8 +14,13 @@ setup_ldap_source() { done # id, type, name, is_actived, cfg, allow_auto_register, created, updated - mysql -u"${MYSQL_USERNAME}" -p"${MYSQL_PASSWORD}" -h mysql --database="${MYSQL_DATABASE}" \ - -e "REPLACE INTO login_source VALUES (1,2,'cloudron',1,'{\"Name\":\"cloudron\",\"Host\":\"${LDAP_SERVER}\",\"Port\":${LDAP_PORT},\"UseSSL\":false,\"UserBase\":\"${LDAP_USERS_BASE_DN}\",\"AttributeUsername\":\"uid\",\"AttributeName\":\"\",\"AttributeSurname\":\"\",\"AttributeMail\":\"mail\",\"Filter\":\"(\\\\u0026(objectClass=user)(uid=%s))\",\"AdminFilter\":\"(memberof=cn=admins,${LDAP_GROUPS_BASE_DN})\",\"Enabled\":true}','2015-06-24 17:14:12','2015-06-24 17:25:03');" + if mysql -u"${MYSQL_USERNAME}" -p"${MYSQL_PASSWORD}" -h mysql --database="${MYSQL_DATABASE}" \ + -e "REPLACE INTO login_source VALUES (1,2,'cloudron',1,'{\"Name\":\"cloudron\",\"Host\":\"${LDAP_SERVER}\",\"Port\":${LDAP_PORT},\"UseSSL\":false,\"UserBase\":\"${LDAP_USERS_BASE_DN}\",\"AttributeUsername\":\"uid\",\"AttributeName\":\"\",\"AttributeSurname\":\"\",\"AttributeMail\":\"mail\",\"Filter\":\"(\\\\u0026(objectClass=user)(uid=%s))\",\"AdminFilter\":\"(memberof=cn=admins,${LDAP_GROUPS_BASE_DN})\",\"Enabled\":true}','2015-06-24 17:14:12','2015-06-24 17:25:03');"; then + echo "LDAP Authentication Setup" + else + echo "Failed to setup LDAP authentication" + exit 1 + fi } sed -e "s/^Port .*/Port ${SSH_PORT}/" \