Sophie

Sophie

distrib > PLD > ac > amd64 > by-pkgid > c5e1ecb1b0f682722db7d914ee777b03 > scriptlet

bacula-dir-1.38.11-1.amd64.rpm

PREUN

/bin/sh
if [ "$1" = "0" ]; then
	{
if [ -f /var/lock/subsys/bacula-dir ]; then
/sbin/service bacula-dir stop 1>&2 || :;
fi };	/sbin/chkconfig --del bacula-dir
fi

POSTIN

/bin/sh
umask 077
[ -s /var/lib/bacula/bacula.db ] && \
	DB_VER=`echo "select * from Version;" | \
	/usr/bin/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
	type=sqlite
	echo "Upgrading bacula tables"
	if [ "$DB_VER" -lt "9" ]; then
		if [ "$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_${type}_tables_4_to_5
					fi
					/usr/lib64/bacula/update_${type}_tables_5_to_6
				fi
				/usr/lib64/bacula/update_${type}_tables_6_to_7
			fi
			/usr/lib64/bacula/update_${type}_tables_7_to_8
		fi
		/usr/lib64/bacula/update_${type}_tables_8_to_9
	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/*

echo "Updating Bacula passwords and names..."
cd /etc/bacula
for f in *-password ; do
	p=`cat $f`
	sed -i -e"s:#FAKE-$f#:$p:" *.conf *.conf.rpmnew 2>/dev/null || :
done
sed -i -e"s:--hostname--:`hostname`:" *.conf *.conf.rpmnew 2>/dev/null || :

/sbin/chkconfig --add bacula-dir
{
skip_auto_restart() {
[ -f /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm
[ -f /etc/sysconfig/bacula-dir ] && . /etc/sysconfig/bacula-dir
echo ${RPM_SKIP_AUTO_RESTART:-no}
};
if [ $(skip_auto_restart) = no ]; then
if [ -f /var/lock/subsys/bacula-dir ]; then
/sbin/service bacula-dir restart 1>&2 || :;
else
echo 'Run "/sbin/service bacula-dir start" to start Bacula Director daemon.'
fi
fi };