Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > contrib-release > by-pkgid > 704357e1df5ddba27ebc72fccbf41e23 > scriptlet

bacula-dir-pgsql-2.2.8-6mdv2008.1.x86_64.rpm

POSTIN

/bin/sh
umask 077
for f in create_postgresql_database drop_postgresql_database drop_postgresql_tables \
    grant_postgresql_privileges make_postgresql_tables update_postgresql_tables ; do
    ln -snf $f /usr/lib64/bacula/${f/postgresql/bacula}
done
ln -snf bacula-dir-postgresql /usr/sbin/bacula-dir
ln -snf bscan-postgresql /usr/sbin/bscan
ln -snf dbcheck-postgresql /usr/sbin/dbcheck
# NOTE: IF THIS FAILS DUE TO MYSQL/PGSQL NEEDING A PASSWORD YOU ARE ON YOUR OWN
DB_VER=`psql bacula -c 'select * from Version;' | tail -n 1 2>/dev/null`
if [ -z "$DB_VER" ]; then
	echo cannot connect to bacula catalog database
	echo if this is the first bacula installation please check
	echo and run the following scripts
	echo 	/usr/lib64/bacula/grant_bacula_privileges
	echo 	/usr/lib64/bacula/create_bacula_database
	echo 	/usr/lib64/bacula/make_bacula_tables
	echo else manually update the database to version 10 using the script
	echo 	/usr/lib64/bacula/update_bacula_tables
elif [ "$DB_VER" -lt "10" ]; then
	echo "Backing up bacula tables"
	pg_dump bacula | bzip2 > /var/lib/bacula/bacula_backup.sql.bz2
	echo "Upgrading bacula tables"
	if [ "$DB_VER" -lt "7" ]; then
		echo "your bacula database version is too old to be upgraded automatically"
	else
	    for v in `seq 8 $((10 - 1))`; do
		if [ "$DB_VER" -lt "$v" ]; then
			/usr/lib64/bacula/update_postgresql_tables_$((v - 1))_to_$v
		fi
	    done
	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