blob: 16aba10aa7a377684a767f33366063b67bf5d494 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# some library functions for phpbb3 maintainer scripts
# copyright 2010 J.M. Roth <jmroth@iip.lu>
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
}
|