Skip to content

Instantly share code, notes, and snippets.

@zuckercode
Created October 23, 2012 21:01
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save zuckercode/3941528 to your computer and use it in GitHub Desktop.
Installer for opengeodb
#!/bin/bash
# - INSTALL instructions:
# mkdir /your/preferred/path/opengeodb
# cd /your/preferred/path/opengeodb
# - copy this script to install_opengeodb.sh
# - make script executable:
# chmod +x install_opengeodb.sh
# - edit you mysql credentials
#
# IMPORTANT:
# This script uses wget to retrieve requested files, verify that wget is installed on your system.
#
# before you start installing opengeodb you have to download:
# setup_innodb_geodb.sql from gist https://gist.github.com/3942251 in the same directory than this script
# or
# setup_myisam_geodb.sql from gist https://gist.github.com/3942244 in the same directory than this script
# and
# CREATE_ZIP_SQL from gist https://gist.github.com/3942008 as create_zip.sql in the same directory than this script
#
#
# start install process:
# ./install_opengeodb.sh
# edit your mysql credentials
DB=dbname
DB_USER=dbuser
DB_PASS=xxx
# do not touch
URL=http://fa-technik.adfc.de/code/opengeodb/
ALTER_SQL=opengeodb-end.sql
EXTRA_SQL=extra.sql
CREATE_ZIP_SQL=create_zip.sql
# CREATE_ZIP_SQL from gist https://gist.github.com/3942008
read -n1 -p "This script is installing the opengeodb schema and is importing lot of data. Do you really want to proceed? y|n " key
echo
case $key in
"Y" | "y") true ;;
"N" | "n") echo 'Installation aborted'; exit;;
*) exit; echo ' ' ;;
esac
read -p "Do you want to install a InnoDB or MyISAM driven opengeodb driven schema? [myisam] " engine
case "$engine" in
innodb) SCHEMA=setup_innodb_geodb.sql
echo "creating InnoDB opengeodb schema"
echo " "
;;
*) SCHEMA=setup_myisam_geodb.sql
echo "creating MyISAM opengeodb schema"
echo " "
;;
esac
mysql -u $DB_USER -p $DB_PASS $DB < $SCHEMA
read -p "Which country data do you want to import? (comma separated) [AT,BE,CH,DE,LI] " country
if [ "$country" == "" ]; then
country="AT,BE,CH,DE,LI"
fi
IFS=','
for sql in $country
do
echo "downloading $sql.sql"
wget $URL$sql.sql
echo "importing $sql data"
mysql -u $DB_USER -p $DB_PASS $DB < $sql.sql
done
echo "Downloading metadata, creating indices"
wget $URL$ALTER_SQL
echo "Inserting metadata, creating indices"
mysql -u $DB_USER -p $DB_PASS $DB < $ALTER_SQL
read -p "Do you want to install extra information (Höhenangaben, Kontinente, Daten mit Versionierung etc.)? y|n " extra
echo
case $extra in
"Y" | "y") echo "Downloading $EXTRA_SQL"
wget $URL$EXTRA_SQL
echo "Inserting extra informations"
mysql -u $DB_USER -p $DB_PASS $DB < $EXTRA_SQL
;;
*) echo "No extra data will be installed"
;;
esac
read -p "Do you want to install hierachy informations? y|n " location
echo
case $location in
"Y" | "y") echo "Downloading hierarchy data for selected countries"
for sql in $country
do
echo "Downloading ${sql}hier.sql"
wget $URL${sql}hier.sql
echo "Importing ${sql}hier data"
mysql -u $DB_USER -p $DB_PASS $DB < ${sql}hier.sql
done
;;
*) echo "No hierachy data will be installed"
;;
esac
read -p "Do you want to create a single zip table for better radius search? y|n " single
echo
case $single in
"Y" | "y") echo "Installing zip table"
mysql -u $DB_USER -p $DB_PASS $DB < $CREATE_ZIP_SQL
;;
*) echo "No zip table will be installed"
;;
esac
echo
echo "Installing opengeodb finished"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment