Skip to content

Commit

Permalink
Make Gogs packageable with https://packager.io
Browse files Browse the repository at this point in the history
  • Loading branch information
crohr committed Sep 9, 2014
1 parent e21d8a7 commit 7fe6155
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions .godir
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main
11 changes: 11 additions & 0 deletions .pkgr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
buildpack: "https://github.com/kr/heroku-buildpack-go.git"
targets:
ubuntu-14.04:
build_dependencies:
- mercurial
- bzr
dependencies:
- git
after:
- mv bin/main gogs
after_install: ./packaging/debian/postinst
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: ./gogs web
51 changes: 51 additions & 0 deletions packaging/debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh

set -e

# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

APP_NAME="gogs"
CLI="${APP_NAME}"
APP_USER=$(${CLI} config:get APP_USER)
APP_GROUP=$(${CLI} config:get APP_GROUP)
APP_CONFIG="/etc/${APP_NAME}/conf/app.ini"

# source debconf library
. /usr/share/debconf/confmodule

case "$1" in

configure)
mkdir -p $(dirname ${APP_CONFIG})
chown ${APP_USER}.${APP_GROUP} $(dirname ${APP_CONFIG})
[ -f ${APP_CONFIG} ] || ${CLI} run cp conf/app.ini ${APP_CONFIG}
${CLI} config:set USER=${APP_USER}
${CLI} config:set GOGS_CUSTOM="/etc/${APP_NAME}"
PORT=$(${CLI} config:get PORT || echo "6000")

This comment has been minimized.

Copy link
@FSMaxB

FSMaxB May 14, 2015

Why is this port changed to a port that is blocked by most browsers by default? (see http://www-archive.mozilla.org/projects/netlib/PortBanning.html )

sed -i "s|HTTP_PORT = 3000|HTTP_PORT = ${PORT}|" ${APP_CONFIG}
sed -i "s|RUN_USER = git|RUN_USER = ${APP_USER}|" ${APP_CONFIG}
sed -i "s|RUN_MODE = dev|RUN_MODE = prod|" ${APP_CONFIG}

# scale
${CLI} scale web=1 || true
;;

abort-upgrade|abort-remove|abort-deconfigure)
exit 0
;;

*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac

0 comments on commit 7fe6155

Please sign in to comment.