From a8c22829d8e8845cd4ddf4ef8b61a1ed79edfffc Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Mon, 12 Mar 2018 22:57:42 +0100 Subject: Imported from the SVN repository http://svn.wolffelaar.nl/wsvn/phpbb/branches/jessie/ Signed-off-by: Olivier Gayot --- debian/dbapps-lib | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 debian/dbapps-lib (limited to 'debian/dbapps-lib') diff --git a/debian/dbapps-lib b/debian/dbapps-lib new file mode 100644 index 0000000..16aba10 --- /dev/null +++ b/debian/dbapps-lib @@ -0,0 +1,101 @@ +# some library functions for phpbb3 maintainer scripts +# copyright 2010 J.M. Roth + +run_sql () { + if [ -f /etc/dbconfig-common/phpbb3.conf ] ; then + . /etc/dbconfig-common/phpbb3.conf + else + echo "$0 $@: run_sql: cannot load db metadata" 1>&2 + return 1 + fi + + local sql="$1" + + ERR= + case $dbc_dbtype in + mysql ) + l_dbc_dbserver=${dbc_dbserver:- localhost} + echo $sql | mysql -h ${l_dbc_dbserver} ${dbc_dbport:+--port $dbc_dbport} -u $dbc_dbuser -p$dbc_dbpass $dbc_dbname -s || run_sql_fail $dbc_dbtype + ;; + pgsql ) + if [ -z "${dbc_dbserver}" ]; then + echo $sql | su - postgres -c "psql ${dbc_dbport:+-p $dbc_dbport} -d \"dbname=$dbc_dbname ${dbc_ssl:+sslmode=require}\" -q" || run_sql_fail $dbc_dbtype + else + echo $sql | psql -h $dbc_dbserver ${dbc_dbport:+-p $dbc_dbport} -d \"dbname=$dbc_dbname ${dbc_ssl:+sslmode=require}\" -q || run_sql_fail $dbc_dbtype + fi + ;; + sqlite ) + echo $sql | sqlite $dbc_basepath/$dbc_dbname || run_sql_fail $dbc_dbtype + ;; + * ) + echo "run_sql: $dbc_dbtype not supported" >&2 + ;; + esac + + return 0 +} + +run_sql_fail () { + echo "run_sql $@ fail" >&2 + ERR=fail +} + +postgres_update_seqs () { +# repair pgsql sequences, this has always been a source of trouble +# on prepopulated DBs + if db_get phpbb3/dbconfig-install && [ "$RET" = "true" ] ; then + db_get phpbb3/database-type + if [ "$RET" = "pgsql" ]; then + db_get phpbb3/db/dbname + local dbname="$RET" + db_get phpbb3/remote/host + local dbhost="$RET" + db_get phpbb3/remote/port + local dbport="$RET" + if [ -z "${dbc_dbserver}" ]; then + /usr/share/phpbb3/postgres_update_seqs.sh /usr/share/dbconfig-common/data/phpbb3/install/pgsql | su - postgres -c "psql ${dbhost:+-h $dbhost} ${dbport:+-p $dbport} -d $dbname -q >/dev/null" + else + /usr/share/phpbb3/postgres_update_seqs.sh /usr/share/dbconfig-common/data/phpbb3/install/pgsql | psql ${dbhost:+-h $dbhost} ${dbport:+-p $dbport} -d $dbname -q >/dev/null + fi + fi + fi +} + +_md5 () { + echo -n $1 | md5sum | cut -c-32 +} + +dc_true () { + db_get $1 + [ "$RET" = "true" ] + return $? +} + +dc_forget () { + db_reset $1 + db_fset $1 seen false +} + +dc_get () { + db_get $1 + echo -n $RET +} + +dc_copy () { + db_set $2 "$(dc_get $1)" +} + +dc_out () { + db_get $1 + echo $1: $RET # -- "$(debconf-show phpbb3 | grep $1)" +} + +dc_dbg () { + [ "$PB3DEBUG" != "maint" ] && return + set +e + echo $0:$LINENO $@ + for d in install upgrade reinstall remove; do + db_get phpbb3/dbconfig-$d && echo [dbc] phpbb3/dbconfig-$d "$RET" + done + set -e +} -- cgit v1.2.3