Last active
December 4, 2019 19:56
-
-
Save gyfoster/18ae14306e6c3690e2d4ac6add19a299 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################## | |
# Based on https://medium.com/@dale.bingham_30375/setup-geoserver-for-a-local-gis-application-like-cesiumjs-14322f1178d5 | |
################################## | |
# Exit when any command fails | |
set -e | |
# Check if being run as root | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" | |
exit 1 | |
fi | |
echo_heading () { | |
LRED='\033[1;31m' # Light red | |
NC='\033[0m' # No Color | |
echo -e "${LRED}$1${NC}" | |
} | |
USER_NAME="geoserveracct" | |
SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd -P )" | |
BASE_DIR="/home/$USER_NAME" | |
echo_heading "Creating user $USER_NAME if doesn't exist..." | |
id -u $USER_NAME &>/dev/null || useradd -m $USER_NAME | |
id -u $USER_NAME &>/dev/null || passwd $USER_NAME | |
echo_heading "Installing PostgreSQL dependencies..." | |
apt -y install postgresql postgresql-contrib postgis postgresql-10-postgis-2.4 postgresql-10-postgis-scripts | |
echo_heading "Installing osm2pgsql dependencies..." | |
apt -y install make cmake g++ libboost-dev libboost-system-dev libboost-filesystem-dev libexpat1-dev zlib1g-dev \ | |
libbz2-dev libpq-dev libgeos-dev libgeos++-dev libproj-dev lua5.2 liblua5.2-dev | |
echo_heading "Installing Java (JDK)..." | |
apt -y install default-jdk | |
echo_heading "Installing osm2pgsql (allows Postgres to store OSM data)..." | |
mkdir $BASE_DIR/src | |
cd $BASE_DIR/src | |
tar xzvf $SCRIPT_DIR/osm2pgsql.tar.gz -C $BASE_DIR/src | |
cd osm2pgsql/ | |
mkdir build && cd build | |
cmake .. | |
make | |
sudo make install | |
echo_heading "Installing GeoServer..." | |
unzip $SCRIPT_DIR/geoserver-2.16.1-bin.zip -d /usr/share | |
echo "export GEOSERVER_HOME=/usr/share/geoserver-2.16.1" >> ~/.profile | |
. ~/.profile | |
sudo chown -R $USER_NAME /usr/share/geoserver-2.16.1/ | |
echo_heading "Initializng PostgreSQL database..." | |
sudo -u postgres createdb floridamaps | |
sudo -u postgres psql floridamaps -c "CREATE EXTENSION postgis" | |
sudo -u postgres psql floridamaps -c "CREATE EXTENSION postgis_topology" | |
sudo -u postgres psql floridamaps -c "CREATE EXTENSION hstore" | |
echo_heading "Loading data..." | |
cd $SCRIPT_DIR | |
mkdir /usr/share/geoserver-2.16.1/data_dir/data/worldmap | |
unzip NE1_50M_SR_W.zip -d /usr/share/geoserver-2.16.1/data_dir/data/worldmap/ | |
bunzip2 florida-latest.osm.bz2 | |
chmod 777 florida-latest.osm | |
#sudo -u postgres osm2pgsql -C 2048 -d floridamaps ./florida-latest.osm -C 2048 --slim --number-processes 2 | |
osm2pgsql -C 2048 -s -d gis ./florida-latest.osm -C 2048 --slim --number-processes 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment