postinst 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. # source debconf library
  20. . /usr/share/debconf/confmodule
  21. case "$1" in
  22. configure)
  23. mkdir -p $(dirname ${APP_CONFIG})
  24. chown ${APP_USER}.${APP_GROUP} $(dirname ${APP_CONFIG})
  25. [ -f ${APP_CONFIG} ] || ${CLI} run cp conf/app.ini ${APP_CONFIG}
  26. ${CLI} config:set USER=${APP_USER}
  27. ${CLI} config:set GOGS_CUSTOM="/etc/${APP_NAME}"
  28. PORT=$(${CLI} config:get PORT || echo "6000")
  29. sed -i "s|HTTP_PORT = 3000|HTTP_PORT = ${PORT}|" ${APP_CONFIG}
  30. sed -i "s|RUN_USER = git|RUN_USER = ${APP_USER}|" ${APP_CONFIG}
  31. sed -i "s|RUN_MODE = dev|RUN_MODE = prod|" ${APP_CONFIG}
  32. # scale
  33. ${CLI} scale web=1 || true
  34. ;;
  35. abort-upgrade|abort-remove|abort-deconfigure)
  36. exit 0
  37. ;;
  38. *)
  39. echo "postinst called with unknown argument \`$1'" >&2
  40. exit 1
  41. ;;
  42. esac