1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-27 16:11:58 +00:00
nixpkgs/pkgs/development/libraries/postgis/pg_db_postgis_enable.sh
Marc Weber bddb72ec8a psotgis:
- support older versions (which are used by other distributions)
- give utilyt scripts nicer names
- pg_db_postgis_enable: support loading comments

svn path=/nixpkgs/trunk/; revision=21992
2010-05-26 19:01:10 +00:00

39 lines
581 B
Bash

#!/bin/sh
sql_files=(@sql_srcs@)
sql_comments=@sql_comments@
do_help(){ echo "$0 [--comments] db_name1 [db_name2 ..]"; }
for arg in "$@"; do
case "$arg" in
-h|--help)
do_help; exit 0
;;
--comments)
LOAD_COMMENTS=1
;;
*)
dbs=(${dbs[@]} "$arg")
;;
esac
done
PSQL(){
echo ">> loading $1"
psql -d "$db" -f $1
}
for db in ${dbs[@]}; do
createlang plpgsql "$db"
# mandatory
for sql in $sql_files; do
PSQL $sql
done
# optionally load some comments
if [ -n "$LOAD_COMMENTS" ]; then
PSQL $sql_comments
fi
done