always create required varibales in config file

This commit is contained in:
Praveen Arimbrathodiyil 2017-04-19 15:34:07 +05:30
parent 50856123c5
commit ba96466d12

47
debian/postinst vendored
View file

@ -138,18 +138,35 @@ case "$1" in
cd ${gitlab_app_root} cd ${gitlab_app_root}
# Obtain hostname from debconf db # Obtain hostname from debconf db
db_get gitlab/fqdn
if [ "${RET}" != "" ]; then
if ! grep GITLAB_HOST ${gitlab_debian_conf_private}; then
echo "Configuring hostname and email..." echo "Configuring hostname and email..."
export GITLAB_HOST=${RET} # We need this to configure nginx below db_get gitlab/fqdn
cat <<EOF >> ${gitlab_debian_conf_private} GITLAB_HOST=$RET
GITLAB_HOST=${RET} GITLAB_EMAIL_FROM="no-reply@$GITLAB_HOST"
GITLAB_EMAIL_FROM="no-reply@${RET}" GITLAB_EMAIL_DISPLAY_NAME="Gitlab"
GITLAB_EMAIL_DISPLAY_NAME="Gitlab" GITLAB_EMAIL_REPLY_TO="no-reply@$GITLAB_HOST"
GITLAB_EMAIL_REPLY_TO="no-reply@${RET}" db_get gitlab/user
EOF gitlab_user=$RET
fi cp -a -f ${gitlab_debian_conf_private} ${gitlab_debian_conf_private}.tmp
# If the admin deleted or commented some variables but then set
# them via debconf, (re-)add them to the conffile.
test -z "$GITLAB_HOST" || grep -Eq '^ *GITLAB_HOST=' ${gitlab_debian_conf_private} || \
echo "GITLAB_HOST=" >> ${gitlab_debian_conf_private}
test -z "$GITLAB_EMAIL_FROM" || grep -Eq '^ *GITLAB_EMAIL_FROM=' ${gitlab_debian_conf_private} || \
echo "GITLAB_EMAIL_FROM=" >> ${gitlab_debian_conf_private}
test -z "$GITLAB_EMAIL_DISPLAY_NAME" || grep -Eq '^ *GITLAB_EMAIL_DISPLAY_NAME=' ${gitlab_debian_conf_private} || \
echo "GITLAB_EMAIL_DISPLAY_NAME=" >> ${gitlab_debian_conf_private}
test -z "$GITLAB_EMAIL_REPLY_TO" || grep -Eq '^ *GITLAB_EMAIL_REPLY_TO=' ${gitlab_debian_conf_private} || \
echo "GITLAB_EMAIL_REPLY_TO=" >> ${gitlab_debian_conf_private}
test -z "$gitlab_user" || grep -Eq '^ *gitlab_user=' ${gitlab_debian_conf_private} || \
echo "gitlab_user=" >> ${gitlab_debian_conf_private}
sed -e "s/^ *GITLAB_HOST=.*/GITLAB_HOST=\"$GITLAB_HOST\"/" \
-e "s/^ *GITLAB_EMAIL_FROM=.*/GITLAB_EMAIL_FROM=\"$GITLAB_EMAIL_FROM\"/" \
-e "s/^ *GITLAB_EMAIL_DISPLAY_NAME=.*/GITLAB_EMAIL_DISPLAY_NAME=\"$GITLAB_EMAIL_DISPLAY_NAME\"/" \
-e "s/^ *GITLAB_EMAIL_REPLY_TO=.*/GITLAB_EMAIL_REPLY_TO=\"$GITLAB_EMAIL_REPLY_TO\"/" \
-e "s/^ *gitlab_user=.*/gitlab_user=\"$gitlab_user\"/" \
< ${gitlab_debian_conf_private} > ${gitlab_debian_conf_private}.tmp
mv -f ${gitlab_debian_conf_private}.tmp ${gitlab_debian_conf_private}
# Check if ssl option is selected # Check if ssl option is selected
db_get gitlab/ssl db_get gitlab/ssl
@ -161,7 +178,10 @@ EOF
test -f ${gitlab_shell_config_private} || \ test -f ${gitlab_shell_config_private} || \
cp ${gitlab_shell_config_example} ${gitlab_shell_config_private} cp ${gitlab_shell_config_example} ${gitlab_shell_config_private}
# Set gitlab user first time
sed -i "s/GITLAB_USER/${gitlab_user}/" ${gitlab_yml_private} sed -i "s/GITLAB_USER/${gitlab_user}/" ${gitlab_yml_private}
# Update gitlab user (its a hack, proper fix is to have gitlab accept GITLAB_USER variable)
sed -i "s/^ *user:.* #gitlab_user/ user: $gitlab_user #gitlab_user/" ${gitlab_yml_private}
if [ "${RET}" = "true" ]; then if [ "${RET}" = "true" ]; then
echo "Configuring nginx with HTTPS..." echo "Configuring nginx with HTTPS..."
@ -176,7 +196,6 @@ EOF
sed -i \ sed -i \
"s/gitlab_url: http*:\/\/.*/gitlab_url: ${gl_proto}:\/\/${GITLAB_HOST}/"\ "s/gitlab_url: http*:\/\/.*/gitlab_url: ${gl_proto}:\/\/${GITLAB_HOST}/"\
${gitlab_shell_config_private} ${gitlab_shell_config_private}
fi fi
mkdir -p /etc/gitlab/ssl mkdir -p /etc/gitlab/ssl
@ -261,10 +280,6 @@ EOF
echo "Reloading nginx configuration..." echo "Reloading nginx configuration..."
invoke-rc.d nginx reload invoke-rc.d nginx reload
fi fi
else
echo "Failed to retrieve fully qualified domain name"
exit 1
fi
db_stop db_stop
echo "Create database if not present" echo "Create database if not present"