Project

General

Profile

Install Adaguc on Ubuntu » History » Version 59

Version 58 (Maarten Plieger, 02/15/2019 02:26 PM) → Version 59/77 (Maarten Plieger, 02/15/2019 02:26 PM)

h1. Install Adaguc Server and Adaguc Viewer on Ubuntu LTS 16.04.2

The following repositories are used:
* https://github.com/KNMI/adaguc-services - Java application for running adaguc-server from tomcat or as a spring boot application
* https://github.com/KNMI/adaguc-server - C++ server for serving WMS, WCS and OpenDAP
* https://github.com/KNMI/adaguc-viewer - Javascript web client for connecting to WMS

This procedure was followed to create the ADAGUC VM image:

Install packages
<pre>
sudo apt-get -y install vim kate kwrite konsole g++ m4 ncview curl git
sudo apt-get -y install postgresql postgresql-server-dev-all postgresql-client postgresql-client-common postgresql-contrib
sudo apt-get -y install libcurl4-openssl-dev libcairo2-dev libxml2-dev libgd2-xpm-dev libudunits2-dev udunits-bin netcdf-bin libnetcdf-dev libhdf5-dev libproj-dev libgdal-dev
sudo apt-get -y install default-jre default-jdk maven
sudo apt-get -y install chromium-browser
</pre>

Setup postgresql
<pre>
sudo service postgresql start
sudo -u postgres createuser --superuser adaguc
sudo -u postgres psql postgres -c "ALTER USER adaguc PASSWORD 'adaguc';"
sudo -u postgres psql postgres -c "CREATE DATABASE adaguc;"
echo "\q" | psql "dbname=adaguc user=adaguc password=adaguc host=localhost"
if [ ${?} -eq 0 ];then
echo "Postgres database setup correctly"
fi
</pre>

Install tomcat

<pre>
sudo mkdir -p /src/
sudo chown -R $USER: /src
cd /src/
curl -L https://archive.apache.org/dist/tomcat/tomcat-8/v8.0.44/bin/apache-tomcat-8.0.44.tar.gz > apache-tomcat-8.0.44.tar.gz
tar -xzvf apache-tomcat-8.0.44.tar.gz

printf "export CATALINA_HOME=\"/src/apache-tomcat-8.0.44\"\n\
export CATALINA_BASE=\"/src/apache-tomcat-8.0.44\"\n\
export ADAGUC_SERVICES_CONFIG=/src/config/adaguc-services-config-tomcat.xml\n\
export JAVA_HOME=\"/usr\"\n\
CONTENT_ROOT=-Dtds.content.root.path=/src/apache-tomcat-8.0.44/content\n\
JAVA_PREFS_ROOTS=\"-Djava.util.prefs.systemRoot=$CATALINA_HOME/content/thredds/javaUtilPrefs -Djava.util.prefs.userRoot=$CATALINA_HOME/content/thredds/javaUtilPrefs\"\n\
NORMAL=\"-d64 -Xmx4096m -Xms512m -server -ea\"\n\
HEAP_DUMP=\"-XX:+HeapDumpOnOutOfMemoryError\"\n\
HEADLESS=\"-Djava.awt.headless=true\"\n\
JAVA_OPTS=\"$CONTENT_ROOT $NORMAL $MAX_PERM_GEN $HEAP_DUMP $HEADLESS $JAVA_PREFS_ROOTS\"\n\
export JAVA_OPTS" > /src/apache-tomcat-8.0.44/setenv.sh

</pre>

Install adaguc-services
<pre>
sudo mkdir -p /src/KNMI
sudo chown -R $USER: /src
mkdir -p /src/config
sudo mkdir -p /data
sudo chown -R adaguc: /data
mkdir -p /data/adaguc-services-base
mkdir -p /data/adaguc-services-space
mkdir -p /src/log/
cd /src/KNMI
git clone https://github.com/KNMI/adaguc-services
cd /src/KNMI/adaguc-services
mvn package
cp ./target/adaguc-services-1.0.0-SNAPSHOT.war /src/apache-tomcat-8.0.44/webapps/adaguc-services.war

