Installing on freebsd 10


Here are my notes for installing gogs on a FreeBSD 10.2 system. It was very straight forward.

To build:

# you need to make sure these packages are installed.
pkg install go zip gmake

setenv GOPATH ~/go
go get -u --tags "sqlite"
go build --tags "sqlite"

cd $GOPATH/src/
gmake pack

The release/gogs.$ file can then be copied to where it is needed.

To set it up:

Create a user “gogs” with a home directory in a suitably large place.
Make sure git and bash are installed.

Pick a place to install the binary package. I chose “/web/gogs”

as root:

cd /web
unzip ~vivek/sources/
mkdir /web/gogs/custom
chown gogs:gogs /web/gogs/custom

mkdir /var/log/gogs
chown gogs:gogs /var/log/gogs

first time setup:
cd ~gogs
su gogs -c “/web/gogs/gogs web”

Configure to use sqlite3 database and whatever else settings you like.
Configure logging to go to /var/log/gogs

type ctrl-c to exit gogs command line.

I then set up a reverse proxy so it goes thru the main apache server running on my source code tracking server (it also handles subversion, jira, etc.) and tweaked my app.ini file which is in /web/gogs/custom/conf to suit my needs.

To manage start/stop, I made this nice compact rc.d script. Instead of redirecting the stdout to a file which could grow unbounded, I pipe it thru a logger daemon and configured syslogd to write that to a file which can be log rotated easily.

–cut here–
# $Id: 4668 2015-10-14 19:12:38Z khera $
# PROVIDE: gogs
# Add the following lines to /etc/rc.conf to run gogs:
# gogs_enable (bool): Set it to “YES” to enable Gogs server.
# Default is “NO”.
# gogs_username: User name to run as. default “gogs”
# gogs_path (path): Path to gogs installation (contains
# the gogs executable and template dirs)
# gogs_loglevel: The syslog level to log web output.
# Default is “”

. /etc/rc.subr



: ${gogs_enable="NO"}
: ${gogs_username="gogs"}
: ${gogs_path="/web/gogs"}
: ${gogs_loglevel=""}

gogs_chdir=$(getent passwd ${gogs_username} | cut -d: -f6)

command_args=" -u ${gogs_username} /bin/sh -c '${procname} web | /usr/bin/logger -i -t ${name} -p ${gogs_loglevel}'"

# must configure before we run as a service

gogs_precmd() {
  export USER=${gogs_username}
  export HOME=${gogs_chdir}
  export PATH=${PATH}:/usr/local/bin

load_rc_config ${name}

run_rc_command "$1"

–cut here–


This step actually needs to be

cd $GOPATH/src/
go build --tags "sqlite"