#!/bin/sh

rm -rf /tmp/ngmp
mkdir /tmp/ngmp
chown -R ngmp:ngmp /tmp/ngmp
rm -rf /usr/local/ngmp/users
mkdir -p /usr/local/ngmp/users/l/u/lukejee@lukejee.net
mkdir -p /usr/local/ngmp/users/l/u/lukejee@lukejee.net/files
mkdir -p /usr/local/ngmp/users/l/u/lukejee@lukejee.net/fax
mkdir -p /usr/local/ngmp/users/l/u/lukejee@lukejee.net/mail
mkdir -p /usr/local/ngmp/users/l/u/lukejee@lukejee.net/mail/tmp
mkdir -p /usr/local/ngmp/users/l/u/lukejee@lukejee.net/mail/cur
mkdir -p /usr/local/ngmp/users/l/u/lukejee@lukejee.net/mail/new

mkdir -p /usr/local/ngmp/users/d/e/demo@lukejee.net
mkdir -p /usr/local/ngmp/users/d/e/demo@lukejee.net/files
mkdir -p /usr/local/ngmp/users/d/e/demo@lukejee.net/fax
mkdir -p /usr/local/ngmp/users/d/e/demo@lukejee.net/mail
mkdir -p /usr/local/ngmp/users/d/e/demo@lukejee.net/mail/tmp
mkdir -p /usr/local/ngmp/users/d/e/demo@lukejee.net/mail/cur
mkdir -p /usr/local/ngmp/users/d/e/demo@lukejee.net/mail/new

mkdir -p /usr/local/ngmp/users/l/u/lukejee@ec-mail.net
mkdir -p /usr/local/ngmp/users/l/u/lukejee@ec-mail.net/files
mkdir -p /usr/local/ngmp/users/l/u/lukejee@ec-mail.net/fax
mkdir -p /usr/local/ngmp/users/l/u/lukejee@ec-mail.net/mail
mkdir -p /usr/local/ngmp/users/l/u/lukejee@ec-mail.net/mail/tmp
mkdir -p /usr/local/ngmp/users/l/u/lukejee@ec-mail.net/mail/cur
mkdir -p /usr/local/ngmp/users/l/u/lukejee@ec-mail.net/mail/new

mkdir -p /usr/local/ngmp/users/d/e/demo@ec-mail.net
mkdir -p /usr/local/ngmp/users/d/e/demo@ec-mail.net/files
mkdir -p /usr/local/ngmp/users/d/e/demo@ec-mail.net/fax
mkdir -p /usr/local/ngmp/users/d/e/demo@ec-mail.net/mail
mkdir -p /usr/local/ngmp/users/d/e/demo@ec-mail.net/mail/tmp
mkdir -p /usr/local/ngmp/users/d/e/demo@ec-mail.net/mail/cur
mkdir -p /usr/local/ngmp/users/d/e/demo@ec-mail.net/mail/new

mkdir -p /usr/local/ngmp/users/l/u/lukejee@domain.com
mkdir -p /usr/local/ngmp/users/l/u/lukejee@domain.com/files
mkdir -p /usr/local/ngmp/users/l/u/lukejee@domain.com/fax
mkdir -p /usr/local/ngmp/users/l/u/lukejee@domain.com/mail
mkdir -p /usr/local/ngmp/users/l/u/lukejee@domain.com/mail/tmp
mkdir -p /usr/local/ngmp/users/l/u/lukejee@domain.com/mail/cur
mkdir -p /usr/local/ngmp/users/l/u/lukejee@domain.com/mail/new

mkdir -p /usr/local/ngmp/users/d/e/demo@domain.com
mkdir -p /usr/local/ngmp/users/d/e/demo@domain.com/files
mkdir -p /usr/local/ngmp/users/d/e/demo@domain.com/fax
mkdir -p /usr/local/ngmp/users/d/e/demo@domain.com/mail
mkdir -p /usr/local/ngmp/users/d/e/demo@domain.com/mail/tmp
mkdir -p /usr/local/ngmp/users/d/e/demo@domain.com/mail/cur
mkdir -p /usr/local/ngmp/users/d/e/demo@domain.com/mail/new

chown -R ngmp:ngmp /usr/local/ngmp/users

/usr/local/etc/rc.d/postgresql restart
su pgsql -c 'dropdb ngmp'
su pgsql -c 'dropuser ngmp'
su pgsql -c 'createuser -SDR ngmp'
su pgsql -c 'createdb -O ngmp ngmp'
su pgsql -c 'createlang plpgsql ngmp'
psql -U ngmp ngmp < ngmp.sql
psql -U ngmp ngmp < testdata.sql
