Browse Source

added rudimentary setup script

master
Michael van Elst 23 years ago committed by Ralf S. Engelschall
parent
commit
55f6b6c23b
  1. 29
      powerdns/powerdns.spec
  2. 154
      powerdns/powerdnssetup

29
powerdns/powerdns.spec

@ -35,7 +35,7 @@ Distribution: OpenPKG [JUNK]
Group: unknown
License: GPL
Version: 2.9.6
Release: 20030228
Release: 20030304
# list of sources
Source0: http://downloads.powerdns.com/releases/pdns-%{version}.tar.gz
@ -43,6 +43,7 @@ Source1: rc.powerdns
Source2: fsl.powerdns
# package options
%option with_fsl yes
%option with_pipe no
%option with_mysql no
%option with_pgsql no
@ -71,21 +72,15 @@ AutoReqProv: no
The PowerDNS name server is a modern, advanced and high performance
authoritative-only nameserver. It is written from scratch and conforms
to all the relevant DNS standards documents.
The PowerDNS name server utilizes a flexible backend architecture which
can access DNS information from any data source. This includes file
formats, Bind zone files, relational databases or LDAP directories.
By connecting directly to a database, no 'reloading' is needed. Changes
committed to the database are effective immediately.
If you have specific needs for your DNS infrastructure then you can use
the Backend Developers Kit to write the 'glue' between PowerDNS and your
data or logic.
Since version 2.9, PowerDNS is licensed under GNU General Public License
version 2.
%prep
%setup -q -n pdns-%{version}
@ -101,12 +96,19 @@ AutoReqProv: no
MODULES="$MODULES gpgsql"
%endif
MODULES=`echo "$MODULES" | sed 's;^ ;;'`
lf="%{l_ldflags}"
li=""
%if "%{with_fsl}" == "yes"
lf="$lf `%{l_prefix}/bin/fsl-config --all --ldflags --libs`"
li="$li `%{l_prefix}/bin/fsl-config --all --libs`"
%endif
CC="%{l_cc}" \
CXX="%{l_cxx}" \
CFLAGS="%{l_cflags -O}" \
CXXFLAGS="%{l_cxxflags -O} -DDLLIMPORT=" \
CPPFLAGS="%{l_cppflags} -DDLLIMPORT=" \
LDFLAGS="%{l_ldflags}" \
LDFLAGS="$lf" \
LIBS="$li" \
./configure \
--prefix=%{l_prefix} \
--sysconfdir=%{l_prefix}/etc/powerdns \
@ -142,6 +144,9 @@ AutoReqProv: no
# Setup config file
mv $RPM_BUILD_ROOT%{l_prefix}/etc/powerdns/pdns.conf-dist \
$RPM_BUILD_ROOT%{l_prefix}/etc/powerdns/pdns.conf
%{l_shtool} subst \
-e 's;@l_prefix@;%{l_prefix};g' \
$RPM_BUILD_ROOT%{l_prefix}/etc/powerdns/pdns.conf
# Creating run-command script
%{l_shtool} mkdir -f -p -m 755 \
@ -151,6 +156,14 @@ AutoReqProv: no
-e 's;@l_musr@;%{l_musr};g' -e 's;@l_mgrp@;%{l_mgrp};g' \
%{SOURCE rc.powerdns} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
%if "%{with_mysql}" == "yes" || "%{with_pgsql}" == "yes"
# Install setup script
%{l_shtool} mkdir -p -m 755 \
powerdnssetup} $RPM_BUILD_ROOT%{l_prefix}/sbin
%{l_shtool} install -c -m 755 \
%{SOURCE powerdnssetup} $RPM_BUILD_ROOT%{l_prefix}/sbin/
%endif
# Creating fsl directory
%{l_shtool} mkdir -f -p -m 755 \
$RPM_BUILD_ROOT%{l_prefix}/etc/fsl

154
powerdns/powerdnssetup

@ -0,0 +1,154 @@
#!/bin/sh
case "$1" in
gmysql)
dbtype=MySQL
;;
gpgsql)
dbtype=PostgreSQL
;;
*)
echo "usage: $0 [ gmysql | gpgsql ]"
exit 1
;;
esac
while [ ".$db" = . ]; do
echo "Please enter the name of the database to be created:"
read db
done
while [ ".$root" = . ]; do
echo "Please enter the name of the database administrator account:"
read root
done
while [ ".$pdnsadm" = . ]; do
echo "Please enter the name of the DNS administrator account:"
read pdnsadm
done
while [ ".$pdns" = . ]; do
echo "Please enter the name of the DNS user account:"
read pdns
done
echo ""
echo "The $dbtype database '$db' will be created by '$root'."
echo "Access is granted to the DNS administrator '$pdnsadm'"
echo "and the DNS user '$pdns'."
echo ""
case "$1" in
gmysql)
echo "Please log in as the $dbtype database administrator ($root)"
mysql -u$root -p mysql <<EOFEOF
DROP DATABASE $db;
CREATE DATABASE $db;
GRANT ALL ON $db TO $pdnsadm WITH GRANT OPTION
EOFEOF
if [ $? -gt 0 ]; then exit 1; fi
echo "The database has been created"
echo ""
echo "Please log in as the $dbtype DNS administrator ($pdnsadm)"
mysql -u$pdnsadm -p $db <<EOFEOF
CREATE TABLE domains (
id INT auto_increment,
name VARCHAR(255) NOT NULL,
master VARCHAR(20) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
primary key (id)
)type=InnoDB;
CREATE UNIQUE INDEX name_index ON domains(name);
CREATE TABLE records (
id INT auto_increment,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(6) DEFAULT NULL,
content VARCHAR(255) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
primary key(id)
)type=InnoDB;
CREATE INDEX rec_name_index ON records(name);
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
CREATE TABLE supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);
GRANT SELECT ON supermasters TO $pdns;
GRANT ALL ON domains TO $pdns;
EOFEOF
if [ $? -gt 0 ]; then exit 1; fi
echo "The database has been populated"
echo ""
;;
gpgsql)
echo "Please log in as the $dbtype database administrator ($root)"
psql -U $root $db <<EOFEOF
DROP DATABASE $db;
CREATE DATABASE $db;
GRANT ALL ON $db TO $pdnsadm WITH GRANT OPTION;
EOFEOF
if [ $? -gt 0 ]; then exit 1; fi
echo "The database has been created"
echo ""
echo "Please log in as the $dbtype DNS administrator ($pdnsadm)"
psql -U $pdnsadm $db <<EOFEOF
CREATE TABLE domains (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
master VARCHAR(20) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL
);
CREATE UNIQUE INDEX name_index ON domains(name);
CREATE TABLE records (
id SERIAL PRIMARY KEY,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(6) DEFAULT NULL,
content VARCHAR(255) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
CONSTRAINT domain_exists
FOREIGN KEY(domain_id) REFERENCES domains(id)
ON DELETE CASCADE
);
CREATE INDEX rec_name_index ON records(name);
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
CREATE TABLE supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);
GRANT SELECT ON supermasters TO $pdns;
GRANT ALL ON domains TO $pdns;
GRANT ALL ON domains_id_seq TO $pdns;
GRANT ALL ON records TO $pdns;
GRANT ALL ON records_id_seq TO $pdns;
EOFEOF
if [ $? -gt 0 ]; then exit 1; fi
echo "The database has been populated"
echo ""
;;
esac
Loading…
Cancel
Save