2018-11-13 15:31:53 +00:00
|
|
|
#! /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
|
2018-11-13 17:34:12 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
--skip-sql)
|
|
|
|
skip_sql=1
|
|
|
|
shift # past argument
|
2018-11-13 15:31:53 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
-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"
|
2018-11-13 17:34:12 +00:00
|
|
|
echo " --skip-sql Skips setup of the sql user"
|
2018-11-13 15:31:53 +00:00
|
|
|
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"
|
2018-11-13 16:30:30 +00:00
|
|
|
echo "postgresql"
|
|
|
|
echo "postgresql-postgis"
|
|
|
|
echo "postgresql-client"
|
|
|
|
echo "postgresql-contrib"
|
2018-11-13 15:31:53 +00:00
|
|
|
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
|
2018-11-13 16:30:30 +00:00
|
|
|
sudo apt-get install -y git osmosis postgis pgadmin3 postgresql-contrib postgresql-client postgresql-postgis postgresql python-pip python3-venv
|
2018-11-13 16:20:52 +00:00
|
|
|
if [ $? == 100 ]; then
|
2018-11-13 16:18:45 +00:00
|
|
|
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"
|
2018-11-13 16:30:30 +00:00
|
|
|
echo "postgresql"
|
|
|
|
echo "postgresql-postgis"
|
|
|
|
echo "postgresql-client"
|
|
|
|
echo "postgresql-contrib"
|
2018-11-13 16:18:45 +00:00
|
|
|
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
|
2018-11-13 15:31:53 +00:00
|
|
|
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
|
|
|
|
|
2018-11-13 17:34:12 +00:00
|
|
|
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
|
|
|
|
|
2018-11-13 17:44:25 +00:00
|
|
|
# check if the fg_elev value is already in the general-settings
|
|
|
|
cat general-settings|grep ^fg_elev > /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
|
|
|
echo "Please give the full path to the fgelev executable"
|
|
|
|
read fg_elev
|
|
|
|
echo "fg_elev=$fg_elev" >> general-settings
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check if the fg_scenery value is already in the general-settings
|
|
|
|
cat general-settings|grep ^fg_scenery > /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
|
|
|
echo "Please give the full path to the flightgear scenery"
|
|
|
|
read fg_scenery
|
|
|
|
echo "fg_elev=$fg_scnery" >> general-settings
|
|
|
|
fi
|
|
|
|
|
2018-11-13 17:34:12 +00:00
|
|
|
# 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
|
|
|
|
|
2018-11-13 17:44:25 +00:00
|
|
|
# check if the db_host value is already in the general-settings
|
|
|
|
cat general-settings|grep ^db_host > /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
|
|
|
echo "db_host=localhost" >> general-settings
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check if the db_port value is already in the general-settings
|
|
|
|
cat general-settings|grep ^db_port > /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
|
|
|
echo "db_port=5432" >> general-settings
|
|
|
|
fi
|
|
|
|
|
2018-11-13 15:31:53 +00:00
|
|
|
# Create directory for .pbf files
|
2018-11-13 16:18:45 +00:00
|
|
|
mkdir -p pbf
|
2018-11-13 16:46:08 +00:00
|
|
|
mkdir -p projects
|