]> git.sur5r.net Git - bacula/bacula/blob - gui/bimagemgr/create_cdimage_table.pl
commit changes
[bacula/bacula] / gui / bimagemgr / create_cdimage_table.pl
1 #!/usr/bin/perl
2 ##
3 # create_cdimage_table.pl
4 # create the bacula table for CD image management
5 #
6 # Copyright (C) 2004 Kern Sibbald
7 #
8 # Thu Dec 09 2004 D. Scott Barninger <barninger at fairfieldcomputers.com>
9 # ASSIGNMENT OF COPYRIGHT
10 # FOR VALUE RECEIVED, D. Scott Barninger hereby sells, transfers and 
11 # assigns unto Kern Sibbald, his successors, assigns and personal representatives, 
12 # all right, title and interest in and to the copyright in this software.
13 # D. Scott Barninger warrants good title to said copyright, that it is 
14 # free of all liens, encumbrances or any known claims against said copyright.
15 #
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public
18 # License version 2 as published by the Free Software Foundation.
19 #
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23 # General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public
26 # License along with this program; if not, write to the Free
27 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 # MA 02111-1307, USA.
29 ##
30
31 $VERSION = "0.2.1";
32
33 require 5.000; use strict 'vars', 'refs', 'subs';
34 use DBI;
35
36 #------------------------------------------------------------------------------------
37 # configuration section
38 my($dbh,$sql,$database,$host,$user,$password,$db_driver,$db_name_param);
39 $database = "bacula";
40 $host = "localhost";
41 $user = "bacula";
42 $password = "";
43 ## database driver selection - uncomment one set
44 # MySQL
45 $db_driver = "mysql";
46 $db_name_param = "database";
47 # Postgresql
48 # $db_driver = "Pg";
49 # $db_name_param = "dbname";
50 ##
51 # end configuration section
52 #------------------------------------------------------------------------------------
53
54 # connect to the database
55 $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$database;host=$host","$user","$password",{'RaiseError' => 1}) || die("Unable to connect to database.");
56
57 if ($db_driver eq "mysql") {
58 $sql = "CREATE TABLE CDImages (
59                                 MediaId INTEGER UNSIGNED NOT NULL,
60                                 LastBurn DATETIME NOT NULL,
61                                 PRIMARY KEY (MediaId))";
62 }
63
64 if ($db_driver eq "Pg") {
65 $sql = "CREATE TABLE CDImages (
66                                 MediaId integer not null,
67                                 LastBurn timestamp without time zone not null,
68                                 primary key (MediaId))";
69 }
70
71 $dbh->do($sql);
72
73 $dbh->disconnect();
74 print "\nFinished creating the CDImages table.\n";
75 exit;
76
77 #-------------------------------------------------------------------#
78 # Changelog
79 #
80 # 0.2 14 Aug 2004
81 # first functional version
82 #
83 # 0.2.1 15 Aug 2004
84 # add configuration option for Postgresql driver
85