postinst is in bacula-director-sqlite3 5.2.5-0ubuntu6.
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 | #! /bin/bash
# postinst script for bacula-director-sqlite3
#
. /usr/share/debconf/confmodule
db_version 2.0
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
# quoting from the policy:
# Any necessary prompting should almost always be confined to the
# post-installation script, and should be protected with a conditional
# so that unnecessary prompting doesn't happen if a package's
# installation fails and the `postinst' is called with `abort-upgrade',
# `abort-remove' or `abort-deconfigure'.
dbc_first_version=3.0.3-3
dbc_dbfile_owner=bacula:bacula
# set in config, must not be set here: dbc_dbuser=bacula
# set in config, must not be set here: dbc_dbname=bacula.db
# set in config, must not be set here: dbc_basepath=/var/lib/bacula
# After squeeze, restore this test. This was needed for sqlite2 migration.
#if [ -n "$2" ]; then
/etc/init.d/bacula-director stop || true
sleep 1
#fi
#### REMOVE THIS CODE POST-SQUEEZE
CONVERTED_SQLITE2=NO
if [ "$1" = "configure" ] ; then
DB=/var/lib/bacula/bacula.db
echo -n " *** Checking type of existing DB at $DB: "
if [ -f "$DB" ]; then
if file "$DB" | grep -q "SQLite 2"; then
echo "SQLite v2"
echo " *** Converting SQLite2 database to SQLite3 format."
echo " *** This may take awhile. Please be patient..."
echo "Converting $DB to temporary location $DB.sqlite3"
sqlite "$DB" .dump \
| sed 's/ INTEGER UNSIGNED AUTOINCREMENT,/ INTEGER,/' \
| sqlite3 "$DB.sqlite3"
echo "SQLite conversion complete. Cleaning up:"
echo -n "Renaming: "
mv -v "$DB" "$DB.old-sqlite2"
echo -n "Renaming: "
mv -v "$DB.sqlite3" "$DB"
chown bacula:bacula "$DB"
echo " *** Conversion complete. Your sqlite v2 database was left in"
echo " *** $DB.old-sqlite2. You may delete it at your leisure."
echo " *** Continuing with upgrade process..."
CONVERTED_SQLITE2=YES
else
echo "SQLite v3"
fi
else
echo "None"
echo " *** Will create new database at this location."
fi
fi
#### END OF CODE TO REMOVE POST-SQUEEZE
# source dbconfig-common shell library, and call the hook function
if [ -f /usr/share/dbconfig-common/dpkg/config.sqlite3 ]; then
. /usr/share/dbconfig-common/dpkg/postinst.sqlite3
#### POST-SQUEEZE, REMOVE THE FOLLOWING LINES AND SIMPLY USE:
# dbc_go bacula-director-sqlite3 $@
if [ "$1" = "configure" -a "$CONVERTED_SQLITE2" = "YES" ]; then
# If we converted from Sqlite v2 in this run, then we have to
# pass a fake prior version number to dbc_go. Otherwise, it
# would think that this is a new sqlite3 install and not upgrade
# the database.
dbc_go bacula-director-sqlite3 configure 2.4.4-1
else
dbc_go bacula-director-sqlite3 $@
fi
fi
LOGDIR="/var/log/bacula"
POSTINST_COMMON="/usr/share/bacula-director/postinst-common"
DEFCONFIG="/usr/share/bacula-common/defconfig"
CFGFILE="/etc/bacula/bacula-dir.conf"
. /usr/share/bacula-common/common-functions
readOrCreatePasswords
case "$1" in
configure)
echo -n "Processing configuration..."
. /etc/dbconfig-common/bacula-director-sqlite3.conf
TARGET=$CFGFILE.dpkg-tmp
# FIXME: should this tweak make_catalog_backup like bacula-director-pgsql.postinst does?
BACULADBNAME=`echo "$dbc_dbname" | sed 's/.db$//'`
sed -e s~XXX_DIRPASSWORD_XXX~$DIRPASSWD~ \
-e s~XXX_MONDIRPASSWORD_XXX~$DIRMPASSWD~ \
-e s~XXX_SDPASSWORD_XXX~$SDPASSWD~ \
-e s~XXX_FDPASSWORD_XXX~$FDPASSWD~ \
-e "s~/XXX_DBNAME_XXX~/$BACULADBNAME~" \
-e "s~\"XXX_DBNAME_XXX~\"$BACULADBNAME~" \
-e s~XXX_DBUSER_XXX~~ \
-e s~XXX_DBPASSWORD_XXX~~ \
$DEFCONFIG/bacula-dir.conf > $TARGET
/bin/bash $POSTINST_COMMON
echo "Ok."
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# Do start daemon
db_stop
invoke-rc.d --quiet bacula-director start
exit 0
|