Skip to content

Commit

Permalink
Rework database scripting.
Browse files Browse the repository at this point in the history
Having the actual DDL (Data Definition Language) in scripts is not very
flexible so we move all DDL into seperate files. We also dropped all
database specific scripting and as such the generic script now knows
for all supported database types what to do on create/update/grant and
drop.

You can also have a read-only user on your database that is allowed
to select stuff but not anything else that might be interesting for
Management Queries.

The update script now can also upgrade from a database that is several
versions old. For now that means you can upgrade from a Bacula database
to the first Bareos database schema and also to the new Database schema
we are introducing with this patch. For the future it means the script
will perform all needed updates for you if its has the wanted so called
conversion available (e.g. the way to go from one version to an other.)

We also added more functionality to the bareos-config script and splitted
the function into a bareos-config-lib which can be included by scripts
so they can get config information like the working dir etc. This is
already used in all the new database scripts.

We also no longer use explicit absolute pathnames for database utilities
but make sure the utility can be found via the PATH, if your PATH already
provides the utility it will be used and otherwise the value will be used
that was determined at compile time.

Fixes #236: Hardcoded path for postgres (verison) in scripts
  • Loading branch information
joergsteffens authored and Marco van Wieringen committed Jan 31, 2014
1 parent 04288ee commit 6f4dc6d
Show file tree
Hide file tree
Showing 63 changed files with 1,965 additions and 1,346 deletions.
38 changes: 1 addition & 37 deletions autoconf/configure.in
Expand Up @@ -3756,6 +3756,7 @@ debian/bareos-filedaemon.preinst \
debian/bareos-director.preinst \
debian/bareos-storage.preinst \
scripts/bareos-config \
scripts/bareos-config-lib.sh \
scripts/btraceback \
scripts/bconsole \
scripts/bareos \
Expand Down Expand Up @@ -3792,26 +3793,6 @@ src/cats/Makefile \
src/cats/make_catalog_backup.pl \
src/cats/make_catalog_backup \
src/cats/delete_catalog_backup \
src/cats/create_postgresql_database \
src/cats/update_postgresql_tables \
src/cats/make_postgresql_tables \
src/cats/grant_postgresql_privileges \
src/cats/drop_postgresql_tables \
src/cats/drop_postgresql_database \
src/cats/create_mysql_database \
src/cats/update_mysql_tables \
src/cats/make_mysql_tables \
src/cats/grant_mysql_privileges \
src/cats/drop_mysql_tables \
src/cats/drop_mysql_database \
src/cats/create_sqlite3_database \
src/cats/update_sqlite3_tables \
src/cats/make_sqlite3_tables \
src/cats/grant_sqlite3_privileges \
src/cats/drop_sqlite3_tables \
src/cats/drop_sqlite3_database \
src/cats/sqlite \
src/cats/mysql \
src/cats/create_bareos_database \
src/cats/update_bareos_tables \
src/cats/grant_bareos_privileges \
Expand Down Expand Up @@ -3888,24 +3869,7 @@ c=src/cats

chmod 755 $c/create_bareos_database $c/update_bareos_tables $c/make_bareos_tables
chmod 755 $c/grant_bareos_privileges $c/drop_bareos_tables $c/drop_bareos_database

chmod 755 $c/create_mysql_database $c/update_mysql_tables $c/make_mysql_tables
chmod 755 $c/grant_mysql_privileges $c/drop_mysql_tables $c/drop_mysql_database

chmod 755 $c/create_sqlite3_database $c/update_sqlite3_tables $c/make_sqlite3_tables
chmod 755 $c/grant_sqlite3_privileges $c/drop_sqlite3_tables $c/drop_sqlite3_database

chmod 755 $c/create_postgresql_database $c/update_postgresql_tables $c/make_postgresql_tables
chmod 755 $c/grant_postgresql_privileges $c/drop_postgresql_tables $c/drop_postgresql_database

#chmod 755 $c/create_ingres_database $c/update_ingres_tables $c/make_ingres_tables
#chmod 755 $c/grant_ingres_privileges $c/drop_ingres_tables $c/drop_ingres_database


chmod 755 $c/make_catalog_backup $c/delete_catalog_backup $c/make_catalog_backup.pl
chmod 755 $c/sqlite
chmod 755 $c/mysql

chmod 755 $c/install-default-backend

