postinst is in rt3.8-rtfm 2.4.3-1.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | #!/bin/sh
set -e
etcdir=/usr/share/rt3.8-rtfm/etc
upgrade_database ()
{
echo "upgrading the RT database for RTFM 2.2" 1>&2
for dir in $etcdir/upgrade/*
do
for action in schema acl
do
run_setup_database $action $dir
done
done
echo -n "migrating the database contents..." 1>&2
# run the migration script through a logging wrapper
# that sends the output into the RT log as well
run_command "/usr/share/rt3.8-rtfm/sbin/rt-wrapper-debian \
/usr/share/rt3.8-rtfm/sbin/migrate-2.0-to-2.1"
echo "Database upgrade done, see the RT (sys)log for details" 1>&2
}
setup_database ()
{
echo "setting up the RT database for RTFM" 1>&2
for action in schema acl
do
run_setup_database $action $etcdir
done
echo "Database setup done, see the RT (sys)log for details" 1>&2
}
run_setup_database ()
{
action=$1
datadir=$2
command="/usr/share/rt3.8-rtfm/sbin/rt-setup-database-debian -v 3.8 -- --action $action --datadir $datadir"
# cosmetics for the output
base=$(basename $datadir)
if [ "$base" = "etc" ]
then
base=rtfm
fi
echo -n "updating database $action for $base..." 1>&2
run_command "$command"
}
run_command ()
{
command="$1"
local exitcode
set +e
output=$($command 2>&1 >/dev/null)
exitcode=$?
set -e
if [ $exitcode != 0 ] || [ -n "$output" ]
then
echo "command failed with code $exitcode" 1>&2
db_capb escape
error=$(debconf-escape -e << EOF
database modification command "$command" exited with code $exitcode
Error messages follow:
$output
EOF
)
db_subst rt3.8-rtfm/modify-database-error error "$error"
db_fset rt3.8-rtfm/modify-database-error seen false
db_input critical rt3.8-rtfm/modify-database-error || true
db_go || true
db_get rt3.8-rtfm/modify-database-error
ERROR_CHOICE="$RET"
if [ "$ERROR_CHOICE" = "abort" ]
then
echo "postinst script aborted" 1>&2
exit 1
fi
if [ "$ERROR_CHOICE" = "retry" ]
then
echo "postinst script: retry to set up the database $action" 1>&2
run_command $@
fi
else
echo "OK" 1>&2
fi
}
test_database ()
{
local testresult
testresult=0
permission="$1"
/usr/share/rt3.8-rtfm/sbin/test-database 2>/dev/null 1>&2 || testresult=$?
set -e
if [ "$permission" = "prompt" ] && \
( [ $testresult = 1 ] || [ $testresult = 2 ] )
then
case $testresult in
1)
db_fset rt3.8-rtfm/setup-database-prompt seen false
db_input high rt3.8-rtfm/setup-database-prompt || true
db_go
db_get rt3.8-rtfm/setup-database-prompt
break
;;
2)
db_fset rt3.8-rtfm/upgrade-database-prompt seen false
db_input high rt3.8-rtfm/upgrade-database-prompt || true
db_go
db_get rt3.8-rtfm/upgrade-database-prompt
break
;;
esac
if [ "$RET" = "false" ]
then
echo "database modification denied by the administrator" 1>&2
return 0
fi
fi
if [ $testresult = 255 ]
then
echo "Database state check failed, skipping modifications. Check your RT_SiteConfig.pm." 1>&2
fi
return $testresult
}
clean_mason_cache ()
{
find /var/cache/request-tracker3.8/mason_data \
-type f -path '*RTFM*' -print0 |xargs -r0 rm -f
}
. /usr/share/debconf/confmodule
db_version 2.0
case "$1" in
configure|reconfigure)
db_get rt3.8-rtfm/modify-database-permission
CONFFILE=/etc/rt3.8-rtfm/debian.conf
MODIFY_DATABASE="unknown"
if [ -r $CONFFILE ]
then
. $CONFFILE
fi
if [ "$RET" != "$MODIFY_DATABASE" ]
then
# rewrite the configuration file
tmpfile=$(mktemp -t rt3.8-rtfm.XXXXXXXX) || exit 1
chmod 644 $tmpfile
cat >$tmpfile << EOF
# automatically modify the database when needed?
# valid options are "allow", "deny" and "prompt"
MODIFY_DATABASE="${RET}"
EOF
ucf --debconf-ok $tmpfile $CONFFILE
rm $tmpfile
fi
if [ "$RET" != "deny" ]
then
retcode=0
test_database $RET || retcode=$?
case $retcode in
1)
setup_database
;;
2)
upgrade_database
;;
esac
fi
db_stop
# add the configuration file into the ucf registry
if which ucfr >/dev/null 2>&1
then
ucfr rt3.8-rtfm $CONFFILE
fi
break
;;
esac
clean_mason_cache
|