Sun, 19 Dec 2021

1:49 AM - Setting up an OpenGrok server on FreeBSD

FreeBSD has OpenGrok in the ports tree. You can install it two ways.  One is to use the devel/opengrok port which will also pull down tomcat85 and java 8 currently. The second is the py38-opengrok-tools which includes utilities to install an opengrok instance via the opengrok-deploy script.

This post assumes you went with the first opengrok port.  

Once it's installed, (1.3.x release) you will find that the port is partially broken.  You need to hand edit the /usr/local/bin/opengrok script to remove the -w opengrok flag and change extags to uctags. 

Next, you will want to enable the tomcat instance to startup via sysrc tomcat85_enable=YES  

Based on recommendations, you likely want to tune RAM usage although it can run on less than the recommended 8GB if you don't have big codebases. 

Before you start tomcat, there are a few more things to do.  You need to edit the WEB-INF/web.xml file in the /usr/local/apache-tomcat-8.5/webapps directory to point at the correct config file location.  We assume /var/opengrok/etc/configuration.xml

Next you must run the indexer!  This part is confusing because if you try to run the app first, it will blow up and possibly show a 404 in tomcat. 

Make sure you have some code checked out in /var/opengrok/src  (make it a subdirectory) 
Also make sure all the directories exist and can be accessed by the www user tomcat runs under

Example command line for that:
/usr/local/bin/opengrok -r on -O on -s /var/opengrok/src -P -d /var/opengrok/data -H  -U http://localhost:8080/opengrok -W /var/opengrok/etc/configuration.xml
 -c /usr/local/bin/uctags

It should generate a default config file although that doesn't always seem to work.  It's supposed to overwrite this every time you run it.

0 comments