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
|
#!/bin/sh
# this script creates the files needed by dbc for database creation
# and updates.
# this script needs to be augmented whenever there is a new database update,
# in particular "lastdbversion" and the case statements need to be reviewed.
# (C) 2016-2017 Carsten Leonhardt <leo@debian.org>
# License: expat
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# first and last target database version covered by this script
dbtarget=11
lastdbversion=16
variants="mysql pgsql sqlite3"
dbc="usr/share/dbconfig-common/data"
extractor="debian/scripts/extract-dbupgrade.awk"
set_longdb() {
if [ $db = pgsql ] ; then
longdb=postgresql
else
longdb=$db
fi
}
# handle older db upgrades
while [ $dbtarget -le 12 ]; do
for db in $variants; do
set_longdb
case $dbtarget in
11) baculaversion="3.0.0"
sourcefile="updatedb/update_"$longdb"_tables_10_to_11"
;;
12) baculaversion="5.0.0"
sourcefile="updatedb/update_"$longdb"_tables_11_to_12"
;;
esac
targetfile="debian/bacula-director-"$db"/"$dbc"/bacula-director-"$db"/upgrade/"$db"/"$baculaversion;
mkdir -p `dirname $targetfile`
awk -v version=ignore -f $extractor $sourcefile >> $targetfile
done
dbtarget=$((dbtarget + 1))
done
# handle newer db upgrades
while [ $dbtarget -le $lastdbversion ]; do
for db in $variants; do
set_longdb
case $dbtarget in
13) baculaversion="5.2.0"
;;
14) baculaversion="5.2.0"
;;
15) baculaversion="7.2.0"
;;
16) baculaversion="9.0.0"
;;
*) echo "$0: Unknown database target version"
exit 1
;;
esac
sourcefile="src/cats/update_"$longdb"_tables"
targetfile="debian/bacula-director-"$db"/"$dbc"/bacula-director-"$db"/upgrade/"$db"/"$baculaversion;
mkdir -p `dirname $targetfile`
awk -v version=$dbtarget -f $extractor $sourcefile >> $targetfile
done
dbtarget=$((dbtarget + 1))
done
# handle db creation
for db in $variants; do
set_longdb
sourcefile="src/cats/make_"$longdb"_tables"
targetfile="debian/bacula-director-"$db"/"$dbc"/bacula-director-"$db"/install/"$db;
mkdir -p `dirname $targetfile`
awk -v version=ignore -f $extractor $sourcefile >> $targetfile
done
# check if this script needs to be updated
# we check for all db types just to be on the safe side
for db in $variants; do
set_longdb
sourcefile="src/cats/make_"$longdb"_tables"
# this looks where the current database version is inserted in the make_(db)_tables script and extracts it
current_bacula_db_version=`sed -n 's/INSERT INTO Version (VersionId) VALUES (\([0-9]*\));/\1/ip' $sourcefile`
if [ $current_bacula_db_version -ne $lastdbversion ]; then
echo "error: unsupported database version $current_bacula_db_version, please update $0!"
exit 1
fi
done
|