Skip calling the install route

The install route is just a convenience if app.ini has not been setup.
gogs always sets up the db on startup if app.ini is setup correctly.
This commit is contained in:
Girish Ramakrishnan 2015-08-18 13:44:26 -07:00
parent c6dca06ef9
commit 4d15edc19f
2 changed files with 9 additions and 38 deletions

View file

@ -1,3 +1,4 @@
APP_NAME = Gogs: Go Git Service
RUN_USER = cloudron RUN_USER = cloudron
RUN_MODE = prod RUN_MODE = prod
@ -7,7 +8,7 @@ HOST = ##MYSQL_HOST:##MYSQL_PORT
NAME = ##MYSQL_DATABASE NAME = ##MYSQL_DATABASE
USER = ##MYSQL_USERNAME USER = ##MYSQL_USERNAME
PASSWD = ##MYSQL_PASSWORD PASSWD = ##MYSQL_PASSWORD
SSL_MODE = SSL_MODE = disable
PATH = PATH =
[repository] [repository]

View file

@ -15,44 +15,8 @@ sed -e "s/^Port .*/Port ${SSH_PORT}/" \
-e "s/^#ListenAddress .*/ListenAddress 0.0.0.0/" \ -e "s/^#ListenAddress .*/ListenAddress 0.0.0.0/" \
-i /etc/ssh/sshd_config -i /etc/ssh/sshd_config
/usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i Gogs &
sleep 3
if [[ ! -f /home/cloudron/gogs/custom/conf/app.ini ]]; then
echo "Triggering installation"
mkdir -p /home/cloudron/gogs/custom/conf mkdir -p /home/cloudron/gogs/custom/conf
touch /home/cloudron/gogs/custom/conf/app.ini
chown cloudron:cloudron /home/cloudron/gogs/custom/conf/app.ini
admin_password=$(pwgen -1)
echo "Admin password set to ${admin_password}"
# the values here are mostly overwritten by the template file below
curl -X POST http://localhost:3000/install \
--data db_type=MySQL \
--data-urlencode "db_host=${MYSQL_HOST}:${MYSQL_PORT}" \
--data "db_user=${MYSQL_USERNAME}" \
--data-urlencode "db_passwd=${MYSQL_PASSWORD}" \
--data "db_name=${MYSQL_DATABASE}" \
--data "ssl_mode=disable" \
--data-urlencode "app_name=Gogs: Go Git Service" \
--data-urlencode "repo_root_path=/tmp" \
--data run_user=cloudron \
--data "domain=${fqdn}" \
--data http_port=3000 \
--data-urlencode "app_url=https://${fqdn}/" \
--data "smtp_host=${MAIL_SMTP_SERVER}" \
--data smtp_user= \
--data smtp_pwd= \
--data admin_name=administrator \
--data-urlencode admin_passwd=${admin_password} \
--data-urlencode admin_confirm_passwd=${admin_password} \
--data-urlencode admin_email=${MAIL_SMTP_USERNAME}@${MAIL_DOMAIN}
fi
# use GOGS_CONFIG maybe for this but not very documented
sed -e "s/##HOSTNAME/${fqdn}/g" \ sed -e "s/##HOSTNAME/${fqdn}/g" \
-e "s/##SSH_PORT/${SSH_PORT}/g" \ -e "s/##SSH_PORT/${SSH_PORT}/g" \
-e "s/##MYSQL_HOST/${MYSQL_HOST}/g" \ -e "s/##MYSQL_HOST/${MYSQL_HOST}/g" \
@ -66,6 +30,12 @@ sed -e "s/##HOSTNAME/${fqdn}/g" \
-e "s/##SECRET_KEY/$(pwgen -1 -s)/g" \ -e "s/##SECRET_KEY/$(pwgen -1 -s)/g" \
/home/cloudron/app.ini.template > "/home/cloudron/gogs/custom/conf/app.ini" /home/cloudron/app.ini.template > "/home/cloudron/gogs/custom/conf/app.ini"
chown cloudron:cloudron /home/cloudron/gogs/custom/conf/app.ini
/usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i Gogs &
sleep 10 # on first run, lets gogs finish the db setup
# id, type, name, is_actived, cfg, allow_auto_register, created, updated # id, type, name, is_actived, cfg, allow_auto_register, created, updated
mysql -u"${MYSQL_USERNAME}" -p"${MYSQL_PASSWORD}" -h mysql --database="${MYSQL_DATABASE}" \ 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))\",\"Enabled\":true}',1,'2015-06-24 17:14:12','2015-06-24 17:25:03');" -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))\",\"Enabled\":true}',1,'2015-06-24 17:14:12','2015-06-24 17:25:03');"