[695] | 1 | -- |
---|
| 2 | -- PyKota - Print Quotas for CUPS |
---|
| 3 | -- |
---|
| 4 | -- (c) 2003 Jerome Alet <alet@librelogiciel.com> |
---|
| 5 | -- You're welcome to redistribute this software under the |
---|
| 6 | -- terms of the GNU General Public Licence version 2.0 |
---|
| 7 | -- or, at your option, any higher version. |
---|
| 8 | -- |
---|
| 9 | -- You can read the complete GNU GPL in the file COPYING |
---|
| 10 | -- which should come along with this software, or visit |
---|
| 11 | -- the Free Software Foundation's WEB site http://www.fsf.org |
---|
| 12 | -- |
---|
| 13 | -- $Id$ |
---|
| 14 | -- |
---|
| 15 | -- $Log$ |
---|
| 16 | -- Revision 1.1 2003/02/05 21:28:17 jalet |
---|
| 17 | -- Initial import into CVS |
---|
| 18 | -- |
---|
| 19 | -- |
---|
| 20 | -- |
---|
| 21 | |
---|
| 22 | -- |
---|
| 23 | -- PyKota Database creation script for PostgreSQL |
---|
| 24 | -- |
---|
| 25 | -- Launch this as PostgreSQL administrator with \i |
---|
| 26 | -- |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | -- |
---|
| 30 | -- Create the print quota database |
---|
| 31 | -- |
---|
| 32 | CREATE DATABASE pykota; |
---|
| 33 | |
---|
| 34 | -- |
---|
| 35 | -- Create the print quota database users |
---|
| 36 | -- |
---|
| 37 | CREATE USER pykotauser; |
---|
| 38 | CREATE USER pykotaadmin; |
---|
| 39 | |
---|
| 40 | -- |
---|
| 41 | -- Now connect to the new database |
---|
| 42 | -- |
---|
| 43 | \connect pykota |
---|
| 44 | |
---|
| 45 | -- |
---|
| 46 | -- Create the users table |
---|
| 47 | -- |
---|
| 48 | CREATE TABLE users(id SERIAL PRIMARY KEY NOT NULL, |
---|
| 49 | username TEXT UNIQUE NOT NULL); |
---|
| 50 | |
---|
| 51 | -- |
---|
| 52 | -- Create the groups table |
---|
| 53 | -- |
---|
| 54 | CREATE TABLE groups(id SERIAL PRIMARY KEY NOT NULL, |
---|
| 55 | groupname TEXT UNIQUE NOT NULL); |
---|
| 56 | |
---|
| 57 | -- |
---|
| 58 | -- Create the printers table |
---|
| 59 | -- |
---|
| 60 | CREATE TABLE printers(id SERIAL PRIMARY KEY NOT NULL, |
---|
| 61 | printername TEXT UNIQUE NOT NULL, |
---|
| 62 | lastusername TEXT, |
---|
| 63 | pagecounter INT4); |
---|
| 64 | |
---|
| 65 | -- |
---|
| 66 | -- Create the print quota table for users |
---|
| 67 | -- |
---|
| 68 | CREATE TABLE userpquota(id SERIAL PRIMARY KEY NOT NULL, |
---|
| 69 | userid INT4 REFERENCES users(id), |
---|
| 70 | printerid INT4 REFERENCES printers(id), |
---|
| 71 | pagecounter INT4 DEFAULT 0, |
---|
| 72 | softlimit INT4, |
---|
| 73 | hardlimit INT4, |
---|
| 74 | datelimit DATETIME); |
---|
| 75 | |
---|
| 76 | -- |
---|
| 77 | -- Create the print quota table for groups |
---|
| 78 | -- |
---|
| 79 | CREATE TABLE grouppquota(id SERIAL PRIMARY KEY NOT NULL, |
---|
| 80 | groupid INT4 REFERENCES groups(id), |
---|
| 81 | printerid INT4 REFERENCES printers(id), |
---|
| 82 | pagecounter INT4 DEFAULT 0, |
---|
| 83 | softlimit INT4, |
---|
| 84 | hardlimit INT4, |
---|
| 85 | datelimit DATETIME); |
---|
| 86 | |
---|
| 87 | -- |
---|
| 88 | -- Set some ACLs |
---|
| 89 | -- |
---|
| 90 | REVOKE ALL ON users, groups, printers, userpquota, grouppquota FROM public; |
---|
| 91 | GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON users, groups, printers, userpquota, grouppquota TO pykotaadmin; |
---|
| 92 | GRANT SELECT, UPDATE ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq TO pykotaadmin; |
---|
| 93 | GRANT SELECT, UPDATE ON printers, userpquota, grouppquota TO pykotauser; |
---|
| 94 | GRANT SELECT ON users, groups TO pykotauser; |
---|