Ubuntu Pastebin

Paste from Nish at Thu, 23 Jun 2016 17:02:49 +0000

Download as text
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
debian/rules:

override_dh_install-arch:
        dh_install -a
        ######### dbconfig-common stuff
        # Sometimes the latest release doesn't have a copy of the data in updatedb.
        # Manually install those. CHECK THIS FOR EACH NEW RELEASE!
        #
        # lenny -> squeeze is 10 -> 12
        $(foreach db,$(VARIANTS),$(shell debian/scripts/install-dbconfig $(db) 3.0.0 11)) # 3.0.0 upgrade 10 to 11
        $(foreach db,$(VARIANTS),$(shell debian/scripts/install-dbconfig $(db) 5.0.0 12)) # 5.0.0 upgrade 11 to 12
        debian/scripts/install-dbconfig-upgrade # handles install of all upgrade scripts to db version 13 and greater
        $(foreach db,$(VARIANTS),$(shell debian/scripts/install-dbconfig $(db)))          # new installs
        # fix database type in some scripts
        $(foreach db,$(VARIANTS),sed -i \
          -e "s/XX_DB_XX/$(db)/" \
                -e "s/XX_DBLONGNAME_XX/$(LONGNAME_$(db))/" \
                debian/bacula-director-$(db)/etc/bacula/scripts/make_catalog_backup \
                debian/bacula-director-$(db)/etc/bacula/scripts/make_catalog_backup.pl;)
#ifeq ($(HAVE_SYSTEMD),1)
#       # only install systemd related files if systemd is enabled during build
#       install -m 644 platforms/systemd/bacula-fd.service -D debian/bacula-fd/lib/systemd/system/bacula-fd.service
#       install -m 644 platforms/systemd/bacula-sd.service -D debian/bacula-sd/lib/systemd/system/bacula-sd.service
#       install -m 644 platforms/systemd/bacula-dir.service -D debian/bacula-director-common/lib/systemd/system/bacula-director.service
#endif

debian/scripts/install-dbconfig:

#!/usr/bin/perl

# Script to install files used by dbconfig-common to install and upgrade
# databases
# (c) 2011 Debian project, Jan Hauke Rahm <jhr@debian.org>
# Based on make macros written by John Goerzen

# Arguments needed:
# 1: database type (sqlite3, mysql, pgsql)
# 2: package version
# 3: bacula database version to support
#
# There are three ways to call this script:
# 1) ./script db-type
# 2) ./script db-type version
# 3) ./script db-type version bacula-db
#
# The first will install the SQL stuff needed to create the database during
# package installations. The second will install the SQL stuff needed to
# upgrade to the latest version of the bacula-db. The third will install
# additional SQL upgrade stuff if we skipped a bacula db version in Debian.
#
# Example: lenny had package version 2.4.4 with bacula db version 10, squeeze has
#          package version 5.0.0 with bacula db version 12.
#          Always needed is the installation stuff:
#    ./script db-type
#          Then we need to migrate the db from 10 (2.4.4) to 11 (3.0.0)
#    ./script db-type 3.0.0 11
#          Finally we need to migrate from 11 to 12 (3.0.0 to 5.0.0) which
#          upstream ships as "latest upgrade"
#    ./script db-type 5.0.0

use strict;
use File::Path "make_path";

my $DBC = "usr/share/dbconfig-common/data";

my $db          = $ARGV[0];
my $pkgver      = $ARGV[1];
my $dbver       = $ARGV[2];

my $longdb      = $db;
$longdb = ($db eq "pgsql") ? "postgresql" : $db;

if (@ARGV == 1) {
        install($db);
} elsif (@ARGV == 2) {
        latest($db, $pkgver);
} elsif (@ARGV == 3) {
        update($db, $pkgver, $dbver);
} else {
        exit 1;
}

sub install {
        make_path("debian/bacula-director-$db/$DBC/bacula-director-$db/install");
        extract_here("src/cats/make_".$longdb."_tables", "debian/bacula-director-$db/$DBC/bacula-director-$db/install/$db");
}

sub latest {
        make_path("debian/bacula-director-$db/$DBC/bacula-director-$db/upgrade/$db");
        extract_here("src/cats/update_".$longdb."_tables", "debian/bacula-director-$db/$DBC/bacula-director-$db/upgrade/$db/$pkgver");
}

sub update {
        my $path = ($dbver - 1) . "_to_" . $dbver;

        make_path("debian/bacula-director-$db/$DBC/bacula-director-$db/upgrade/$db");
        extract_here("updatedb/update_".$longdb."_tables_$path", "debian/bacula-director-$db/$DBC/bacula-director-$db/upgrade/$db/$pkgver");
}

sub extract_here {
        my $input = shift;
        my $output = shift;

        my $found = 0;

        open (INPUT, '<', $input);
        open (OUTPUT, '>', $output);
        while (<INPUT>) {
                if (m/END.OF.DATA/ && !$found) {$found = 1; next;};
                last if (m/END.OF.DATA/);
                print OUTPUT $_ if $found;
        }
        close (INPUT);
}

src/cats/make_mysql_tables:

#!/bin/sh
#
# shell script to create Bacula MySQL tables
#
# Copyright (C) 2000-2015 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# Important note: 
#   You won't get any support for performance issue if you changed the default
#   schema.
#
bindir=/usr/bin
PATH="$bindir:$PATH"
db_name=${db_name:-XXX_DBNAME_XXX}

if mysql $* -f <<END-OF-DATA
SET SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'NO_ZERO_DATE', ''));
USE ${db_name};
--
-- Note, we use BLOB rather than TEXT because in MySQL,
--  BLOBs are identical to TEXT except that BLOB is case
--  sensitive in sorts, which is what we want, and TEXT
--  is case insensitive.
--
...
Download as text