Skip to content

Instantly share code, notes, and snippets.

@darmawan01
Last active March 26, 2023 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darmawan01/ac1409854330f8f1d6c7db7b3cae80cd to your computer and use it in GitHub Desktop.
Save darmawan01/ac1409854330f8f1d6c7db7b3cae80cd to your computer and use it in GitHub Desktop.
Dhis2 Notes

setenv.sh configuration

#!/bin/sh
#
CATALINA_HOME=/usr/share/tomcat9
export JAVA_HOME='/usr/lib/jvm/java-11-openjdk-amd64'
export JAVA_OPTS='-Xmx8000m -Xms4192m'
export DHIS2_HOME='/home/dhis/config'

# Find the Java runtime and set JAVA_HOME
. /usr/libexec/tomcat9/tomcat-locate-java.sh
# Default Java options
if [ -z "$JAVA_OPTS" ]; then
   JAVA_OPTS="-Djava.awt.headless=true"
fi

Dhis2 tools

#!/bin/bash

DHIS_DIR="/home/dhis" 
DHIS_CONFIG="config" 
TOMCAT_DHIS="tomcat-dhis" 

clear

echo ""
echo "*** Dhis tools ***"
echo "[ ] Dhis config path $DHIS_DIR/$DHIS_CONFIG"
echo "[ ] Tomcat dhis path $DHIS_DIR/$TOMCAT_DHIS"

dhis_start () {
  sudo bash $DHIS_DIR/$TOMCAT_DHIS/bin/startup.sh
}

dhis_stop () {
  sudo bash $DHIS_DIR/$TOMCAT_DHIS/bin/shutdown.sh
}

dhis_log () {
  sudo tail -f $DHIS_DIR/$TOMCAT_DHIS/logs/catalina.out
}

setup_login () {
  SOURCE=$1
  
  if [ ! -d "$SOURCE/css" ]; then
     echo "[x] css asset not provided, is required."
     exit 1
  fi

  if [ ! -d "$SOURCE/security" ]; then
     echo "[x] security asset not provided, is required."i
     exit 1
  fi
  
  dhis_stop
  set -e
  set -x
  sudo rm -rf $DHIS_DIR/$TOMCAT_DHIS/webapps/ROOT/dhis-web-commons/css
  sudo rm -rf $DHIS_DIR/$TOMCAT_DHIS/webapps/ROOT/dhis-web-commons/security
  sudo cp -rf $SOUCRCE/css $DHIS_DIR/$TOMCAT_DHIS/webapps/ROOT/dhis-web-commons/css
  sudo cp -rf $SOUCRCE/security $DHIS_DIR/$TOMCAT_DHIS/webapps/ROOT/dhis-web-commons/security
  sleep 3
  dhis start
}

dhis_nginx () {
  sudo systemctl $1 nginx
}

case $1 in
    start)
      echo "[ ] Starting dhis . . ."
      dhis_start
    ;;
    stop)
      echo "[ ] Stoping dhis . . ."
      dhis_stop
    ;;
    log)
      echo "[ ] Dhis log . . ."
      dhis_log
    ;;
    setuplogin)
      echo "[ ] Setup dhis login page . . ."
      setup_login $2
    ;;
    nginx)
      echo "[ ] Nginx $2"
      dhis_nginx $2
    ;;
    *)
      echo "[x] Invalid command"
    ;;
esac

@darmawan01
Copy link
Author

Postgres:

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee  /etc/apt/sources.list.d/pgdg.list
sudo apt-get install postgresql-13 postgresql-contrib-13
sudo apt install postgresql-13-postgis-2.5

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