sogo/OGoContentStore/sql/acls.sh
Wolfgang Sourdeau 17a4faa5f6 Monotone-Parent: 21d3c266f32d058a6d1133567ac844486a87d2b3
Monotone-Revision: 293e773bade06f97acb90961a13323cdf0e8bcd7

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2006-12-15T22:17:25
Monotone-Branch: ca.inverse.sogo
2006-12-15 22:17:25 +00:00

66 lines
1.7 KiB
Bash
Executable file

#!/bin/bash
#
# Usage: generate-folderinfo-sql-for-users user1 [user2] [user3] [...]
#
DB_USER="sogo"
DB_PASS="sogo"
DB_HOST="192.168.0.4"
DB_PORT="5432"
DB_NAME="sogo"
TIMEZONE="Canada/Eastern"
while [ "$1" != "" ]; do
USER_ID=$1
USER_TABLE=`echo $USER_ID | tr -s [:punct:] _`
cat << EOF
--
-- (C) 2004 SKYRIX Software AG
--
-- TODO:
-- add a unique constraints on path
UPDATE SOGo_folder_info
SET c_acl_location = 'http://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME}/SOGo_${USER_TABLE}_acl'
WHERE c_folder_type = 'Container'
AND c_path2 = '${USER_ID}';
UPDATE SOGo_folder_info
SET c_acl_location = 'http://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME}/SOGo_${USER_TABLE}_contacts_acl'
WHERE c_folder_type = 'Contact'
AND c_path2 = '${USER_ID}';
UPDATE SOGo_folder_info
SET c_acl_location = 'http://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME}/SOGo_${USER_TABLE}_privcal_acl'
WHERE c_folder_type = 'Appointment'
AND c_path2 = '${USER_ID}';
DROP TABLE SOGo_${USER_TABLE}_acls;
DROP TABLE SOGo_${USER_TABLE}_privcal_acls;
DROP TABLE SOGo_${USER_TABLE}_contacts_acls;
DROP TABLE SOGo_${USER_TABLE}_acl;
DROP TABLE SOGo_${USER_TABLE}_privcal_acl;
DROP TABLE SOGo_${USER_TABLE}_contacts_acl;
CREATE TABLE SOGo_${USER_TABLE}_acl (
c_uid VARCHAR(256) NOT NULL,
c_object VARCHAR(256) NOT NULL,
c_role VARCHAR(80) NOT NULL
);
CREATE TABLE SOGo_${USER_TABLE}_privcal_acl (
c_uid VARCHAR(256) NOT NULL,
c_object VARCHAR(256) NOT NULL,
c_role VARCHAR(80) NOT NULL
);
CREATE TABLE SOGo_${USER_TABLE}_contacts_acl (
c_uid VARCHAR(256) NOT NULL,
c_object VARCHAR(256) NOT NULL,
c_role VARCHAR(80) NOT NULL
);
EOF
shift
done