8 # Script for creating and loading database
12 echo Usage: ${0##*/} [options]
15 echo " " -h display this help message
16 echo " " -w load database with sample data
17 echo " " -g resets geographic informations \(geoip and geonames\)
18 echo " " -s be more silent \(show only warnings\)
25 args=`getopt -o hwgs -l help,withdata,geo,silent -- "$@"`
29 -h|--help) usage; exit 0 ;;
30 -w|--withdata) WITHDATA="1"; shift ;;
31 -g|--geo) GEODATA="1"; shift ;;
32 -s|--silent) SILENT="1"; shift ;;
34 *) echo "Invalid option: $1"; exit 1 ;;
38 if [ ${#SILENT} -ne 0 ]; then
39 # we won't see all the index creation notices when creating tables
40 export PGOPTIONS='--client_min_messages=warning'
44 psql --set "ON_ERROR_STOP=1" -f ${0%/*}/schema.postgres.sql
46 # optionally load sample data
47 if [ ${#WITHDATA} -ne 0 ]; then
48 psql --set "ON_ERROR_STOP=1" -f ${0%/*}/data.postgres.sql
51 if [ ${#GEODATA} -ne 0 ]; then
52 sh ${0%/*}/updategeoip.sh "${@}"
53 sh ${0%/*}/updategeonames.sh "${@}"