#! /bin/bash while [[ $# -gt 0 ]] do key="$1" case $key in --skip-install) skip_install=1 shift # past argument ;; --skip-git) skip_git=1 shift # past argument ;; --skip-sql) skip_sql=1 shift # past argument ;; -h|--help) echo "usage: install [OPTIONS]..." echo "Installs all needed packages and clones the osm2city and osm2city-data repository" echo "" echo "OPTIONS:" echo " -h, --help Shows this help and exits" echo " --skip-install Skips install of packages and continues with setup" echo " --skip-git Skips git clones of the osm2city and osm2city-data repository" echo " --skip-sql Skips setup of the sql user" exit ;; *) echo "Unknow option $key" exit 1 ;; esac done if [ "$skip_install" != 1 ]; then which apt-get > /dev/null if [ $? == 1 ]; then echo "Currently apt is the only supported package manager but it seems that apt isn't installed." echo "Please install the following packages manually" echo "python3-venv" echo "python-pip" echo "postgresql" echo "postgresql-postgis" echo "postgresql-client" echo "postgresql-contrib" echo "pgadmin3" echo "postgis" echo "python3-psycopg2" echo "osmosis" echo "git" echo "Then rerun this script with skip-install argument" echo "./install --skip-install" exit 1 fi sudo apt-get install -y git osmosis postgis pgadmin3 postgresql-contrib postgresql-client postgresql-postgis postgresql python-pip python3-venv if [ $? == 100 ]; then echo "apt-get had problems installing some packages" echo "Please make sure that all of the following packages are installed" echo "python3-venv" echo "python-pip" echo "postgresql" echo "postgresql-postgis" echo "postgresql-client" echo "postgresql-contrib" echo "pgadmin3" echo "postgis" echo "python3-psycopg2" echo "osmosis" echo "git" echo "Then rerun this script with skip-install argument" echo "./install --skip-install" exit 1 fi fi if [ "$skip_git" != 1 ]; then which git > /dev/null if [ $? == 1 ]; then echo "Unable to find git. Please manually download the following two repositories:" echo "https://gitlab.com/fg-radi/osm2city" echo "https://gitlab.com/fg-radi/osm2city-data" echo "Unzip them in this directory and make sure, the are named osm2city and osm2city-data" exit 1 fi git clone https://gitlab.com/fg-radi/osm2city.git git clone https://gitlab.com/fg-radi/osm2city-data.git fi if [ "$skip_sql" != 1 ]; then echo "Do you want to create a database user[y/n]? " read ret if [ "$ret" == "y" ]; then echo "Please enter the username: " read db_user echo "Please enter a password: " read db_passwd sudo -u postgres psql -c "CREATE USER $db_user WITH PASSWORD '$db_passwd';" echo "db_user=$db_user" >> general-settings echo "db_passwd=$db_passwd" >> general-settings fi fi if [ ! -f general-settings ]; then echo "# This file must be used with "source general-settings" *from bash*" > general-settings echo "# you cannot run it directly" >> general-settings echo "" >> general-settings fi # check if the threads value is already in the general-settings cat general-settings|grep ^threads > /dev/null if [ $? == 1 ]; then echo "What is the default number of threads you want to use for scenery generation?" read threads echo "threads=$threads" >> general-settings fi # check if the FG_ROOT value is already in the general-settings cat general-settings|grep ^FG_ROOT > /dev/null if [ $? == 1 ]; then echo "Please give the full path to the fgdata directory" read fg_root echo "FG_ROOT=$fg_root" >> general-settings echo "export \$FG_ROOT" >> general-settings fi # check if the PYTHONPATH value is already in the general-settings cat general-settings|grep ^PYTHONPATH > /dev/null if [ $? == 1 ]; then echo "PYTHONPATH=$(pwd)/osm2city" >> general-settings echo "export \$PYTHONPATH" >> general-settings fi # Create directory for .pbf files mkdir -p pbf mkdir -p projects