~ubuntu-branches/ubuntu/maverick/pdns/maverick-updates

« back to all changes in this revision

Viewing changes to debian/pdns-backend-sqlite3.postinst

  • Committer: Bazaar Package Importer
  • Author(s): Matthijs Mohlmann, Matthijs Mohlmann, Christoph Haas
  • Date: 2007-04-15 23:23:39 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070415232339-5x3scc8gx04e50um
Tags: 2.9.21-1
[ Matthijs Mohlmann ]
* New upstream release. (Closes: #420294)
* Remove meta pdns package.
* Added new sqlite3 backend package.
* Months and minutes where mixed up. (Closes: #406462)
* Case sensitivity in bind backend caused PowerDNS to not serve a certain
  zone. (Closes: #406461)
* Bind backend forgot about zones on a notify. (Closes: #398213)

[ Christoph Haas ]
* Documented incorporated backend bind. (Closes: #415471)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
# postinst script for pdns-backend-sqlite
 
3
#
 
4
# see: dh_installdeb(1)
 
5
 
 
6
set -e
 
7
 
 
8
# summary of how this script can be called:
 
9
#        * <postinst> `configure' <most-recently-configured-version>
 
10
#        * <old-postinst> `abort-upgrade' <new version>
 
11
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
 
12
#          <new-version>
 
13
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
 
14
#          <failed-install-package> <version> `removing'
 
15
#          <conflicting-package> <version>
 
16
# for details, see http://www.debian.org/doc/debian-policy/ or
 
17
# the debian-policy package
 
18
#
 
19
 
 
20
# Configuration file
 
21
PDNSCONF=/etc/powerdns/pdns.conf
 
22
PDNSDIR=`cat $PDNSCONF | grep include | awk -F '=' '{print $2}'`
 
23
PDNSUSER=`cat $PDNSCONF | grep setuid | awk -F '=' '{print $2}'`
 
24
PDNSGROUP=`cat $PDNSCONF | grep setgid | awk -F '=' '{print $2}'`
 
25
DATABASE=/var/lib/powerdns/pdns.sqlite3
 
26
PDNSLOCAL=$PDNSDIR/pdns.local
 
27
 
 
28
INITDATA="create table domains (
 
29
  id            INTEGER PRIMARY KEY,
 
30
  name          VARCHAR(255) NOT NULL,
 
31
  master                VARCHAR(20) DEFAULT NULL,
 
32
  last_check    INTEGER DEFAULT NULL,
 
33
  type          VARCHAR(6) NOT NULL,
 
34
  notified_serial   INTEGER DEFAULT NULL,
 
35
  account           VARCHAR(40) DEFAULT NULL
 
36
);
 
37
 
 
38
CREATE UNIQUE INDEX name_index ON domains(name);
 
39
 
 
40
CREATE TABLE records (
 
41
  id              INTEGER PRIMARY KEY,
 
42
  domain_id       INTEGER DEFAULT NULL,
 
43
  name            VARCHAR(255) DEFAULT NULL,
 
44
  type            VARCHAR(6) DEFAULT NULL,
 
45
  content         VARCHAR(255) DEFAULT NULL,
 
46
  ttl             INTEGER DEFAULT NULL,
 
47
  prio            INTEGER DEFAULT NULL,
 
48
  change_date     INTEGER DEFAULT NULL
 
49
);
 
50
 
 
51
CREATE INDEX rec_name_index ON records(name);
 
52
CREATE INDEX nametype_index ON records(name,type);
 
53
CREATE INDEX domain_id ON records(domain_id);
 
54
 
 
55
create table supermasters (
 
56
  ip          VARCHAR(25) NOT NULL,
 
57
  nameserver  VARCHAR(255) NOT NULL,
 
58
  account     VARCHAR(40) DEFAULT NULL
 
59
);"
 
60
 
 
61
update_permissions() {
 
62
  data="$1"
 
63
  if [ -d "$dir" ]; then
 
64
    if [ ! -z "$PDNSUSER" ]; then
 
65
      chown -R "$PDNSUSER" "$data"
 
66
    fi
 
67
    if [ ! -z "$PDNSGROUP" ]; then
 
68
      chgrp -R "$PDNSGROUP" "$data"
 
69
    fi
 
70
  fi
 
71
}
 
72
 
 
73
case "$1" in
 
74
  configure)
 
75
    if [ -f $PDNSLOCAL ]; then
 
76
      EXIST=`(cat $PDNSLOCAL | grep "gsqlite-database") || true`
 
77
      DATA=`echo $EXIST | awk -F '=' '{print $2}'`
 
78
    else
 
79
      EXIST=""
 
80
    fi
 
81
 
 
82
    if [ ! -z "$DATA" ]; then
 
83
      DATABASE=$DATA
 
84
    else
 
85
      if [ ! -d "/var/lib/powerdns" ]; then
 
86
        mkdir -m 0755 /var/lib/powerdns
 
87
      fi
 
88
    fi
 
89
 
 
90
    # Create initial database
 
91
    if [ ! -f $DATABASE ]; then
 
92
      echo -n "Generating sqlite database..."
 
93
      echo $INITDATA | sqlite3 $DATABASE
 
94
      echo "done"
 
95
    fi
 
96
 
 
97
    update_permissions "$DATABASE"
 
98
  ;;
 
99
 
 
100
  abort-upgrade|abort-remove|abort-deconfigure)
 
101
  ;;
 
102
 
 
103
  *)
 
104
    echo "postinst called with unknown argument \`$1'" >&2
 
105
    exit 1
 
106
  ;;
 
107
esac
 
108
 
 
109
if [ -x "/etc/init.d/pdns" ]; then
 
110
  if [ -x /usr/sbin/invoke-rc.d ]; then
 
111
    invoke-rc.d pdns restart || exit $?
 
112
  else
 
113
    /etc/init.d/pdns restart || exit $?
 
114
  fi
 
115
fi
 
116
 
 
117
# dh_installdeb will replace this with shell code automatically
 
118
# generated by other debhelper scripts.
 
119
 
 
120
#DEBHELPER#
 
121
 
 
122
exit 0
 
123