POSTIN
/bin/sh
umask 077
for f in create_mysql_database drop_mysql_database drop_mysql_tables \
grant_mysql_privileges make_mysql_tables update_mysql_tables ; do
ln -snf $f /usr/lib/bacula/${f/mysql/bacula}
done
ln -snf bacula-dir-mysql /usr/sbin/bacula-dir
ln -snf bscan-mysql /usr/sbin/bscan
ln -snf dbcheck-mysql /usr/sbin/dbcheck
# NOTE: IF THIS FAILS DUE TO MYSQL/PGSQL NEEDING A PASSWORD YOU ARE ON YOUR OWN
DB_VER=`mysql bacula -e '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/lib/bacula/grant_bacula_privileges
echo /usr/lib/bacula/create_bacula_database
echo /usr/lib/bacula/make_bacula_tables
echo else manually update the database to version 10 using the script
echo /usr/lib/bacula/update_bacula_tables
elif [ "$DB_VER" -lt "10" ]; then
echo "Backing up bacula tables"
mysqldump -f --opt bacula | 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"
else
for v in `seq 5 $((10 - 1))`; do
if [ "$DB_VER" -lt "$v" ]; then
/usr/lib/bacula/update_mysql_tables_$((v - 1))_to_$v
fi
done
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