# Configure adaguc-services
printf "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
<adaguc-services>\n\
<external-home-url>http://localhost:8080/adaguc-services/</external-home-url>\n\
<basedir>/data/adaguc-services-base</basedir>\n\
<userworkspace>/data/adaguc-services-space</userworkspace>\n\
<server>\n\
<port>8080</port>\n\
</server>\n\
<security>\n\
<keystore>/src/keystore.jks</keystore>\n\
<keystorepassword>password</keystorepassword>\n\
<keystoretype>JKS</keystoretype>\n\
<keyalias>tomcat</keyalias>\n\
</security>\n\
<adaguc-server>\n\
<adagucexecutable>/src/KNMI/adaguc-server/bin/adagucserver</adagucexecutable>\n\
<export>ADAGUC_PATH=/src/KNMI/adaguc-server/</export>\n\
<export>ADAGUC_CONFIG=/src/KNMI/adaguc-server/data/config/adaguc.vm.xml</export>\n\
<export>ADAGUC_DATARESTRICTION=FALSE</export>\n\
<export>ADAGUC_FONT=/src/KNMI/adaguc-server/data/fonts/FreeSans.ttf</export>\n\
<export>ADAGUC_LOGFILE=/src/log/adaguc-server.log</export>\n\
</adaguc-server>\n\
<autowms>\n\
<enabled>true</enabled>\n\
<autowmspath>/data/adaguc-autowms/</autowmspath>\n\
<datasetpath>/data/adaguc-datasets/</datasetpath>\n\
</autowms>\n\
</adaguc-services>" > /src/config/adaguc-services-config-tomcat.xml

</pre>

Install adaguc-viewer
<pre>
cd /src/apache-tomcat-8.0.44/webapps
git clone https://github.com/KNMI/adaguc-viewer/
printf "\n\
xml2jsonrequestURL = '/adaguc-services/xml2json?'\n\
autowmsURL = '/adaguc-services/autowms?';\n\
getFeatureInfoApplications.push({name:'AutoWMS',iconCls:'button_getfeatureinfo'});\n\
" >> adaguc-viewer/config.js
</pre>

Install adaguc-server
<pre>
sudo mkdir -p /src/KNMI
sudo chown -R adaguc: /src
sudo mkdir -p /data/
sudo chown -R $USER: adaguc: /data
mkdir /data/adaguc-autowms
mkdir /data/adaguc-datasets
cd /src/KNMI
git clone https://github.com/KNMI/adaguc-server
cd /src/KNMI/adaguc-server
bash compile.sh
cp /src/KNMI/adaguc-server/data/datasets/testdata.nc /data/adaguc-autowms/
cp /src/KNMI/adaguc-server/data/config/datasets/dataset_a.xml /data/adaguc-datasets/

</pre>

Automate Start tomcat
<pre>
echo -e '#!/bin/bash
t=`ps -ef | grep apache-tomcat-8 | grep adaguc | grep -v grep`
if [ ! -z "$t" -a "$t" != " " ]; then
echo "Tomcat is running"
else
echo "Tomcat is not running, starting it"
. /src/apache-tomcat-8.0.44/setenv.sh
/src/apache-tomcat-8.0.44/bin/startup.sh
sleep 2
fi' > /src/tomcatstarter.sh
chmod +x /src/tomcatstarter.sh
/src/tomcatstarter.sh

echo -e '@reboot /src/tomcatstarter.sh > /dev/null 2>&1' > /src/crontab
crontab /src/crontab

</pre>

Visit for files in /data/adaguc-autowms:
* http://localhost:8080/adaguc-viewer/?service=http%3A%2F%2Flocalhost%3A8080%2Fadaguc-services%2Fadagucserver%3Fservice%3Dwms%26request%3Dgetcapabilities%26source%3Dtestdata.nc
Visit for datasets in /data/adaguc-datasets:
* http://localhost:8080/adaguc-viewer/?service=http%3A%2F%2Flocalhost%3A8080%2Fadaguc-services%2Fadagucserver%3Fservice%3Dwms%26request%3Dgetcapabilities%26dataset%3Ddataset_a

---

*Please note:* The previous instructions for installing adaguc using Apache CGI and PHP can be found here: [[Install_Adaguc_on_Ubuntu_Old]]