Installing on freebsd 10


#1

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" github.com/gogits/gogs
go build --tags "sqlite" github.com/gogits/gogs

cd $GOPATH/src/github.com/gogits/gogs/
gmake pack

The release/gogs.$DATE.zip 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/gogs.20160506122948.zip
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–
#!/bin/sh
#
# $Id: gogs.sh.in 4668 2015-10-14 19:12:38Z khera $
#
# PROVIDE: gogs
# REQUIRE: DAEMON
#
# 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 “local1.info”
#

. /etc/rc.subr

name="gogs"
rcvar=`set_rcvar`

start_precmd=${name}_precmd

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

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

command=/usr/sbin/daemon
procname=${gogs_path}/gogs
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
required_files="${gogs_path}/custom/conf/app.ini"

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–


#2

This step actually needs to be

cd $GOPATH/src/github.com/gogits/gogs/
go build --tags "sqlite"