[695] | 1 | -- |
---|
| 2 | -- PyKota - Print Quotas for CUPS |
---|
| 3 | -- |
---|
| 4 | -- (c) 2003 Jerome Alet <alet@librelogiciel.com> |
---|
[873] | 5 | -- This program is free software; you can redistribute it and/or modify |
---|
| 6 | -- it under the terms of the GNU General Public License as published by |
---|
| 7 | -- the Free Software Foundation; either version 2 of the License, or |
---|
| 8 | -- (at your option) any later version. |
---|
[695] | 9 | -- |
---|
[873] | 10 | -- This program is distributed in the hope that it will be useful, |
---|
| 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 13 | -- GNU General Public License for more details. |
---|
| 14 | -- |
---|
| 15 | -- You should have received a copy of the GNU General Public License |
---|
| 16 | -- along with this program; if not, write to the Free Software |
---|
| 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
---|
[695] | 18 | -- |
---|
| 19 | -- $Id$ |
---|
| 20 | -- |
---|
| 21 | -- $Log$ |
---|
[873] | 22 | -- Revision 1.6 2003/03/29 13:45:27 jalet |
---|
| 23 | -- GPL paragraphs were incorrectly (from memory) copied into the sources. |
---|
| 24 | -- Two README files were added. |
---|
| 25 | -- Upgrade script for PostgreSQL pre 1.01 schema was added. |
---|
| 26 | -- |
---|
[849] | 27 | -- Revision 1.5 2003/03/12 19:06:08 jalet |
---|
| 28 | -- Initial support for groups added. |
---|
| 29 | -- |
---|
[812] | 30 | -- Revision 1.4 2003/02/27 08:40:14 jalet |
---|
| 31 | -- DATETIME is not supported anymore in PostgreSQL 7.3 it seems, but |
---|
| 32 | -- TIMESTAMP is. |
---|
| 33 | -- |
---|
[811] | 34 | -- Revision 1.3 2003/02/26 20:34:22 jalet |
---|
| 35 | -- Default value for printer page counter set to 0 |
---|
| 36 | -- |
---|
[765] | 37 | -- Revision 1.2 2003/02/08 22:12:09 jalet |
---|
| 38 | -- Life time counter for users and groups added. |
---|
| 39 | -- |
---|
[695] | 40 | -- Revision 1.1 2003/02/05 21:28:17 jalet |
---|
| 41 | -- Initial import into CVS |
---|
| 42 | -- |
---|
| 43 | -- |
---|
| 44 | -- |
---|
| 45 | |
---|
| 46 | -- |
---|
| 47 | -- PyKota Database creation script for PostgreSQL |
---|
| 48 | -- |
---|
| 49 | -- Launch this as PostgreSQL administrator with \i |
---|
| 50 | -- |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | -- |
---|
| 54 | -- Create the print quota database |
---|
| 55 | -- |
---|
| 56 | CREATE DATABASE pykota; |
---|
| 57 | |
---|
| 58 | -- |
---|
| 59 | -- Create the print quota database users |
---|
| 60 | -- |
---|
| 61 | CREATE USER pykotauser; |
---|
| 62 | CREATE USER pykotaadmin; |
---|
| 63 | |
---|
| 64 | -- |
---|
| 65 | -- Now connect to the new database |
---|
| 66 | -- |
---|
| 67 | \connect pykota |
---|
| 68 | |
---|
| 69 | -- |
---|
| 70 | -- Create the users table |
---|
| 71 | -- |
---|
| 72 | CREATE TABLE users(id SERIAL PRIMARY KEY NOT NULL, |
---|
| 73 | username TEXT UNIQUE NOT NULL); |
---|
| 74 | |
---|
| 75 | -- |
---|
| 76 | -- Create the groups table |
---|
| 77 | -- |
---|
| 78 | CREATE TABLE groups(id SERIAL PRIMARY KEY NOT NULL, |
---|
| 79 | groupname TEXT UNIQUE NOT NULL); |
---|
| 80 | |
---|
| 81 | -- |
---|
| 82 | -- Create the printers table |
---|
| 83 | -- |
---|
| 84 | CREATE TABLE printers(id SERIAL PRIMARY KEY NOT NULL, |
---|
| 85 | printername TEXT UNIQUE NOT NULL, |
---|
| 86 | lastusername TEXT, |
---|
[811] | 87 | pagecounter INT4 DEFAULT 0); |
---|
[695] | 88 | |
---|
| 89 | -- |
---|
| 90 | -- Create the print quota table for users |
---|
| 91 | -- |
---|
| 92 | CREATE TABLE userpquota(id SERIAL PRIMARY KEY NOT NULL, |
---|
| 93 | userid INT4 REFERENCES users(id), |
---|
| 94 | printerid INT4 REFERENCES printers(id), |
---|
[765] | 95 | lifepagecounter INT4 DEFAULT 0, |
---|
[695] | 96 | pagecounter INT4 DEFAULT 0, |
---|
| 97 | softlimit INT4, |
---|
| 98 | hardlimit INT4, |
---|
[812] | 99 | datelimit TIMESTAMP); |
---|
[695] | 100 | |
---|
| 101 | -- |
---|
| 102 | -- Create the print quota table for groups |
---|
| 103 | -- |
---|
| 104 | CREATE TABLE grouppquota(id SERIAL PRIMARY KEY NOT NULL, |
---|
| 105 | groupid INT4 REFERENCES groups(id), |
---|
| 106 | printerid INT4 REFERENCES printers(id), |
---|
| 107 | softlimit INT4, |
---|
| 108 | hardlimit INT4, |
---|
[812] | 109 | datelimit TIMESTAMP); |
---|
[695] | 110 | |
---|
[849] | 111 | -- |
---|
| 112 | -- Create the groups/members relationship |
---|
| 113 | -- |
---|
| 114 | CREATE TABLE groupsmembers(groupid INT4 REFERENCES groups(id), |
---|
| 115 | userid INT4 REFERENCES users(id), |
---|
| 116 | PRIMARY KEY (groupid, userid)); |
---|
| 117 | |
---|
[695] | 118 | -- |
---|
| 119 | -- Set some ACLs |
---|
| 120 | -- |
---|
[849] | 121 | REVOKE ALL ON users, groups, printers, userpquota, grouppquota, groupsmembers FROM public; |
---|
| 122 | GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON users, groups, printers, userpquota, grouppquota, groupsmembers TO pykotaadmin; |
---|
[695] | 123 | GRANT SELECT, UPDATE ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq TO pykotaadmin; |
---|
| 124 | GRANT SELECT, UPDATE ON printers, userpquota, grouppquota TO pykotauser; |
---|
[849] | 125 | GRANT SELECT ON users, groups, groupsmembers TO pykotauser; |
---|