- updated schema
- use database connection git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@186 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
parent
bca6369b41
commit
f5e5b1ed34
3 changed files with 128 additions and 101 deletions
|
@ -5,6 +5,8 @@
|
||||||
#
|
#
|
||||||
from SessionManager import *
|
from SessionManager import *
|
||||||
from DomainManager import *
|
from DomainManager import *
|
||||||
|
import Settings
|
||||||
|
import psycopg
|
||||||
|
|
||||||
class ServiceFacade:
|
class ServiceFacade:
|
||||||
"""
|
"""
|
||||||
|
@ -12,8 +14,9 @@ class ServiceFacade:
|
||||||
gnuviech admin backend.
|
gnuviech admin backend.
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.sessionManager = SessionManager(None)
|
dbconn = psycopg.connect('host=%(dbhost)s user=%(dbuser)s password=%(dbpassword)s dbname=%(dbname)s' % Settings.DBSETTINGS)
|
||||||
self.domainManager = DomainManager(None)
|
self.sessionManager = SessionManager(dbconn)
|
||||||
|
self.domainManager = DomainManager(dbconn)
|
||||||
|
|
||||||
def _dispatch(self, method, params):
|
def _dispatch(self, method, params):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -5,9 +5,11 @@
|
||||||
#
|
#
|
||||||
ALLPREFIX = '/home/jan/gnvadmtest'
|
ALLPREFIX = '/home/jan/gnvadmtest'
|
||||||
|
|
||||||
DBSETTINGS = { 'dbuser': 'exim4',
|
DBSETTINGS = { 'dbhost' : 'localhost',
|
||||||
'dbpassword' : 'CotOgigmeIk5',
|
'dbuser' : 'gnuviech',
|
||||||
|
'dbpassword' : 'SIKKnsyXsV5yU',
|
||||||
'dbname' : 'gnuviechadmin' }
|
'dbname' : 'gnuviechadmin' }
|
||||||
|
# exim:CotOgigmeIk5
|
||||||
# courier:jevhi3Wriav
|
# courier:jevhi3Wriav
|
||||||
# gnuviech:SIKKnsyXsV5yU
|
# gnuviech:SIKKnsyXsV5yU
|
||||||
|
|
||||||
|
|
|
@ -1,155 +1,177 @@
|
||||||
--
|
--
|
||||||
-- Database Schema for gnuviechadmin-tools
|
-- PostgreSQL database dump
|
||||||
-- (c) 2006 Jan Dittberner <jan@dittberner.info>
|
|
||||||
-- $Id$
|
|
||||||
--
|
--
|
||||||
|
|
||||||
SET client_encoding = 'SQL_ASCII';
|
SET client_encoding = 'UNICODE';
|
||||||
SET check_function_bodies = false;
|
SET check_function_bodies = false;
|
||||||
|
|
||||||
|
SET SESSION AUTHORIZATION 'postgres';
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Country names
|
-- Name: public; Type: ACL; Schema: -; Owner: postgres
|
||||||
--
|
--
|
||||||
|
|
||||||
|
REVOKE ALL ON SCHEMA public FROM PUBLIC;
|
||||||
|
GRANT ALL ON SCHEMA public TO PUBLIC;
|
||||||
|
|
||||||
|
SET SESSION AUTHORIZATION 'gnuviech';
|
||||||
|
|
||||||
|
SET search_path = public, pg_catalog;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: country; Type: TABLE; Schema: public; Owner: gnuviech
|
||||||
|
--
|
||||||
CREATE TABLE country (
|
CREATE TABLE country (
|
||||||
countryid serial NOT NULL,
|
countryid serial PRIMARY KEY,
|
||||||
name varchar(40) NOT NULL,
|
name character varying(40) NOT NULL
|
||||||
PRIMARY KEY (countryid)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
REVOKE ALL ON TABLE country FROM PUBLIC;
|
REVOKE ALL ON TABLE country FROM PUBLIC;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Salutations
|
-- Name: reseller; Type: TABLE; Schema: public; Owner: gnuviech
|
||||||
--
|
--
|
||||||
CREATE TABLE salutation (
|
|
||||||
salutationid serial NOT NULL,
|
CREATE TABLE reseller (
|
||||||
name varchar(20) NOT NULL,
|
resellerid serial PRIMARY KEY,
|
||||||
primary key (salutationid),
|
name character varying(40) NOT NULL
|
||||||
unique (name)
|
|
||||||
);
|
);
|
||||||
REVOKE ALL ON TABLE salutation FROM PUBLIC;
|
|
||||||
|
REVOKE ALL ON TABLE reseller FROM PUBLIC;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Client data
|
-- Name: client; Type: TABLE; Schema: public; Owner: gnuviech
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE client (
|
CREATE TABLE client (
|
||||||
clientid serial NOT NULL,
|
clientid serial PRIMARY KEY,
|
||||||
clientnr varchar(10) NOT NULL,
|
firstname character varying(40) NOT NULL,
|
||||||
salutationid integer NOT NULL REFERENCES salutation(salutationid),
|
lastname character varying(40) NOT NULL,
|
||||||
firstname varchar(40) NOT NULL,
|
address1 character varying(40) NOT NULL,
|
||||||
lastname varchar(40) NOT NULL,
|
address2 character varying(40),
|
||||||
address1 varchar(40) NOT NULL,
|
|
||||||
address2 varchar(40),
|
|
||||||
countryid integer NOT NULL REFERENCES country(countryid),
|
countryid integer NOT NULL REFERENCES country(countryid),
|
||||||
town varchar(50) NOT NULL,
|
town character varying(50) NOT NULL,
|
||||||
zipcode character(5) NOT NULL,
|
zipcode character(5) NOT NULL,
|
||||||
state varchar(40),
|
state character varying(40),
|
||||||
active boolean DEFAULT false NOT NULL,
|
active boolean DEFAULT false NOT NULL,
|
||||||
phone varchar(20),
|
phone character varying(20),
|
||||||
mobile varchar(20),
|
mobile character varying(20),
|
||||||
reseller_id integer REFERENCES client(clientid),
|
reseller_id integer REFERENCES reseller(resellerid),
|
||||||
organisation varchar(200),
|
organisation character varying(200)
|
||||||
primary key (clientid),
|
|
||||||
unique (clientnr)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
REVOKE ALL ON TABLE client FROM PUBLIC;
|
REVOKE ALL ON TABLE client FROM PUBLIC;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Email addresses
|
-- Name: email; Type: TABLE; Schema: public; Owner: gnuviech
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE email (
|
CREATE TABLE email (
|
||||||
emailid serial NOT NULL,
|
emailid serial PRIMARY KEY,
|
||||||
email varchar(128) NOT NULL,
|
email character varying(128) NOT NULL,
|
||||||
clientid integer NOT NULL REFERENCES client(clientid),
|
clientid integer NOT NULL REFERENCES client(clientid),
|
||||||
verified boolean DEFAULT false NOT NULL,
|
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;
|
REVOKE ALL ON TABLE email FROM PUBLIC;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- System user to client mapping
|
-- Name: sysuser; Type: TABLE; Schema: public; Owner: gnuviech
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE sysuser (
|
CREATE TABLE sysuser (
|
||||||
sysuserid serial NOT NULL,
|
sysuserid serial PRIMARY KEY,
|
||||||
name varchar(12) NOT NULL,
|
name character varying(12) NOT NULL,
|
||||||
"type" integer DEFAULT 0 NOT NULL,
|
"type" integer DEFAULT 0 NOT NULL,
|
||||||
home varchar(128),
|
home character varying(128),
|
||||||
shell boolean,
|
shell boolean,
|
||||||
"password" varchar(64),
|
"password" character varying(64),
|
||||||
clientid integer NOT NULL REFERENCES client(clientid),
|
clientid integer NOT NULL REFERENCES client(clientid),
|
||||||
toupdate boolean DEFAULT false NOT NULL,
|
toupdate boolean DEFAULT false NOT NULL,
|
||||||
md5pass varchar(32),
|
md5pass character varying(32),
|
||||||
sysuid integer,
|
sysuid integer UNIQUE
|
||||||
primary key (sysuserid),
|
|
||||||
unique (name),
|
|
||||||
unique (sysuid)
|
|
||||||
);
|
);
|
||||||
CREATE INDEX sysuser_type_idx ON sysuser ("type");
|
|
||||||
REVOKE ALL ON TABLE sysuser FROM PUBLIC;
|
REVOKE ALL ON TABLE sysuser FROM PUBLIC;
|
||||||
GRANT SELECT ON TABLE sysuser TO GROUP services;
|
GRANT SELECT ON TABLE sysuser TO GROUP services;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Domains
|
-- Name: domain; Type: TABLE; Schema: public; Owner: gnuviech
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE "domain" (
|
CREATE TABLE "domain" (
|
||||||
domainid serial NOT NULL,
|
domainid serial PRIMARY KEY,
|
||||||
domainname varchar(64) NOT NULL,
|
domainname character varying(64) NOT NULL,
|
||||||
clientid integer NOT NULL REFERENCES client(clientid),
|
clientid integer NOT NULL REFERENCES client(clientid),
|
||||||
status integer DEFAULT 0 NOT NULL,
|
status integer DEFAULT 0 NOT NULL,
|
||||||
sysuserid integer NOT NULL REFERENCES sysuser(sysuserid),
|
sysuserid integer NOT NULL REFERENCES sysuser(sysuserid)
|
||||||
primary key (domainid),
|
|
||||||
unique (domainname)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
REVOKE ALL ON TABLE "domain" FROM PUBLIC;
|
REVOKE ALL ON TABLE "domain" FROM PUBLIC;
|
||||||
GRANT SELECT ON TABLE "domain" TO GROUP services;
|
GRANT SELECT ON TABLE "domain" TO GROUP services;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- DNS Zones
|
-- Name: zone; Type: TABLE; Schema: public; Owner: gnuviech
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE "zone" (
|
CREATE TABLE "zone" (
|
||||||
zoneid serial NOT NULL,
|
zoneid serial PRIMARY KEY,
|
||||||
"domain" integer NOT NULL REFERENCES "domain"(domainid),
|
"domain" integer NOT NULL REFERENCES domain(domainid),
|
||||||
"type" varchar(5) NOT NULL,
|
"type" character varying(5) NOT NULL,
|
||||||
ttl integer NOT NULL,
|
ttl integer NOT NULL,
|
||||||
mxprio integer,
|
mxprio integer,
|
||||||
resource varchar(256),
|
resource character varying(256),
|
||||||
toupdate boolean DEFAULT false NOT NULL,
|
toupdate boolean DEFAULT false NOT NULL
|
||||||
primary key (zoneid)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
REVOKE ALL ON TABLE "zone" FROM PUBLIC;
|
REVOKE ALL ON TABLE "zone" FROM PUBLIC;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Mail passwords for pop3/imap accounts
|
-- Name: mailpasswd; Type: TABLE; Schema: public; Owner: gnuviech
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE mailpasswd (
|
CREATE TABLE mailpasswd (
|
||||||
id varchar(128) DEFAULT ''::varchar NOT NULL,
|
id character varying(128) NOT NULL,
|
||||||
crypt varchar(128) DEFAULT ''::varchar NOT NULL,
|
crypt character varying(128) DEFAULT '' NOT NULL,
|
||||||
clear varchar(128) DEFAULT ''::varchar NOT NULL,
|
clear character varying(128) DEFAULT '' NOT NULL,
|
||||||
name varchar(128) DEFAULT ''::varchar NOT NULL,
|
name character varying(128) DEFAULT '' NOT NULL,
|
||||||
uid integer DEFAULT 65534 NOT NULL,
|
uid integer DEFAULT 65534 NOT NULL,
|
||||||
gid integer DEFAULT 65534 NOT NULL,
|
gid integer DEFAULT 65534 NOT NULL,
|
||||||
home varchar(255) DEFAULT ''::varchar NOT NULL,
|
home character varying(255) DEFAULT '' NOT NULL,
|
||||||
maildir varchar(255) DEFAULT ''::varchar NOT NULL,
|
maildir character varying(255) DEFAULT '' NOT NULL,
|
||||||
defaultdelivery varchar(255) DEFAULT ''::varchar NOT NULL,
|
defaultdelivery character varying(255) DEFAULT '' NOT NULL,
|
||||||
quota varchar(255) DEFAULT ''::varchar NOT NULL,
|
quota character varying(255) DEFAULT '' NOT NULL,
|
||||||
spamcheck boolean DEFAULT false NOT NULL,
|
spamcheck boolean DEFAULT false NOT NULL,
|
||||||
sajunkscore integer,
|
sajunkscore integer
|
||||||
primary key (id)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
REVOKE ALL ON TABLE mailpasswd FROM PUBLIC;
|
REVOKE ALL ON TABLE mailpasswd FROM PUBLIC;
|
||||||
GRANT SELECT ON TABLE mailpasswd TO GROUP services;
|
GRANT ALL ON TABLE mailpasswd TO GROUP services;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Mail aliases for forwarding configuration and pop3/imap inbox mapping
|
-- Name: mailalias; Type: TABLE; Schema: public; Owner: gnuviech
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE mailalias (
|
CREATE TABLE mailalias (
|
||||||
email varchar(255) NOT NULL,
|
email character varying(255) NOT NULL,
|
||||||
"domain" varchar(255) NOT NULL,
|
"domain" character varying(255) NOT NULL,
|
||||||
target varchar(255) NOT NULL,
|
target character varying(255) NOT NULL
|
||||||
primary key (email, "domain")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
REVOKE ALL ON TABLE mailalias FROM PUBLIC;
|
REVOKE ALL ON TABLE mailalias FROM PUBLIC;
|
||||||
GRANT SELECT ON TABLE mailalias TO GROUP services;
|
GRANT ALL ON TABLE mailalias TO GROUP services;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: country; Type: TABLE DATA; Schema: public; Owner: gnuviech
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO country (countryid, name) VALUES (1, 'Deutschland');
|
||||||
|
INSERT INTO country (countryid, name) VALUES (2, 'Schweiz');
|
||||||
|
INSERT INTO country (countryid, name) VALUES (3, 'Österreich');
|
||||||
|
|
||||||
|
SET SESSION AUTHORIZATION 'postgres';
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
Loading…
Reference in a new issue