1
0
Fork 0

- add database schema

- add host to postgres connection
- add comments with additional account data

git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@152 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
Jan Dittberner 2006-02-19 23:32:53 +00:00
parent 61569aa807
commit 045c9bce58
3 changed files with 163 additions and 1 deletions

155
backend/dbschema.sql Normal file
View file

@ -0,0 +1,155 @@
--
-- Database Schema for gnuviechadmin-tools
-- (c) 2006 Jan Dittberner <jan@dittberner.info>
-- $Id$
--
SET client_encoding = 'SQL_ASCII';
SET check_function_bodies = false;
--
-- Country names
--
CREATE TABLE country (
countryid serial NOT NULL,
name varchar(40) NOT NULL,
PRIMARY KEY (countryid)
);
REVOKE ALL ON TABLE country FROM PUBLIC;
--
-- Salutations
--
CREATE TABLE salutation (
salutationid serial NOT NULL,
name varchar(20) NOT NULL,
primary key (salutationid),
unique (name)
);
REVOKE ALL ON TABLE salutation FROM PUBLIC;
--
-- Client data
--
CREATE TABLE client (
clientid serial NOT NULL,
clientnr varchar(10) NOT NULL,
salutationid integer NOT NULL REFERENCES salutation(salutationid),
firstname varchar(40) NOT NULL,
lastname varchar(40) NOT NULL,
address1 varchar(40) NOT NULL,
address2 varchar(40),
countryid integer NOT NULL REFERENCES country(countryid),
town varchar(50) NOT NULL,
zipcode character(5) NOT NULL,
state varchar(40),
active boolean DEFAULT false NOT NULL,
phone varchar(20),
mobile varchar(20),
reseller_id integer REFERENCES client(clientid),
organisation varchar(200),
primary key (clientid),
unique (clientnr)
);
REVOKE ALL ON TABLE client FROM PUBLIC;
--
-- Email addresses
--
CREATE TABLE email (
emailid serial NOT NULL,
email varchar(128) NOT NULL,
clientid integer NOT NULL REFERENCES client(clientid),
verified boolean DEFAULT false NOT NULL,
sortorder integer NOT NULL,
primary key (emailid),
unique (email),
unique (clientid, sortorder)
);
REVOKE ALL ON TABLE email FROM PUBLIC;
--
-- System user to client mapping
--
CREATE TABLE sysuser (
sysuserid serial NOT NULL,
name varchar(12) NOT NULL,
"type" integer DEFAULT 0 NOT NULL,
home varchar(128),
shell boolean,
"password" varchar(64),
clientid integer NOT NULL REFERENCES client(clientid),
toupdate boolean DEFAULT false NOT NULL,
md5pass varchar(32),
sysuid integer,
primary key (sysuserid),
unique (name),
unique (sysuid)
);
CREATE INDEX sysuser_type_idx ON sysuser ("type");
REVOKE ALL ON TABLE sysuser FROM PUBLIC;
GRANT SELECT ON TABLE sysuser TO GROUP services;
--
-- Domains
--
CREATE TABLE "domain" (
domainid serial NOT NULL,
domainname varchar(64) NOT NULL,
clientid integer NOT NULL REFERENCES client(clientid),
status integer DEFAULT 0 NOT NULL,
sysuserid integer NOT NULL REFERENCES sysuser(sysuserid),
primary key (domainid),
unique (domainname)
);
REVOKE ALL ON TABLE "domain" FROM PUBLIC;
GRANT SELECT ON TABLE "domain" TO GROUP services;
--
-- DNS Zones
--
CREATE TABLE "zone" (
zoneid serial NOT NULL,
"domain" integer NOT NULL REFERENCES "domain"(domainid),
"type" varchar(5) NOT NULL,
ttl integer NOT NULL,
mxprio integer,
resource varchar(256),
toupdate boolean DEFAULT false NOT NULL,
primary key (zoneid)
);
REVOKE ALL ON TABLE "zone" FROM PUBLIC;
--
-- Mail passwords for pop3/imap accounts
--
CREATE TABLE mailpasswd (
id varchar(128) DEFAULT ''::varchar NOT NULL,
crypt varchar(128) DEFAULT ''::varchar NOT NULL,
clear varchar(128) DEFAULT ''::varchar NOT NULL,
name varchar(128) DEFAULT ''::varchar NOT NULL,
uid integer DEFAULT 65534 NOT NULL,
gid integer DEFAULT 65534 NOT NULL,
home varchar(255) DEFAULT ''::varchar NOT NULL,
maildir varchar(255) DEFAULT ''::varchar NOT NULL,
defaultdelivery varchar(255) DEFAULT ''::varchar NOT NULL,
quota varchar(255) DEFAULT ''::varchar NOT NULL,
spamcheck boolean DEFAULT false NOT NULL,
sajunkscore integer,
primary key (id)
);
REVOKE ALL ON TABLE mailpasswd FROM PUBLIC;
GRANT SELECT ON TABLE mailpasswd TO GROUP services;
--
-- Mail aliases for forwarding configuration and pop3/imap inbox mapping
--
CREATE TABLE mailalias (
email varchar(255) NOT NULL,
"domain" varchar(255) NOT NULL,
target varchar(255) NOT NULL,
primary key (email, "domain")
);
REVOKE ALL ON TABLE mailalias FROM PUBLIC;
GRANT SELECT ON TABLE mailalias TO GROUP services;

View file

@ -1,8 +1,15 @@
#!/usr/bin/env python #!/usr/bin/env python
#
# Settings for gnuviech-admin tool backend
# (c) 2006 Jan Dittberner <jan@dittberner.info>
# $Id$
#
dbsettings = { 'dbuser': 'exim4', dbsettings = { 'dbuser': 'exim4',
'dbpassword' : 'CotOgigmeIk5', 'dbpassword' : 'CotOgigmeIk5',
'dbname' : 'gnuviechadmin' } 'dbname' : 'gnuviechadmin' }
# courier:jevhi3Wriav
# gnuviech:SIKKnsyXsV5yU
mailsender = 'root@gnuviech.info' mailsender = 'root@gnuviech.info'
mailreceiver = 'root@gnuviech.info' mailreceiver = 'root@gnuviech.info'

View file

@ -2,7 +2,7 @@
import psycopg import psycopg
cnx = psycopg.connect("user=exim4 password=CotOgigmeIk5 dbname=gnuviechadmin") cnx = psycopg.connect("host=localhost user=exim4 password=CotOgigmeIk5 dbname=gnuviechadmin")
cr = cnx.cursor() cr = cnx.cursor()