PREIN
/bin/sh
/usr/bin/perl -e '
exit 0 if ( -f "/etc/bacula/.pw.sed");
mkdir("/etc/bacula");
umask(0077);
open(IN, "/dev/random") or die "$!";
open(OUT, ">/etc/bacula/.pw.sed") or die "$!";
foreach $c ("DIR","SD","FD") {
read(IN, $buf, 32);
my $res = pack("u", $buf);
$res =~ s/^.//mg;
$res =~ s/\n//g;
$res =~ tr|` -_|AA-Za-z0-9+/|;
print OUT "s!#YOU MUST SET THE $c PASSWORD#!\"$res\"!\n";
}
close (IN);
close (OUT);
'
PREUN
/bin/sh
/usr/share/rpm-helper/del-service bacula $1 bacula-dir
POSTIN
/bin/sh
umask 077
[ -s /var/lib/bacula/bacula.db ] && \
DB_VER=`echo "select * from Version;" | \
sqlite /var/lib/bacula/bacula.db | tail -n 1 2>/dev/null`
if [ -z "$DB_VER" ]; then
# grant privileges and create tables
/usr/lib/bacula/grant_bacula_privileges > dev/null
/usr/lib/bacula/create_bacula_database > dev/null
/usr/lib/bacula/make_bacula_tables > dev/null
elif [ "$DB_VER" -lt "8" ]; then
echo "Backing up bacula tables"
echo ".dump" | sqlite /var/lib/bacula/bacula.db | bzip2 > /var/lib/bacula/bacula_backup.sql.bz2
type=sqlite
echo "Upgrading bacula tables"
if [ "$DB_VER" -lt "7" ]; then
if [ "$DB_VER" -lt "6" ]; then
if [ "$DB_VER" -lt "5" ]; then
/usr/lib/bacula/update_${type}_tables_4_to_5
fi
/usr/lib/bacula/update_${type}_tables_5_to_6
fi
/usr/lib/bacula/update_${type}_tables_6_to_7
fi
/usr/lib/bacula/update_bacula_tables
echo "If bacula works correctly you can remove the backup file /var/lib/bacula/bacula_backup.sql.bz2"
fi
chown -R bacula:bacula /var/lib/bacula
chmod -R u+rX,go-rwx /var/lib/bacula
umask 0037; if [ -s /etc/bacula/.pw.sed ]; then for i in /etc/bacula/*.conf /etc/bacula/*.conf.rpmnew; do if [ -s $i ]; then sed -f /etc/bacula/.pw.sed $i > $i.tmp; sed -e '/SubSys[[:space:]]*Directory/I d' $i.tmp > $i; rm -f $i.tmp; fi; done; fi;/usr/share/rpm-helper/add-service bacula $1 bacula-dir