Sophie

Sophie

distrib > Mandriva > 2007.0 > x86_64 > media > contrib-release > by-pkgid > 4eabba4cce86aded081eef2f0a84cf50 > scriptlet

bacula-dir-1.38.11-3mdv2007.0.x86_64.rpm

PREIN

/bin/sh
/usr/bin/perl -e '
$confdir="/etc/bacula";
$conffile="$confdir/.pw.sed";
if ( -f "$conffile") {
	open(IN, "<$conffile") or die "$!";
	while (<IN>) {
		/#YOU MUST SET THE (.*) PASSWORD#/ && $already{$1}++;
	}
	close(IN);
}
mkdir("$confdir");
umask(0077);
open(IN, "/dev/random") or die "$!";
open(OUT, ">>$conffile") or die "$!";
foreach $c ("DIR","SD","FD","MONITOR DIR","MONITOR SD","MONITOR FD") {
next if ($already{$c});
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/lib64/bacula/grant_bacula_privileges > dev/null
	/usr/lib64/bacula/create_bacula_database > dev/null
	/usr/lib64/bacula/make_bacula_tables > dev/null
elif [ "$DB_VER" -lt "9" ]; then
	echo "Backing up bacula tables"
	echo ".dump" | sqlite /var/lib/bacula/bacula.db | bzip2 > /var/lib/bacula/bacula_backup.sql.bz2
	echo "Upgrading bacula tables"
	if [ "$DB_VER" -lt "4" ]; then
		echo "your bacula database version is too old to be upgraded automatically"
	elif [ "$DB_VER" -lt "8" ]; then
		if [ "$DB_VER" -lt "7" ]; then
			if [ "$DB_VER" -lt "6" ]; then
				if [ "$DB_VER" -lt "5" ]; then
					/usr/lib64/bacula/update_sqlite_tables_4_to_5
				fi
				/usr/lib64/bacula/update_sqlite_tables_5_to_6
			fi
			/usr/lib64/bacula/update_sqlite_tables_6_to_7
		fi
		/usr/lib64/bacula/update_sqlite_tables_7_to_8
	fi
	/usr/lib64/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