Skip to content

Instantly share code, notes, and snippets.

@JorgeMartinezG
Last active December 22, 2020 00:03
Show Gist options
  • Save JorgeMartinezG/4ace8d6d2722e791fc211ba460b5510a to your computer and use it in GitHub Desktop.
Save JorgeMartinezG/4ace8d6d2722e791fc211ba460b5510a to your computer and use it in GitHub Desktop.

Export variables.

export DBNAME=django
export PGPASSWORD="sdksakdamsd"
export DATABASE_URL="postgis://localhost:5432/$DBNAME?user=gnadmin&password=$PGPASSWORD"
export GEOSERVER_DATA_DIR="/home/stack_sdi/geoserver/data"
export GEOSERVER_LOG_LOCATION="/home/stack_sdi/logs/gs.log"
export JAVA_HOME="/home/stack_sdi/geoserver/jdk1.8.0_251"
export DATA_DIR="/home/sdi/tomcat/webapps/geoserver/data"
export STATIC_ROOT="/home/stack_sdi/www/geonode/static"
export CATALINA_OPTS="-Xms2g -Xmx2g -Duser.timezone=UTC"

POSTGRES

  • Generate postgres dumps for data and metadata dbs.
pg_dump -U gnadmin sdi_django --no-privileges --no-owner > /home/stack_sdi/sdi_django.sql

Create databases

psql -U gnadmin -d postgres

create database django;
  • Store dump into example database
psql -U gnadmin -d $DBNAME < /home/stack_sdi/sdi_django.sql

GEOSERVER

INSTALLATION

  • Get JDK
wget -c --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u251-b08/3d5a2bb8f8d4428bbe94aed7ec7ae784/jdk-8u251-linux-x64.tar.gz
  • Unzip file
tar -xvf jdk-8u251-linux-x64.tar.gz
  • Download apache tomcat
wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.37/bin/apache-tomcat-9.0.37.tar.gz
  • Download geoserver war
wget --no-check-certificate --progress=bar:force:noscroll https://build.geo-solutions.it/geonode/geoserver/latest/geoserver-2.15.2.war
  • Unzip data.
unzip -q geoserver-2.15.2.war -d apache-tomcat-9.0.37/webapps/geoserver

CONFIGURATION

  • Modify /home/stack_sdi/geoserver/apache-tomcat-9.0.37/conf/server.xml to set Connector port (9095).
vim /home/stack_sdi/geoserver/apache-tomcat-9.0.37/conf/server.xml
  • Create data directory
cp -r /home/stack_sdi/geoserver/apache-tomcat-9.0.37/webapps/geoserver/data $GEOSERVER_DATA_DIR
  • Configure oauth variables
vim $GEOSERVER_DATA_DIR/security/filter/geonode-oauth2/config.xml

https://geonode.wfp.org/o/token/ https://geonode.wfp.org/o/authorize/ https://geonode.wfp.org/geoserver/index.html https://geonode.wfp.org/api/o/v4/tokeninfo/ https://geonode.wfp.org/account/logout/

vim $GEOSERVER_DATA_DIR/security/role/geonode\ REST\ role\ service/config.xml

https://geonode.wfp.org/

vim $GEOSERVER_DATA_DIR/global.xml

https://geonode.wfp.org/geoserver

  • Copy from old directory

cp -r $DATA_DIR/workspaces $GEOSERVER_DATA_DIR cp -r $DATA_DIR/styles $GEOSERVER_DATA_DIR/ cp -r $DATA_DIR/gwc-layers $GEOSERVER_DATA_DIR

  • Remember to modify the databases credentials for each datastore file.

  • Add Geofence security policy to read layers from authenticated roles.

DJANGO

INSTALLATION

  • Create virtualenv
virtualenv --no-site-packages --python=/usr/bin/python2.7 ./env
  • Clone Geonode project
git clone https://github.com/GeoNode/geonode.git
  • Install requirements
cd geonode
git checkout 2.10.1
pip install -r requirements.txt
pip install GDAL==1.9.1 pip==9.0.0
pip install -e .
pip install psycopg2==2.7.7
pip install jsonfield==2.1.1
pip install lxml==3.2.5
  • Clone wfp Geonode project
git clone ssh://[email protected]:7999/geonode/wfp-geonode.git
  • Run migrations
source /home/stack_sdi/django/env/bin/activate
cd /home/stack_sdi/django/wfp-geonode

python manage.py makemigrations
python manage.py migrate --fake-initial
paver sync

cd /home/stack_sdi/django/geonode

CONFIGURATION

  • Copy static maps and uploaded files.
cp -r /home/sdi/www/uploaded /home/stack_sdi/www
  • Update remote layers.
update layers_layer set remote_service_id=services_service.resourcebase_ptr_id from services_service where store=services_service.name;
  • Fix migrations for upload application:
delete from django_migrations where app = 'upload';
drop table upload_upload cascade;
drop table upload_uploadfile;
./manage.py migrate upload
  • Remove not null constraint for user registration.
ALTER TABLE people_profile ALTER COLUMN last_login DROP NOT NULL;
  • Collectstatic files.
python /home/stack_sdi/django/wfp-geonode/manage.py collectstatic --no-input

Fix groups information.

As admin, modify manually within the application and include name and description

  • Add social application.

  • Run tags migration script

python fixes_tags.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment