# HG changeset patch # User Pascal Volk # Date 1209603071 0 # Node ID 8c5f1eba0ea6fc5e7d165179e1a5a13ec8a24ffe # Parent 668951708f2f28f49da94479a89c40ab8c8a9b01 * 'install.sh' - Added again $PF_GID (was removed with r19) * 'update_config_0.3.x-0.4.py' * 'update_tables_0.3.x-0.4.py' * 'UPGRADE' * 'upgrade.sh' - removed because vmm 0.4 was released diff -r 668951708f2f -r 8c5f1eba0ea6 UPGRADE --- a/UPGRADE Wed Apr 30 04:05:13 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -If you have installed vmm 0.3.x you have to proceed this steps: - - * stop Postfix and Dovecot - * backup/dump your database. - * backup/dump your database! - * execute upgrade.sh - * set permissions for replaced views: - GRANT SELECT ON dovecot_user, dovecot_password TO your_dovecot_dbuser; - GRANT SELECT ON postfix_transport TO your_postfix_dbuser; - * update user_query in /etc/dovecot/dovecot-sql.conf: - * user_query = \ - SELECT home, uid, gid, 'maildir:'||mail AS mail FROM dovecot_user WHERE userid = '%u' - * update password_query in /etc/dovecot/dovecot-sql.conf: - password_query = \ - SELECT "user", password FROM dovecot_password WHERE "user"='%u' AND %Ls - * edit the pgsql parameters hosts, user, password and dbname in: - $(postconf -h config_directory)/pgsql-smtpd_sender_login_maps.cf - $(postconf -h config_directory)/pgsql-transport.cf - $(postconf -h config_directory)/pgsql-virtual_mailbox_domains.cf - * check the value of option transport in section misc in - /usr/local/etc/vmm.cfg - * start Dovecot and Postfix - -else: - - * read INSTALL diff -r 668951708f2f -r 8c5f1eba0ea6 install.sh --- a/install.sh Wed Apr 30 04:05:13 2008 +0000 +++ b/install.sh Thu May 01 00:51:11 2008 +0000 @@ -9,6 +9,7 @@ INSTALL_OPTS="-g 0 -o 0 -p -v" PREFIX=/usr/local PF_CONFDIR=$(postconf -h config_directory) +PF_GID=$(id -g postfix) DOC_DIR=${PREFIX}/share/doc/vmm MAN1DIR=${PREFIX}/share/man/man1 MAN5DIR=${PREFIX}/share/man/man5 @@ -23,7 +24,7 @@ python setup.py clean --all >/dev/null install -b -m 0600 ${INSTALL_OPTS} vmm.cfg ${PREFIX}/etc/ -install -b -m 0640 ${INSTALL_OPTS} pgsql-*.cf ${PF_CONFDIR}/ +install -b -m 0640 -g ${PF_GID} -o 0 -p -v pgsql-*.cf ${PF_CONFDIR}/ install -m 0700 ${INSTALL_OPTS} vmm ${PREFIX}/sbin [ -d ${MAN1DIR} ] || mkdir -m 0755 -p ${MAN1DIR} diff -r 668951708f2f -r 8c5f1eba0ea6 update_config_0.3.x-0.4.py --- a/update_config_0.3.x-0.4.py Wed Apr 30 04:05:13 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 -*- -# Copyright 2008 VEB IT -# See COPYING for distribution information. -# $Id$ - -from ConfigParser import ConfigParser - -cff = file('/usr/local/etc/vmm.cfg', 'r') -cf = ConfigParser() -cf.readfp(cff) -cff.close() - -if not cf.has_option('misc', 'transport') or not cf.has_section('services') \ -or cf.has_option('maildir', 'base'): - cff = file('/usr/local/etc/vmm.cfg', 'w') - if not cf.has_option('misc', 'transport'): - cf.set('misc', 'transport', 'dovecot:') - if not cf.has_section('services'): - cf.add_section('services') - for service in ['smtp', 'pop3', 'imap', 'managesieve']: - cf.set('services', service, 'true') - if cf.has_option('maildir', 'base'): - domdir = cf.get('maildir', 'base') - cf.remove_option('maildir', 'base') - cf.set('domdir', 'base', domdir) - cf.write(cff) - cff.close() diff -r 668951708f2f -r 8c5f1eba0ea6 update_tables_0.3.x-0.4.py --- a/update_tables_0.3.x-0.4.py Wed Apr 30 04:05:13 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,195 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 -*- -# Copyright 2008 VEB IT -# See COPYING for distribution information. -# $Id$ - -from ConfigParser import ConfigParser -from pyPgSQL import PgSQL - -cff = file('/usr/local/etc/vmm.cfg', 'r') -cf = ConfigParser() -cf.readfp(cff) -cff.close() - -dbh = PgSQL.connect(database=cf.get('database', 'name'), - user=cf.get('database', 'user'), host=cf.get('database', 'host'), - password=cf.get('database', 'pass'), client_encoding='utf8', - unicode_results=True) -dbc = dbh.cursor() -dbc.execute("SET NAMES 'UTF8'") - -# Create new tables -queries = ("CREATE SEQUENCE transport_id", - """CREATE TABLE transport ( - tid bigint NOT NULL DEFAULT nextval('transport_id'), - transport varchar(270) NOT NULL, - CONSTRAINT pkey_transport PRIMARY KEY (tid), - CONSTRAINT ukey_transport UNIQUE (transport) -)""", - "INSERT INTO transport(transport) VALUES ('dovecot:')", - "CREATE SEQUENCE maillocation_id", - """CREATE TABLE maillocation( - mid bigint NOT NULL DEFAULT nextval('maillocation_id'), - maillocation varchar(20) NOT NULL, - CONSTRAINT pkey_maillocation PRIMARY KEY (mid), - CONSTRAINT ukey_maillocation UNIQUE (maillocation) -)""", - "INSERT INTO maillocation(maillocation) VALUES ('Maildir')" - ) -for query in queries: - dbc.execute(query) -dbh.commit() - - -# fix table domains (Part I) -dbc.execute('ALTER TABLE domains ADD tid bigint NOT NULL DEFAULT 1') -dbh.commit() -dbc.execute("ALTER TABLE domains ADD CONSTRAINT fkey_domains_tid_transport \ - FOREIGN KEY (tid) REFERENCES transport (tid)") -dbh.commit() - -dbc.execute("SELECT DISTINCT transport from domains \ - WHERE transport != 'dovecot:'") -res = dbc.fetchall() -if len(res): - for trsp in res: - dbc.execute("INSERT INTO transport(transport) VALUES (%s)", trsp[0]) - dbh.commit() - - dbc.execute("SELECT tid, transport FROM transport WHERE tid > 1") - res = dbc.fetchall() - for tid, trsp in res: - dbc.execute("UPDATE domains SET tid = %s WHERE transport = %s", tid, - trsp) - dbh.commit() - - -# fix table users (Part I) -dbc.execute("ALTER TABLE users ADD mid bigint NOT NULL DEFAULT 1") -dbh.commit() -dbc.execute("ALTER TABLE users ADD tid bigint NOT NULL DEFAULT 1") -dbh.commit() -for service in ['smtp', 'pop3', 'imap', 'managesieve']: - dbc.execute( - "ALTER TABLE users ADD %s boolean NOT NULL DEFAULT TRUE" % service) - dbh.commit() -dbc.execute("ALTER TABLE users ADD CONSTRAINT fkey_users_mid_maillocation \ - FOREIGN KEY (mid) REFERENCES maillocation (mid)") -dbh.commit() -dbc.execute("ALTER TABLE users ADD CONSTRAINT fkey_users_tid_transport \ - FOREIGN KEY (tid) REFERENCES transport (tid)") -dbh.commit() - -dbc.execute("SELECT DISTINCT mail FROM users WHERE mail != 'Maildir'") -res = dbc.fetchall() -if len(res): - for mailloc in res: - dbc.execute("INSERT INTO maillocation(maillocation) VALUES (%s)", - mailloc[0]) - dbh.commit() - - dbc.execute("SELECT mid, maillocation FROM maillocation WHERE mid > 1") - res = dbc.fetchall() - for mid, mailloc in res: - dbc.execute("UPDATE users SET mid = %s WHERE mail = %s", mid, - maillocation) - dbh.commit() - -dbc.execute("SELECT uid FROM users WHERE disabled") -res = dbc.fetchall() -if len(res): - for uid in res: - dbc.execute("UPDATE users SET smtp = FALSE, pop3 = FALSE, imap = FALSE,\ - managesieve = FALSE WHERE uid = %s", uid[0]) - dbh.commit() - -dbc.execute("SELECT gid, tid FROM domains") -res = dbc.fetchall() -for gid, tid in res: - dbc.execute("UPDATE users SET tid = %s WHERE gid = %s", tid, gid) -dbh.commit() - - -# Update VIEW postfix_maildir -dbc.execute("""CREATE OR REPLACE VIEW postfix_maildir AS - SELECT local_part || '@' || domains.domainname AS address, - domains.domaindir||'/'||uid||'/'||maillocation.maillocation||'/' AS maildir - FROM users - LEFT JOIN domains USING (gid) - LEFT JOIN maillocation USING (mid)""") -dbh.commit() - -# Replace VIEW dovecot_user -dbc.execute("DROP VIEW dovecot_user") -dbh.commit() -dbc.execute("""CREATE OR REPLACE VIEW dovecot_user AS - SELECT local_part || '@' || domains.domainname AS userid, - uid, gid, domains.domaindir || '/' || uid AS home, - '~/' || maillocation.maillocation AS mail - FROM users - LEFT JOIN domains USING (gid) - LEFT JOIN maillocation USING (mid);""") -dbh.commit() - -# Replace VIEW dovecot_password -dbc.execute("DROP VIEW dovecot_password") -dbh.commit() -dbc.execute("""CREATE OR REPLACE VIEW dovecot_password AS - SELECT local_part || '@' || domains.domainname AS "user", - passwd AS "password", smtp, pop3, imap, managesieve - FROM users - LEFT JOIN domains USING (gid)""") -dbh.commit() - -# fix table users (Part II) -dbc.execute("ALTER TABLE users DROP home") -dbh.commit() -dbc.execute("ALTER TABLE users DROP mail") -dbh.commit() -dbc.execute("ALTER TABLE users DROP disabled") -dbh.commit() - - -# Replace VIEW postfix_transport -dbc.execute("DROP VIEW postfix_transport") -dbh.commit() -dbc.execute("""CREATE OR REPLACE VIEW postfix_transport AS - SELECT local_part || '@' || domains.domainname AS address, - transport.transport - FROM users - LEFT JOIN transport USING (tid) - LEFT JOIN domains USING (gid)""") -dbh.commit() - - -# fix table domains (Part II) -dbc.execute("ALTER TABLE domains DROP transport") -dbh.commit() - - -# fix table alias -dbc.execute('ALTER TABLE alias DROP id') -dbh.commit() -dbc.execute('DROP SEQUENCE alias_id') -dbh.commit() - - -# fix table relocated -dbc.execute('ALTER TABLE relocated DROP id') -dbh.commit() -dbc.execute('DROP SEQUENCE relocated_id') -dbh.commit() - - -# add new VIEW vmm_domain_info -dbc.execute("""CREATE OR REPLACE VIEW vmm_domain_info AS - SELECT gid, domainname, transport, domaindir, count(uid) AS accounts, - aliases - FROM domains - LEFT JOIN transport USING (tid) - LEFT JOIN users USING (gid) - LEFT JOIN vmm_alias_count USING (gid) - GROUP BY gid, domainname, transport, domaindir, aliases""") -dbh.commit() -dbh.close() diff -r 668951708f2f -r 8c5f1eba0ea6 upgrade.sh --- a/upgrade.sh Wed Apr 30 04:05:13 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -#!/bin/bash -# $Id$ -# -# Upgrade script for the Virtual Mail Manager -# run: ./install.sh - -LANG=C -PATH=/bin:/usr/sbin:/usr/bin -INSTALL_OPTS="-g 0 -o 0 -p -v" -PREFIX=/usr/local -PF_CONFDIR=$(postconf -h config_directory) -CFS="smtpd_sender_login_maps transport virtual_mailbox_domains" -DOC_DIR=${PREFIX}/share/doc/vmm -DOCS="ChangeLog COPYING INSTALL README" - -if [ $(id -u) -ne 0 ]; then - echo "Run this script as root." - exit 1 -fi - -python setup.py install --prefix ${PREFIX} -python setup.py clean --all >/dev/null - -for CF in ${CFS} ; do - install -b -m 0640 ${INSTALL_OPTS} pgsql-${CF}.cf ${PF_CONFDIR}/ -done -install -m 0700 ${INSTALL_OPTS} vmm ${PREFIX}/sbin - -[ -d ${DOC_DIR} ] || mkdir -m 0755 -p ${DOC_DIR} -for DOC in ${DOCS}; do - install -m 0644 ${INSTALL_OPTS} ${DOC} ${DOC_DIR} -done - -[ -d ${DOC_DIR}/examples ] || mkdir -m 0755 -p ${DOC_DIR}/examples -install -m 0644 ${INSTALL_OPTS} pgsql-*.cf ${DOC_DIR}/examples -install -m 0644 ${INSTALL_OPTS} vmm.cfg ${DOC_DIR}/examples - -./update_tables_0.3.x-0.4.py -./update_config_0.3.x-0.4.py - -echo -echo "Don't forget to check ${PREFIX}/etc/vmm.cfg" -echo "and modify: ${PF_CONFDIR}/pgsql-*.cf files." -for CF in ${CFS}; do - echo " * ${PF_CONFDIR}/pgsql-${CF}.cf" -done -echo