start.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. set -eu -o pipefail
  3. fqdn=$(hostname -f)
  4. chown -R cloudron.cloudron /app/data
  5. # clean up old logs
  6. rm -rf /home/cloudron/gogs/log && mkdir -p /home/cloudron/gogs/log
  7. chown cloudron:cloudron /home/cloudron/gogs/log
  8. # Dockerfile changes the ownership of this file to make it writable by cloudron user
  9. sed -e "s/^Port .*/Port ${SSH_PORT}/" \
  10. -e "s/^#ListenAddress .*/ListenAddress 0.0.0.0/" \
  11. -i /etc/ssh/sshd_config
  12. mkdir -p /home/cloudron/gogs/custom/conf
  13. sed -e "s/##HOSTNAME/${fqdn}/g" \
  14. -e "s/##SSH_PORT/${SSH_PORT}/g" \
  15. -e "s/##MYSQL_HOST/${MYSQL_HOST}/g" \
  16. -e "s/##MYSQL_PORT/${MYSQL_PORT}/g" \
  17. -e "s/##MYSQL_USERNAME/${MYSQL_USERNAME}/g" \
  18. -e "s/##MYSQL_PASSWORD/${MYSQL_PASSWORD}/g" \
  19. -e "s/##MYSQL_DATABASE/${MYSQL_DATABASE}/g" \
  20. -e "s/##MAIL_SERVER/${MAIL_SMTP_SERVER}/g" \
  21. -e "s/##MAIL_PORT/${MAIL_SMTP_PORT}/g" \
  22. -e "s/##MAIL_FROM/${MAIL_SMTP_USERNAME}@${MAIL_DOMAIN}/g" \
  23. -e "s/##SECRET_KEY/$(pwgen -1 -s)/g" \
  24. /home/cloudron/app.ini.template > "/home/cloudron/gogs/custom/conf/app.ini"
  25. chown cloudron:cloudron /home/cloudron/gogs/custom/conf/app.ini
  26. /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i Gogs &
  27. sleep 10 # on first run, lets gogs finish the db setup
  28. # id, type, name, is_actived, cfg, allow_auto_register, created, updated
  29. mysql -u"${MYSQL_USERNAME}" -p"${MYSQL_PASSWORD}" -h mysql --database="${MYSQL_DATABASE}" \
  30. -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');"
  31. supervisorctl restart gogs
  32. wait