2
0

postinst 634 B

123456789101112131415161718192021222324
  1. #!/bin/sh
  2. set -e
  3. APP_NAME="gogs"
  4. CLI="${APP_NAME}"
  5. APP_USER=$(${CLI} config:get APP_USER)
  6. APP_GROUP=$(${CLI} config:get APP_GROUP)
  7. APP_CONFIG="/etc/${APP_NAME}/conf/app.ini"
  8. mkdir -p "$(dirname ${APP_CONFIG})"
  9. chown "${APP_USER}"."${APP_GROUP}" "$(dirname ${APP_CONFIG})"
  10. [ -f ${APP_CONFIG} ] || ${CLI} run cp conf/app.ini ${APP_CONFIG}
  11. ${CLI} config:set USER="${APP_USER}"
  12. sed -i "s|RUN_USER = git|RUN_USER = ${APP_USER}|" ${APP_CONFIG}
  13. sed -i "s|RUN_MODE = dev|RUN_MODE = prod|" ${APP_CONFIG}
  14. ${CLI} config:set GOGS_CUSTOM=/etc/${APP_NAME}
  15. # scale
  16. ${CLI} scale web=1 || true
  17. # restart the service
  18. service gogs restart || true