if test "x$ac_cv_sys_largefile_CFLAGS" != "xno" ; then
Expand Down
1 change: 1 addition & 0 deletions debian/bareos-common.install
@@ -1,4 +1,5 @@
/usr/lib/bareos/scripts/bareos-config
/usr/lib/bareos/scripts/bareos-config-lib.sh
/usr/lib/bareos/scripts/btraceback.gdb
/usr/lib/libbareos.so
/usr/lib/libbareos-*.so
Expand Down
2 changes: 1 addition & 1 deletion debian/bareos-database-mysql.install
@@ -1,2 +1,2 @@
/usr/lib/libb*-mysql*.so
/usr/lib/bareos/scripts/*_mysql_*
/usr/lib/bareos/scripts/ddl/*/mysql*.sql
2 changes: 1 addition & 1 deletion debian/bareos-database-postgresql.install
@@ -1,2 +1,2 @@
/usr/lib/libb*-postgresql*.so
/usr/lib/bareos/scripts/*_postgresql_*
/usr/lib/bareos/scripts/ddl/*/postgresql*.sql
2 changes: 1 addition & 1 deletion debian/bareos-database-sqlite3.install
@@ -1,2 +1,2 @@
/usr/lib/libb*-sqlite3*.so
/usr/lib/bareos/scripts/*_sqlite3_*
/usr/lib/bareos/scripts/ddl/*/sqlite3*.sql
12 changes: 9 additions & 3 deletions platforms/packaging/bareos.spec
Expand Up @@ -741,6 +741,7 @@ echo "This is a meta package to install a full bareos system" > %{buildroot}%{_d
%dir /usr/lib/bareos/
%dir %{script_dir}
%{script_dir}/bareos-config
%{script_dir}/bareos-config-lib.sh
%{script_dir}/btraceback.gdb
%if "%{_libdir}/bareos/" != "/usr/lib/bareos/"
%dir %{_libdir}/bareos/
Expand All @@ -755,6 +756,11 @@ echo "This is a meta package to install a full bareos system" > %{buildroot}%{_d
%files database-common
# catalog independent files
%defattr(-, root, root)
%dir %{script_dir}/ddl
%dir %{script_dir}/ddl/creates
%dir %{script_dir}/ddl/drops
%dir %{script_dir}/ddl/grants
%dir %{script_dir}/ddl/updates
%{_libdir}/libbareossql.so
%{_libdir}/libbareoscats.so
%{_libdir}/libbareossql-%{_libversion}.so
Expand All @@ -769,22 +775,22 @@ echo "This is a meta package to install a full bareos system" > %{buildroot}%{_d
%files database-postgresql
# postgresql catalog files
%defattr(-, root, root)
%{script_dir}/*_postgresql_*
%{script_dir}/ddl/*/postgresql*.sql
%{_libdir}/libbareoscats-postgresql.so
%{_libdir}/libbareoscats-postgresql-%{_libversion}.so

%files database-mysql
# mysql catalog files
%defattr(-, root, root)
%{script_dir}/*_mysql_*
%{script_dir}/ddl/*/mysql*.sql
%{_libdir}/libbareoscats-mysql.so
%{_libdir}/libbareoscats-mysql-%{_libversion}.so

%if 0%{?build_sqlite3}
%files database-sqlite3
# sqlite3 catalog files
%defattr(-, root, root)
%{script_dir}/*_sqlite3_*
%{script_dir}/ddl/*/sqlite3*.sql
%{_libdir}/libbareoscats-sqlite3.so
%{_libdir}/libbareoscats-sqlite3-%{_libversion}.so
%endif
Expand Down
1 change: 1 addition & 0 deletions scripts/Makefile.in
Expand Up @@ -62,6 +62,7 @@ install: installdirs
$(INSTALL_DATA) btraceback.mdb $(DESTDIR)$(scriptdir)/btraceback.mdb
#$(INSTALL_SCRIPT) -m 700 bareos-password-setup.sh ${DESTDIR}${scriptdir}/bareos-password-setup.sh
$(INSTALL_SCRIPT) bareos-config ${DESTDIR}${scriptdir}/bareos-config
$(INSTALL_SCRIPT) bareos-config-lib.sh ${DESTDIR}${scriptdir}/bareos-config-lib.sh
$(INSTALL_SCRIPT) btraceback $(DESTDIR)$(sbindir)/btraceback
#$(INSTALL_SCRIPT) logrotate $(DESTDIR)/etc/logrotate.d/bareos-dir

Expand Down

0 comments on commit 6f4dc6d

Please sign in to comment.