1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-24 22:50:49 +00:00
nixpkgs/pkgs/development/libraries/postgis/pg_db_postgis_enable.sh

39 lines
581 B
Bash
Raw Normal View History

#!/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