postinst 869 B

123456789101112131415161718192021222324252627282930313233
  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. case "$1" in
  9. abort-upgrade|abort-remove|abort-deconfigure)
  10. exit 0
  11. ;;
  12. configure|*)
  13. mkdir -p $(dirname ${APP_CONFIG})
  14. chown ${APP_USER}.${APP_GROUP} $(dirname ${APP_CONFIG})
  15. [ -f ${APP_CONFIG} ] || ${CLI} run cp conf/app.ini ${APP_CONFIG}
  16. ${CLI} config:set USER=${APP_USER}
  17. sed -i "s|RUN_USER = git|RUN_USER = ${APP_USER}|" ${APP_CONFIG}
  18. sed -i "s|RUN_MODE = dev|RUN_MODE = prod|" ${APP_CONFIG}
  19. # setup symlink towards custom conf
  20. mkdir -p /opt/${APP_NAME}/custom/conf
  21. chown -R ${APP_USER}.${APP_GROUP} /opt/${APP_NAME}/custom
  22. ln -f -s ${APP_CONFIG} /opt/${APP_NAME}/custom/conf/app.ini
  23. # scale
  24. ${CLI} scale web=1 || true
  25. ;;
  26. esac