You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.4 KiB

  1. #!/bin/sh
  2. set -e
  3. # summary of how this script can be called:
  4. # * <postinst> `configure' <most-recently-configured-version>
  5. # * <old-postinst> `abort-upgrade' <new version>
  6. # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
  7. # <new-version>
  8. # * <postinst> `abort-remove'
  9. # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
  10. # <failed-install-package> <version> `removing'
  11. # <conflicting-package> <version>
  12. # for details, see http://www.debian.org/doc/debian-policy/ or
  13. # the debian-policy package
  14. APP_NAME="gogs"
  15. CLI="${APP_NAME}"
  16. APP_USER=$(${CLI} config:get APP_USER)
  17. APP_GROUP=$(${CLI} config:get APP_GROUP)
  18. APP_CONFIG="/etc/${APP_NAME}/conf/app.ini"
  19. case "$1" in
  20. configure)
  21. mkdir -p $(dirname ${APP_CONFIG})
  22. chown ${APP_USER}.${APP_GROUP} $(dirname ${APP_CONFIG})
  23. [ -f ${APP_CONFIG} ] || ${CLI} run cp conf/app.ini ${APP_CONFIG}
  24. ${CLI} config:set USER=${APP_USER}
  25. ${CLI} config:set GOGS_CUSTOM="/etc/${APP_NAME}"
  26. PORT=$(${CLI} config:get PORT || echo "6000")
  27. sed -i "s|HTTP_PORT = 3000|HTTP_PORT = ${PORT}|" ${APP_CONFIG}
  28. sed -i "s|RUN_USER = git|RUN_USER = ${APP_USER}|" ${APP_CONFIG}
  29. sed -i "s|RUN_MODE = dev|RUN_MODE = prod|" ${APP_CONFIG}
  30. # scale
  31. ${CLI} scale web=1 || true
  32. ;;
  33. abort-upgrade|abort-remove|abort-deconfigure)
  34. exit 0
  35. ;;
  36. *)
  37. echo "postinst called with unknown argument \`$1'" >&2
  38. exit 1
  39. ;;
  40. esac