mirror of
https://github.com/YunoHost-Apps/noalyss_ynh.git
synced 2024-09-03 19:46:20 +02:00
3a905a4a87
Update files from sources with last update on noalyss.eu
42 lines
1.8 KiB
Bash
42 lines
1.8 KiB
Bash
#!/bin/bash
|
|
# Create script for exporting a new template
|
|
# DDB 2018-01-28
|
|
# under GPL license
|
|
#
|
|
|
|
export TEMPLATE=${DOMAIN}account_repository
|
|
|
|
pg_dump -O -U dany -s $TEMPLATE|grep -v "COMMENT ON SCHEMA public IS 'Standard public schema';" |sed "/^--/d" > schema.sql
|
|
sed -i -e "/COMMENT ON EXTENSION/d" schema.sql
|
|
sed -i -e "/CREATE EXTENSION/d" schema.sql
|
|
|
|
awk '/SEQUENCE/,/;/ { print $0;}' < schema.sql > sequence.sql
|
|
awk '/CREATE DOMAIN/,/;/ { print $0;}' < schema.sql > table.sql
|
|
awk '/CREATE TABLE/,/;/ { print $0;}' < schema.sql >> table.sql
|
|
awk '/CREATE VIEW/,/;/ { print $0;}' < schema.sql > view.sql
|
|
awk '/INDEX/,/;/ { print $0;}' < schema.sql > index.sql
|
|
(
|
|
echo " SET client_encoding = 'utf8';"
|
|
echo " SET check_function_bodies = false;"
|
|
echo " SET client_min_messages = warning;"
|
|
echo "SET search_path = public, pg_catalog;"
|
|
)> constraint.sql
|
|
|
|
|
|
awk '/ALTER TABLE/,/;/ { print $0;}' < schema.sql >> constraint.sql
|
|
awk '/CREATE TRIGGER/,/;/ { print $0;}' < schema.sql >> constraint.sql
|
|
awk '/COMMENT ON CONSTRAINT/,/;/ { print $0;}' < schema.sql >> constraint.sql
|
|
awk '/COMMENT ON TRIGGER/,/;/ { print $0;}' < schema.sql >> constraint.sql
|
|
|
|
# function in XML
|
|
## awk 'BEGIN{print "<PROCEDURES>";} /CREATE FUNCTION/,/\$\$;/ { if (/CREATE FUNCTION/) {print "<procedure>";} if (/\$\$;/) {print "</procedure>";} print $0;} END { print "</PROCEDURES>";}' < schema.sql
|
|
awk '/CREATE FUNCTION/,/\$\$;/ { print $0;}' < schema.sql > function.sql
|
|
awk '/COMMENT/,/;/ {print $0;}' < schema.sql > comment.sql
|
|
|
|
sed -i -e "/REVOKE /d" -e "/GRANT /d" -e "/ALTER TABLE.*/d" -e "/ADD CONSTRAINT/d" -e "/CREATE PROCEDURAL/d" -e "/CREATE TRIGGER/d" -e "/COMMENT ON CONSTRAINT/d" -e "/COMMENT ON TRIGGER/d" schema.sql
|
|
|
|
|
|
grep setval schema.sql >> sequence.sql
|
|
pg_dump -O -U dany --data-only --column-inserts -O ${TEMPLATE}|sed "/^--/d" | sed -e "/SET search_path/d" > data.sql
|
|
|
|
|