Changeset 3413 for pykota/trunk/initscripts
- Timestamp:
- 09/27/08 22:02:37 (16 years ago)
- Location:
- pykota/trunk/initscripts
- Files:
-
- 20 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/initscripts/ldap/pykota-sample.ldif
r3280 r3413 3 3 # 4 4 # YOU CAN USE IT TO CREATE AN INITIAL LDAP TREE WITH PYKOTA SUPPORT. 5 # 5 # 6 6 # ITS STRUCTURE IS AN EXAMPLE : YOU CAN USE WHATEVER STRUCTURE YOU WANT, 7 7 # PROVIDED YOU PUT CORRECT CONFIGURATION PARAMETERS IN /etc/pykota/pykota.conf 8 # 8 # 9 9 # 10 10 # (c) 2003, 2004, 2005, 2006, 2007, 2008 Jerome Alet <alet@librelogiciel.com> … … 13 13 # the Free Software Foundation, either version 3 of the License, or 14 14 # (at your option) any later version. 15 # 15 # 16 16 # This program is distributed in the hope that it will be useful, 17 17 # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 19 # GNU General Public License for more details. 20 # 20 # 21 21 # You should have received a copy of the GNU General Public License 22 22 # along with this program. If not, see <http://www.gnu.org/licenses/>. … … 24 24 # $Id$ 25 25 # 26 26 27 27 # The encrypted password below in clear text is : BlfUPg7t 28 28 dn: cn=pykotaadmin,dc=example,dc=com -
pykota/trunk/initscripts/ldap/pykota.schema
r3280 r3413 10 10 # the Free Software Foundation, either version 3 of the License, or 11 11 # (at your option) any later version. 12 # 12 # 13 13 # This program is distributed in the hope that it will be useful, 14 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 16 # GNU General Public License for more details. 17 # 17 # 18 18 # You should have received a copy of the GNU General Public License 19 19 # along with this program. If not, see <http://www.gnu.org/licenses/>. … … 31 31 # 16868.1.2.x => classes 32 32 # 33 # Contributors : Leif Johansson - Stockholm University 34 # 35 36 # 33 # Contributors : Leif Johansson - Stockholm University 34 # 35 36 # 37 37 # PyKota Attributes Types 38 38 # … … 73 73 EQUALITY caseIgnoreIA5Match 74 74 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 75 76 # pykotaHardLimit 75 76 # pykotaHardLimit 77 77 attributetype ( 1.3.6.1.4.1.16868.1.1.7 NAME 'pykotaHardLimit' 78 78 DESC 'Hard limit in maximal number of pages' … … 121 121 EQUALITY caseExactIA5Match 122 122 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 123 124 # pykotaPrinterName 123 124 # pykotaPrinterName 125 125 attributetype ( 1.3.6.1.4.1.16868.1.1.15 NAME 'pykotaPrinterName' 126 126 DESC 'PyKota printer name as received from the printing subsystem' … … 128 128 SUBSTR caseExactIA5SubstringsMatch 129 129 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 130 131 # pykotaUserName 130 131 # pykotaUserName 132 132 attributetype ( 1.3.6.1.4.1.16868.1.1.16 NAME 'pykotaUserName' 133 133 DESC 'PyKota user name' … … 135 135 SUBSTR caseExactIA5SubstringsMatch 136 136 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 137 138 # pykotaGroupName 137 138 # pykotaGroupName 139 139 attributetype ( 1.3.6.1.4.1.16868.1.1.17 NAME 'pykotaGroupName' 140 140 DESC 'PyKota group name' … … 142 142 SUBSTR caseExactIA5SubstringsMatch 143 143 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 144 145 # pykotaLastJobIdent 144 145 # pykotaLastJobIdent 146 146 attributetype ( 1.3.6.1.4.1.16868.1.1.18 NAME 'pykotaLastJobIdent' 147 147 DESC 'Identifies the last job in the history' 148 148 EQUALITY caseExactIA5Match 149 149 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 150 151 # pykotaFileName 150 151 # pykotaFileName 152 152 attributetype ( 1.3.6.1.4.1.16868.1.1.19 NAME 'pykotaFileName' 153 153 DESC 'Print job filename' … … 155 155 SUBSTR caseExactSubstringsMatch 156 156 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) 157 158 # pykotaTitle 157 158 # pykotaTitle 159 159 attributetype ( 1.3.6.1.4.1.16868.1.1.20 NAME 'pykotaTitle' 160 160 DESC 'Print job title' … … 162 162 SUBSTR caseIgnoreSubstringsMatch 163 163 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) 164 164 165 165 # pykotaCopies 166 166 attributetype ( 1.3.6.1.4.1.16868.1.1.21 NAME 'pykotaCopies' … … 168 168 EQUALITY integerMatch 169 169 SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) 170 171 # pykotaOptions 170 171 # pykotaOptions 172 172 attributetype ( 1.3.6.1.4.1.16868.1.1.22 NAME 'pykotaOptions' 173 173 DESC 'Print job options' … … 175 175 SUBSTR caseIgnoreSubstringsMatch 176 176 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) 177 177 178 178 # pykotaJobPrice 179 179 attributetype ( 1.3.6.1.4.1.16868.1.1.23 NAME 'pykotaJobPrice' … … 188 188 SUBSTR caseIgnoreSubstringsMatch 189 189 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) 190 190 191 191 # pykotaJobSizeBytes 192 192 attributetype ( 1.3.6.1.4.1.16868.1.1.25 NAME 'pykotaJobSizeBytes' … … 200 200 EQUALITY caseExactIA5Match 201 201 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) 202 202 203 203 # pykotaOverCharge 204 204 attributetype ( 1.3.6.1.4.1.16868.1.1.27 NAME 'pykotaOverCharge' … … 206 206 EQUALITY caseIgnoreIA5Match 207 207 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 208 208 209 209 # pykotaWarnCount 210 210 attributetype ( 1.3.6.1.4.1.16868.1.1.28 NAME 'pykotaWarnCount' … … 212 212 EQUALITY integerMatch 213 213 SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) 214 215 # pykotaMD5Sum 214 215 # pykotaMD5Sum 216 216 attributetype ( 1.3.6.1.4.1.16868.1.1.29 NAME 'pykotaMD5Sum' 217 217 DESC 'MD5 Sum of the job datas' … … 219 219 SUBSTR caseExactIA5SubstringsMatch 220 220 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 221 222 # pykotaPages 221 222 # pykotaPages 223 223 attributetype ( 1.3.6.1.4.1.16868.1.1.30 NAME 'pykotaPages' 224 224 DESC 'Descriptor for each page settings in the history' … … 226 226 SUBSTR caseExactIA5SubstringsMatch 227 227 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26) 228 228 229 229 # pykotaPrinterCoefficient 230 230 attributetype ( 1.3.6.1.4.1.16868.1.1.31 NAME 'pykotaPrinterCoefficient' … … 239 239 SUBSTR caseIgnoreSubstringsMatch 240 240 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) 241 241 242 242 # pykotaPrecomputedJobSize 243 243 attributetype ( 1.3.6.1.4.1.16868.1.1.33 NAME 'pykotaPrecomputedJobSize' … … 251 251 EQUALITY caseIgnoreIA5Match 252 252 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 253 253 254 254 # pykotaMaxJobSize 255 255 attributetype ( 1.3.6.1.4.1.16868.1.1.35 NAME 'pykotaMaxJobSize' … … 264 264 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 265 265 266 # 266 # 267 267 # PyKota Object Classes 268 268 # … … 273 273 MUST ( uid ) 274 274 MAY ( pykotaUserName $ pykotaLimitBy $ mail $ description ) ) 275 276 # pykotaGroup 275 276 # pykotaGroup 277 277 objectclass ( 1.3.6.1.4.1.16868.1.2.2 NAME 'pykotaGroup' SUP top AUXILIARY 278 278 DESC 'PyKota Auxiliary Group' 279 279 MUST ( cn ) 280 280 MAY ( pykotaGroupName $ pykotaLimitBy $ memberUid $ uniqueMember $ member $ description ) ) 281 282 # pykotaPrinter 281 282 # pykotaPrinter 283 283 objectclass ( 1.3.6.1.4.1.16868.1.2.3 NAME 'pykotaPrinter' SUP top AUXILIARY 284 284 DESC 'PyKota Printer' 285 285 MUST ( cn ) 286 286 MAY ( pykotaMaxJobSize $ pykotaPassThrough $ description $ pykotaPrinterName $ pykotaPricePerPage $ pykotaPricePerJob $ pykotaPrinterCoefficient $ uniqueMember ) ) 287 288 # pykotaUserPQuota 287 288 # pykotaUserPQuota 289 289 objectclass ( 1.3.6.1.4.1.16868.1.2.4 NAME 'pykotaUserPQuota' SUP top AUXILIARY 290 290 DESC 'PyKota User Quota on a Printer' 291 291 MUST ( cn $ pykotaUserName $ pykotaPrinterName ) 292 292 MAY ( pykotaMaxJobSize $ pykotaPageCounter $ pykotaLifePageCounter $ pykotaSoftLimit $ pykotaHardLimit $ pykotaDateLimit $ pykotaWarnCount ) ) 293 294 # pykotaGroupPQuota 293 294 # pykotaGroupPQuota 295 295 objectclass ( 1.3.6.1.4.1.16868.1.2.5 NAME 'pykotaGroupPQuota' SUP top AUXILIARY 296 296 DESC 'PyKota Group Quota on a Printer' 297 297 MUST ( cn $ pykotaGroupName $ pykotaPrinterName ) 298 298 MAY ( pykotaMaxJobSize $ pykotaSoftLimit $ pykotaHardLimit $ pykotaDateLimit ) ) 299 300 # pykotaJob 299 300 # pykotaJob 301 301 objectclass ( 1.3.6.1.4.1.16868.1.2.6 NAME 'pykotaJob' SUP top AUXILIARY 302 302 DESC 'An entry in the job history for a printer' 303 303 MUST ( cn $ pykotaUserName $ pykotaPrinterName $ pykotaJobId ) 304 304 MAY ( pykotaPrecomputedJobPrice $ pykotaPrecomputedJobSize $ pykotaBillingCode $ pykotaPrinterPageCounter $ pykotaJobSize $ pykotaAction $ pykotaJobPrice $ pykotaFileName $ pykotaTitle $ pykotaCopies $ pykotaOptions $ pykotaHostName $ pykotaJobSizeBytes $ pykotaMD5Sum $ pykotaPages ) ) 305 305 306 306 # pykotaAccountBalance 307 307 objectclass ( 1.3.6.1.4.1.16868.1.2.7 NAME 'pykotaAccountBalance' SUP top AUXILIARY 308 308 DESC 'PyKota User account balance' 309 309 MAY ( pykotaUserName $ pykotaBalance $ pykotaLifeTimePaid $ pykotaOverCharge $ pykotaPayments ) ) 310 311 # pykotaLastJob 310 311 # pykotaLastJob 312 312 objectclass ( 1.3.6.1.4.1.16868.1.2.8 NAME 'pykotaLastJob' SUP top AUXILIARY 313 313 DESC 'Last job information for a printer' 314 314 MUST ( pykotaLastJobIdent ) 315 MAY ( pykotaPrinterName ) ) 316 315 MAY ( pykotaPrinterName ) ) 316 317 317 # pykotaBilling 318 318 objectclass ( 1.3.6.1.4.1.16868.1.2.10 NAME 'pykotaBilling' SUP top AUXILIARY … … 320 320 MUST ( cn $ pykotaBillingCode ) 321 321 MAY ( pykotaPageCounter $ pykotaBalance $ description ) ) 322 323 # pykotaObject - Use it if you have to 322 323 # pykotaObject - Use it if you have to 324 324 objectclass ( 1.3.6.1.4.1.16868.1.2.9 NAME 'pykotaObject' SUP top STRUCTURAL 325 325 DESC 'PyKota Object' 326 326 MUST ( cn ) ) 327 328 327 328 -
pykota/trunk/initscripts/ldap/pykota-schema-sunds.ldif
r3351 r3413 20 20 # 16868.1.2.x => classes 21 21 # 22 # Contributors : Leif Johansson - Stockholm University 22 # Contributors : Leif Johansson - Stockholm University 23 23 # 24 24 dn: cn=schema … … 295 295 DESC 'Last job information for a printer' 296 296 MUST ( pykotaLastJobIdent ) 297 MAY ( pykotaPrinterName ) ) 297 MAY ( pykotaPrinterName ) ) 298 298 - 299 299 add: objectClasses -
pykota/trunk/initscripts/ldap/pykota-sunds-indexes.ldif
r3351 r3413 7 7 # the Free Software Foundation, either version 3 of the License, or 8 8 # (at your option) any later version. 9 # 9 # 10 10 # This program is distributed in the hope that it will be useful, 11 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 # GNU General Public License for more details. 14 # 14 # 15 15 # You should have received a copy of the GNU General Public License 16 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. -
pykota/trunk/initscripts/ldap/README.ldap
r3343 r3413 22 22 =============== 23 23 24 OpenLDAP : 24 OpenLDAP : 25 25 ---------- 26 26 27 The pykota.schema file can be used to modify an existing OpenLDAP 28 directory to add the necessary object classes and attributes for 27 The pykota.schema file can be used to modify an existing OpenLDAP 28 directory to add the necessary object classes and attributes for 29 29 use with PyKota. 30 30 31 31 Include it in your LDAP server's configuration. 32 32 For example, with OpenLDAP under Debian : 33 33 34 34 $ cp pykota.schema /etc/ldap/schema 35 35 (no need to do this if you install from PyKota's Debian package) 36 36 37 NB: With OpenLDAP under Red Hat-based distros, where /etc/ldap is 38 referenced, substitute /etc/openldap. e.g. 37 NB: With OpenLDAP under Red Hat-based distros, where /etc/ldap is 38 referenced, substitute /etc/openldap. e.g. 39 39 40 40 $ cp pykota.schema /etc/openldap/schema 41 42 Then edit /etc/ldap/slapd.conf and add a line to 41 42 Then edit /etc/ldap/slapd.conf and add a line to 43 43 include the PyKota schema. You should have something 44 44 like : 45 45 46 46 # Schema and objectClass definitions 47 47 include /etc/ldap/schema/core.schema … … 50 50 include /etc/ldap/schema/inetorgperson.schema 51 51 include /etc/ldap/schema/pykota.schema 52 53 While this is not mandatory, you may want to create 52 53 While this is not mandatory, you may want to create 54 54 some indexes to speed things up a bit : 55 55 56 56 You should already have these : 57 57 58 58 index objectClass eq 59 59 index cn pres,eq,sub 60 60 index uid pres,eq,sub 61 62 But we recommend that you add these : 63 61 62 But we recommend that you add these : 63 64 64 index pykotaUserName pres,eq,sub 65 65 index pykotaGroupName pres,eq,sub … … 67 67 index pykotaBillingCode pres,eq,sub 68 68 index pykotaLastJobIdent eq 69 69 70 70 Now you must ensure that the DNs PyKota will use to bind to 71 71 your OpenLDAP server don't have search queries size limits, 72 72 which gives for example (OpenLDAP 2.1.x or above) : 73 73 74 74 limits dn="cn=pykotaadmin,dc=example,dc=com" size.soft=-1 size.hard=soft 75 75 limits dn="cn=pykotauser,dc=example,dc=com" size.soft=-1 size.hard=soft 76 76 77 77 Where pykotaadmin and pykotauser are the usernames used to bind to your 78 OpenLDAP server within PyKota, respectively in complete ReadWrite mode 78 OpenLDAP server within PyKota, respectively in complete ReadWrite mode 79 79 (as set in pykotadmin.conf) and in ReadOnly mode (pykota.conf). 80 80 81 81 NB : YOU have to define the ACLs necessary for user pykotaadmin to 82 82 have unlimited Read+Write access to your LDAP tree, and for user … … 87 87 this is up to you to decide. An example giving full write access 88 88 to the pykotaadmin user is : 89 90 access to dn.subtree="ou=PyKota,dc=example,dc=com" 91 by dn="cn=pykotaadmin,dc=example,dc=com" write 92 93 access to dn.subtree="ou=People,dc=example,dc=com" 94 by dn="cn=pykotaadmin,dc=example,dc=com" write 95 96 access to dn.subtree="ou=Groups,dc=example,dc=com" 97 by dn="cn=pykotaadmin,dc=example,dc=com" write 98 89 90 access to dn.subtree="ou=PyKota,dc=example,dc=com" 91 by dn="cn=pykotaadmin,dc=example,dc=com" write 92 93 access to dn.subtree="ou=People,dc=example,dc=com" 94 by dn="cn=pykotaadmin,dc=example,dc=com" write 95 96 access to dn.subtree="ou=Groups,dc=example,dc=com" 97 by dn="cn=pykotaadmin,dc=example,dc=com" write 98 99 99 Please adapt this to your own needs and configuration. 100 101 Now, stop the OpenLDAP server : 102 100 101 Now, stop the OpenLDAP server : 102 103 103 $ /etc/init.d/slapd stop 104 105 Generate the index files : 106 104 105 Generate the index files : 106 107 107 $ slapindex 108 109 And finally restart the OpenLDAP server : 110 108 109 And finally restart the OpenLDAP server : 110 111 111 $ /etc/init.d/slapd start 112 112 113 NB: On Red Hat-based distros, use '/sbin/service ldap stop' and 113 NB: On Red Hat-based distros, use '/sbin/service ldap stop' and 114 114 '/sbin/service ldap start' instead. 115 116 Sun Directory Server : 115 116 Sun Directory Server : 117 117 ---------------------- 118 118 119 119 See README.sunds 120 121 Initial datas : 120 121 Initial datas : 122 122 =============== 123 124 You can use the pykota-sample.ldif file to initialize an LDAP tree 123 124 You can use the pykota-sample.ldif file to initialize an LDAP tree 125 125 for PyKota, if you want. 126 126 127 127 The structure used in this file is NOT mandatory ! 128 128 Provided you put correct parameters into /etc/pykota/pykota.conf, 129 129 you can structure your LDAP directory the way you want. 130 131 To use an LDAP directory as the Quota Storage, just modify 130 131 To use an LDAP directory as the Quota Storage, just modify 132 132 ~pykota/pykota.conf to make it contain lines similar to the LDAP 133 133 related ones in conf/pykota.conf.sample, but adapted to your 134 134 own configuration. Also de-activate the PostgreSQL-related lines. 135 Don't forget to adapt ~pykota/pykotadmin.conf as well. 135 Don't forget to adapt ~pykota/pykotadmin.conf as well. 136 136 ============================================================ -
pykota/trunk/initscripts/ldap/README.sunds
r3351 r3413 7 7 # the Free Software Foundation, either version 3 of the License, or 8 8 # (at your option) any later version. 9 # 9 # 10 10 # This program is distributed in the hope that it will be useful, 11 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 # GNU General Public License for more details. 14 # 14 # 15 15 # You should have received a copy of the GNU General Public License 16 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. … … 54 54 55 55 % ldapmodify -a -h ldap.domain.com -D "cn=Directory Manager" -f pykota-sunds-indexes.ldif 56 56 57 57 By default configuration settings are NOT replicated in a 58 58 replication environment so the following indexes must be … … 95 95 will encrypt the userPassword entry so you may wish to leave it as 96 96 plain text when creating the pykotaadmin and pykotauser entries. 97 97 98 98 If a Password Policy is being enforced it would be advisable exclude 99 99 both the pykotauser and pykotaadmin from that policy. This is especially … … 106 106 Access Control Instructions (ACI) : 107 107 ----------------------------------- 108 108 109 109 The provided ACI's must not be blindly added using ldapmodify or 110 110 ldapadd, if you do so you will clobber any existing ACI's for a -
pykota/trunk/initscripts/mysql/pykota-mysql.sql
r3279 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 35 35 -- Create the print quota database users 36 36 -- NOTE: Change the "IDENTIFIED BY" strings to the passwords you would like. 37 -- 37 -- 38 38 GRANT USAGE ON *.* TO 'pykotauser'@'localhost' IDENTIFIED BY 'readonlypw'; 39 39 GRANT USAGE ON *.* TO 'pykotaadmin'@'localhost' IDENTIFIED BY 'readwritepw'; 40 40 41 -- 41 -- 42 42 -- If necessary activate the lines below (and keep the preceding ones 43 43 -- activated at the same time) … … 46 46 -- GRANT USAGE ON *.* TO 'pykotaadmin'@'%' IDENTIFIED BY 'readwritepw'; 47 47 48 -- 48 -- 49 49 -- Now connect to the new database 50 -- 50 -- 51 51 USE pykota; 52 52 … … 56 56 CREATE TABLE users (id INT4 PRIMARY KEY NOT NULL AUTO_INCREMENT, 57 57 username VARCHAR(255) UNIQUE NOT NULL, 58 email TEXT, 58 email TEXT, 59 59 balance FLOAT DEFAULT 0.0, 60 60 lifetimepaid FLOAT DEFAULT 0.0, … … 62 62 description TEXT, 63 63 overcharge FLOAT NOT NULL DEFAULT 1.0) TYPE=INNODB; 64 64 65 65 -- 66 66 -- Create the groups table … … 70 70 description TEXT, 71 71 limitby VARCHAR(30) DEFAULT 'quota') TYPE=INNODB; 72 72 73 73 -- 74 74 -- Create the printers table … … 81 81 passthrough ENUM('t','f') DEFAULT 'f', 82 82 maxjobsize INT4) TYPE=INNODB; 83 83 84 84 -- 85 85 -- Create the print quota table for users 86 86 -- 87 87 CREATE TABLE userpquota (id INT8 PRIMARY KEY NOT NULL AUTO_INCREMENT, 88 userid INT4, 89 printerid INT4, 88 userid INT4, 89 printerid INT4, 90 90 lifepagecounter INT4 DEFAULT 0, 91 91 pagecounter INT4 DEFAULT 0, … … 94 94 datelimit DATETIME, 95 95 maxjobsize INT4, 96 warncount INT4 DEFAULT 0, 96 warncount INT4 DEFAULT 0, 97 97 INDEX (userid), 98 98 FOREIGN KEY (userid) REFERENCES users(id), 99 99 INDEX (printerid), 100 FOREIGN KEY (printerid) REFERENCES printers(id)) 100 FOREIGN KEY (printerid) REFERENCES printers(id)) 101 101 TYPE=INNODB; 102 102 CREATE UNIQUE INDEX userpquota_up_id_ix ON userpquota (userid, printerid); 103 103 104 104 -- 105 105 -- Create the job history table … … 132 132 CREATE INDEX jobhistory_pd_id_ix ON jobhistory (printerid, jobdate); 133 133 CREATE INDEX jobhistory_hostname_ix ON jobhistory (hostname); 134 134 135 135 -- 136 136 -- Create the print quota table for groups 137 137 -- 138 138 CREATE TABLE grouppquota(id INT8 PRIMARY KEY NOT NULL AUTO_INCREMENT, 139 groupid INT4, 139 groupid INT4, 140 140 printerid INT4, 141 141 softlimit INT4, … … 149 149 TYPE=INNODB; 150 150 CREATE UNIQUE INDEX grouppquota_up_id_ix ON grouppquota (groupid, printerid); 151 152 -- 151 152 -- 153 153 -- Create the groups/members relationship 154 154 -- … … 160 160 FOREIGN KEY (userid) REFERENCES users(id), 161 161 PRIMARY KEY (groupid, userid)) TYPE=INNODB; 162 163 -- 162 163 -- 164 164 -- Create the printer groups relationship 165 165 -- … … 173 173 -- 174 174 -- Create the table for payments 175 -- 175 -- 176 176 CREATE TABLE payments (id INT4 PRIMARY KEY NOT NULL AUTO_INCREMENT, 177 177 userid INT4, … … 195 195 ) TYPE=INNODB; 196 196 197 -- 197 -- 198 198 -- Create the table for the billing codes 199 199 -- … … 203 203 balance FLOAT DEFAULT 0.0, 204 204 pagecounter INT4 DEFAULT 0) TYPE=INNODB; 205 -- 206 -- Set some ACLs 205 -- 206 -- Set some ACLs 207 207 -- 208 208 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON `pykota`.* TO 'pykotaadmin'@'localhost'; 209 209 GRANT SELECT ON `pykota`.* TO 'pykotauser'@'localhost'; 210 210 211 -- 211 -- 212 212 -- If necessary activate the lines below (and keep the preceding ones 213 213 -- activated at the same time) -
pykota/trunk/initscripts/mysql/README.mysql
r3279 r3413 25 25 DataBase using MySQL as a backend. 26 26 27 - edit the pykota-mysql.sql file and modify the passwords at 27 - edit the pykota-mysql.sql file and modify the passwords at 28 28 the end of the 'GRANT USAGE' lines. 29 29 30 30 - As MySQL's administrative user, usually root, 31 31 do the following : 32 32 33 33 # mysql <pykota-mysql.sql 34 34 35 35 - If no error message appear, your MySQL PyKota storage 36 36 is now ready for use. 37 37 38 38 - In ~pykota/pykota.conf, ensure that the following lines 39 39 are present and unique inside the [global] section : 40 40 41 41 storagebackend : mysqlstorage 42 42 storageserver : localhost … … 44 44 storageuser : pykotauser 45 45 storageuserpw : readonlypw 46 46 47 47 NB : replace 'readonlypw' with the password you chose 48 48 for user 'pykotauser' when you modified pykota-mysql.sql 49 49 50 50 - In ~pykota/pykotadmin.conf ensure that the following lines 51 51 are present and unique inside the [global] section : 52 52 53 53 storageadmin : pykotaadmin 54 54 storageadminpw : readwritepw 55 55 56 56 NB : replace 'readwritepw' with the password you chose 57 57 for user 'pykotaadmin' when you modified pykota-mysql.sql 58 59 - IMPORTANT : if your database is not located on the print server, 60 replace 'localhost' in the lines above with your database server's 58 59 - IMPORTANT : if your database is not located on the print server, 60 replace 'localhost' in the lines above with your database server's 61 61 hostname or IP address. If your database server doesn't listen on 62 62 its standard port, add the port number at the end of the hostname 63 63 with a colon to separate the hostname from the port. 64 64 See pykota/conf/pykota.conf.sample for examples. 65 65 66 66 ============================================================ -
pykota/trunk/initscripts/postgresql/pykota-postgresql.sql
r3279 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 35 35 -- Create the print quota database users 36 36 -- NOTE: Change the password values to the passwords you would like. 37 -- 37 -- 38 38 CREATE USER pykotauser WITH UNENCRYPTED PASSWORD 'readonlypw' NOCREATEDB NOCREATEUSER; 39 39 CREATE USER pykotaadmin WITH UNENCRYPTED PASSWORD 'readwritepw' NOCREATEDB NOCREATEUSER; 40 40 41 -- 41 -- 42 42 -- Now connect to the new database 43 -- 43 -- 44 44 \connect pykota 45 45 … … 49 49 CREATE TABLE users(id SERIAL PRIMARY KEY NOT NULL, 50 50 username TEXT UNIQUE NOT NULL, 51 email TEXT, 51 email TEXT, 52 52 balance FLOAT DEFAULT 0.0, 53 53 lifetimepaid FLOAT DEFAULT 0.0, … … 55 55 description TEXT, 56 56 overcharge FLOAT NOT NULL DEFAULT 1.0); 57 57 58 58 -- 59 59 -- Create the groups table … … 63 63 description TEXT, 64 64 limitby TEXT DEFAULT 'quota'); 65 65 66 66 -- 67 67 -- Create the printers table … … 74 74 passthrough BOOLEAN DEFAULT FALSE, 75 75 maxjobsize INT4); 76 76 77 77 -- 78 78 -- Create the print quota table for users … … 87 87 datelimit TIMESTAMP, 88 88 maxjobsize INT4, 89 warncount INT4 DEFAULT 0); 89 warncount INT4 DEFAULT 0); 90 90 CREATE INDEX userpquota_u_id_ix ON userpquota (userid); 91 91 CREATE INDEX userpquota_p_id_ix ON userpquota (printerid); 92 92 CREATE UNIQUE INDEX userpquota_up_id_ix ON userpquota (userid, printerid); 93 93 94 94 -- 95 95 -- Create the job history table … … 120 120 CREATE INDEX jobhistory_pd_id_ix ON jobhistory (printerid, jobdate); 121 121 CREATE INDEX jobhistory_hostname_ix ON jobhistory (hostname); 122 122 123 123 -- 124 124 -- Create the print quota table for groups … … 134 134 CREATE INDEX grouppquota_p_id_ix ON grouppquota (printerid); 135 135 CREATE UNIQUE INDEX grouppquota_up_id_ix ON grouppquota (groupid, printerid); 136 137 -- 136 137 -- 138 138 -- Create the groups/members relationship 139 139 -- … … 141 141 userid INT4 REFERENCES users(id), 142 142 PRIMARY KEY (groupid, userid)); 143 144 -- 143 144 -- 145 145 -- Create the printer groups relationship 146 146 -- … … 150 150 -- 151 151 -- Create the table for payments 152 -- 152 -- 153 153 CREATE TABLE payments (id SERIAL PRIMARY KEY NOT NULL, 154 154 userid INT4 REFERENCES users(id), … … 158 158 CREATE INDEX payments_date_ix ON payments (date); 159 159 160 -- 160 -- 161 161 -- Create the table for coefficients wrt paper sizes and the like 162 162 -- 163 CREATE TABLE coefficients (id SERIAL PRIMARY KEY NOT NULL, 164 printerid INTEGER NOT NULL REFERENCES printers(id), 165 label TEXT NOT NULL, 166 coefficient FLOAT DEFAULT 1.0, 163 CREATE TABLE coefficients (id SERIAL PRIMARY KEY NOT NULL, 164 printerid INTEGER NOT NULL REFERENCES printers(id), 165 label TEXT NOT NULL, 166 coefficient FLOAT DEFAULT 1.0, 167 167 CONSTRAINT coeffconstraint UNIQUE (printerid, label)); 168 168 169 -- 169 -- 170 170 -- Create the table for the billing codes 171 171 -- … … 176 176 pagecounter INT4 DEFAULT 0); 177 177 178 -- 179 -- Set some ACLs 178 -- 179 -- Set some ACLs 180 180 -- 181 181 REVOKE ALL ON users, groups, printers, userpquota, grouppquota, groupsmembers, printergroupsmembers, jobhistory, payments, coefficients, billingcodes FROM public; -
pykota/trunk/initscripts/postgresql/README.postgresql
r3279 r3413 31 31 - edit the pykota-postgresql.sql file and modify the passwords on 32 32 the 'CREATE USER' lines. 33 33 34 34 - Launch the psql frontend and connect to the 35 35 database template1 as a PostgreSQL administrator 36 36 (i.e. the postgres user) : 37 37 38 38 as user 'root' : 39 39 40 40 # su - postgres 41 42 you're now user 'postgres', then continue with : 43 41 42 you're now user 'postgres', then continue with : 43 44 44 $ psql -f pykota-postgresql.sql template1 45 46 or depending on your settings you may prefer : 47 45 46 or depending on your settings you may prefer : 47 48 48 $ psql -h localhost -U postgres -f pykota-postgresql.sql template1 49 50 - If no error message appears, your PostgreSQL PyKota storage 49 50 - If no error message appears, your PostgreSQL PyKota storage 51 51 is now ready for use. NB : a lot of NOTICE messages might appear, 52 52 this is perfectly normal. 53 53 54 54 - In ~pykota/pykota.conf, ensure that the following lines 55 55 are present and unique inside the [global] section : 56 56 57 57 storagebackend : pgstorage 58 58 storageserver : localhost … … 60 60 storageuser : pykotauser 61 61 storageuserpw : readonlypw 62 62 63 63 NB : replace 'readonlypw' with the password you chose 64 64 for user 'pykotauser' when you modified pykota-postgresql.sql 65 65 66 66 - In ~pykota/pykotadmin.conf ensure that the following lines 67 67 are present and unique inside the [global] section : 68 68 69 69 storageadmin : pykotaadmin 70 70 storageadminpw : readwritepw 71 71 72 72 NB : replace 'readwritepw' with the password you chose 73 73 for user 'pykotaadmin' when you modified pykota-postgresql.sql 74 75 - IMPORTANT : if your database is not located on the print server, 76 replace 'localhost' in the lines above with your database server's 74 75 - IMPORTANT : if your database is not located on the print server, 76 replace 'localhost' in the lines above with your database server's 77 77 hostname or IP address. If your database server doesn't listen on 78 78 its standard port, add the port number at the end of the hostname 79 79 with a colon to separate the hostname from the port. 80 80 See pykota/conf/pykota.conf.sample for examples. 81 81 82 82 ============================================================ 83 83 … … 89 89 Some scripts to upgrade old PyKota databases to the new 90 90 database schema are included. You may have to run all 91 of them or only some of them, depending on your 91 of them or only some of them, depending on your 92 92 version of PyKota. Usually running them several times, for 93 93 example if you used several different development versions 94 94 of PyKota, won't do any harm. 95 95 96 96 If you're connected as user 'root', you have to be user 'postgres' 97 97 instead : 98 98 99 99 # su - postgres 100 100 101 101 You're now user 'postgres', then continue the upgrade by following 102 102 the instructions below, depending on the version you actually use : 103 103 104 104 * An SQL script to upgrade a 1.22 PyKota Storage DataBase to 105 105 1.23 is included. Launch it this way on the Quota Storage Server : 106 106 107 107 $ psql -U postgres pykota 108 108 pykota=# \i upgrade-to-1.23.sql 109 109 pykota=# \q 110 110 $ 111 111 112 112 This script adds many fields to existing tables, and a table to 113 113 manage billing codes. 114 114 115 115 * An SQL script to upgrade a 1.20 PyKota Storage DataBase to 116 116 1.21 is included. Launch it this way on the Quota Storage Server : 117 117 118 118 $ psql -U postgres pykota 119 119 pykota=# \i upgrade-to-1.21.sql 120 120 pykota=# \q 121 121 $ 122 122 123 123 This script adds many fields to existing tables, and also adds 124 124 some tables in indexes. 125 125 126 126 * An SQL script to upgrade a 1.18 PyKota Storage DataBase to 127 127 1.19 is included. Launch it this way on the Quota Storage Server : 128 128 129 129 $ psql -U postgres pykota 130 130 pykota=# \i upgrade-to-1.19.sql 131 131 pykota=# \q 132 132 $ 133 133 134 134 This script adds a field to the print job history. The field that 135 135 is added is : hostname 136 136 137 137 * An SQL script to upgrade a pre-1.16 PyKota Storage DataBase to 138 138 1.16 is included. Launch it this way on the Quota Storage Server : 139 139 140 140 $ psql -U postgres pykota 141 141 pykota=# \i upgrade-to-1.16.sql 142 142 pykota=# \q 143 143 $ 144 144 145 145 This script adds some fields to the print job history, so that 146 146 more complete information will be known. The fields that 147 are added are : jobprice, filename, title, copies and print 147 are added are : jobprice, filename, title, copies and print 148 148 command options. Also some indexes are created to speed things up. 149 150 What is below is for historical reasons only, real people don't use 149 150 What is below is for historical reasons only, real people don't use 151 151 such old beasts, and YOU SHOULDN'T EITHER ! 152 152 153 153 * An SQL script to upgrade a pre-1.14 PyKota Storage DataBase to 154 154 1.14 is included. Launch it this way on the Quota Storage Server : 155 155 156 156 $ psql -U postgres pykota 157 157 pykota=# \i upgrade-to-1.14.sql 158 158 pykota=# \q 159 159 $ 160 161 This script adds an "email" field for each user. This field, if not 160 161 This script adds an "email" field for each user. This field, if not 162 162 NULL, is used as the email address of the user when sending warning 163 163 messages in case he is over quota. 164 165 * An sql script to upgrade a pre-1.01 PyKota Quota Storage DataBase to 166 1.01 is still included for historical reasons. PLEASE DON'T USE IT ! 167 168 * If you are already running an old version of PyKota (<1.03) and 169 want to upgrade to 1.03, YOU HAVE TO RUN the 170 upgrade-from-before-1.03.py shell script. NOT LAUNCHING THIS SCRIPT 171 WILL CAUSE PYKOTA TO STOP WORKING ! PLEASE NEVER RUN THIS SCRIPT IF 172 YOUR EXISTING VERSION OF PYKOTA IS ALREADY 1.03 OR HIGHER. 164 165 * An sql script to upgrade a pre-1.01 PyKota Quota Storage DataBase to 166 1.01 is still included for historical reasons. PLEASE DON'T USE IT ! 167 168 * If you are already running an old version of PyKota (<1.03) and 169 want to upgrade to 1.03, YOU HAVE TO RUN the 170 upgrade-from-before-1.03.py shell script. NOT LAUNCHING THIS SCRIPT 171 WILL CAUSE PYKOTA TO STOP WORKING ! PLEASE NEVER RUN THIS SCRIPT IF 172 YOUR EXISTING VERSION OF PYKOTA IS ALREADY 1.03 OR HIGHER. -
pykota/trunk/initscripts/postgresql/upgrade-from-before-1.03.py
r3259 r3413 8 8 # the Free Software Foundation, either version 3 of the License, or 9 9 # (at your option) any later version. 10 # 10 # 11 11 # This program is distributed in the hope that it will be useful, 12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 # GNU General Public License for more details. 15 # 15 # 16 16 # You should have received a copy of the GNU General Public License 17 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. … … 26 26 try : 27 27 import pg 28 except ImportError : 28 except ImportError : 29 29 sys.stderr.write("The PyGreSQL Python module doesn't seem to be available. ABORTED.\n") 30 30 sys.exit(-1) … … 32 32 def dump_old_database() : 33 33 """Dumps the existing PyKota database to a file, to avoir loosing data. 34 34 35 35 Returns 1 if dump is successfull, 0 if it isn't. 36 """ 36 """ 37 37 pipeinput = os.popen("pg_dump -C -D -N -U postgres -f pykota-dump.sql pykota") 38 38 dummy = pipeinput.read() … … 44 44 dummy = pipeinput.read() 45 45 return (pipeinput.close() is None) or 0 46 46 47 47 def restore_original_database() : 48 48 """Creates the empty database.""" … … 50 50 dummy = pipeinput.read() 51 51 return (pipeinput.close() is None) or 0 52 52 53 53 def open_database(dbname="pykota") : 54 54 """Returns the database object or None if we can't connect to it.""" 55 55 try : 56 56 pykotadb = pg.connect(host="localhost", port=5432, dbname=dbname, user="postgres") 57 except pg.error, msg : 57 except pg.error, msg : 58 58 sys.stderr.write("%s\n" % msg) 59 59 sys.stderr.write("Unable to connect to the local PostgreSQL server.\nPlease modify the open_database() method in %s\nto connect to the correct PostgreSQL server\nand relaunch the script.\n" % sys.argv[0]) 60 return 61 else : 60 return 61 else : 62 62 return pykotadb 63 64 63 64 65 65 def doQuote(field) : 66 66 """Quotes a field for use as a string in SQL queries.""" 67 67 if type(field) == type(0) : # TODO : do something safer 68 68 typ = "decimal" 69 else : 69 else : 70 70 typ = "text" 71 71 return pg._quote(field, typ) 72 72 73 73 def main() : 74 74 """Does the work.""" 75 75 76 76 # First we make a dump of the old database 77 77 print "Dumping old database for safety...", … … 80 80 return -1 81 81 print "Done." 82 83 # Second we try to connect to it 84 print "Extracting datas from old database...", 82 83 # Second we try to connect to it 84 print "Extracting datas from old database...", 85 85 db = open_database() 86 86 if db is None : 87 87 sys.stderr.write("Impossible to connect to old PyKota database. ABORTED.\nAre you sure you are upgrading an existing installation ?\n") 88 88 return -1 89 89 90 90 # Third we extract datas 91 91 oldprinters = db.query("SELECT * FROM printers ORDER BY id;") 92 92 oldusers = db.query("SELECT * FROM users ORDER BY id;") 93 93 oldquotas = db.query("SELECT * FROM userpquota ORDER BY printerid, userid;") 94 94 95 95 # Fourth close the database 96 96 db.close() 97 97 print "Done." 98 98 99 99 # Fifth we delete the old database ! 100 100 answer = raw_input("The old database will be deleted for the upgrade to take place.\nAre you sure you want to continue (y/N) ? ") … … 112 112 db.close() 113 113 return -1 114 else : 114 else : 115 115 db.close() 116 116 117 117 # Sixth we create the new database 118 118 print "Creating the new database...", … … 121 121 return -1 122 122 print "Done." 123 123 124 124 # Seventh we restore old data 125 125 print "Restoring old datas..." … … 131 131 sys.stderr.write("Shit ! A double-error occured !!!\nPlease report problem to your database administrator.\n") 132 132 sys.stderr.write("And file a bug report to alet@librelogiciel.com\n") 133 else : 133 else : 134 134 print "Done." 135 135 return -1 136 db.query("BEGIN;") 136 db.query("BEGIN;") 137 137 try : 138 138 newprinters = {} … … 141 141 newid = db.query("SELECT id FROM printers WHERE printername='%s';" % oldprinter["printername"]).dictresult()[0]["id"] 142 142 newprinters[oldprinter["id"]] = newid 143 newusers = {} 144 for olduser in oldusers.dictresult() : 143 newusers = {} 144 for olduser in oldusers.dictresult() : 145 145 db.query("INSERT INTO users (username) VALUES (%s);" % doQuote(olduser["username"])) 146 146 newid = db.query("SELECT id FROM users WHERE username='%s';" % olduser["username"]).dictresult()[0]["id"] 147 147 newusers[olduser["id"]] = newid 148 for oldquota in oldquotas.dictresult() : 149 db.query("INSERT INTO userpquota (userid, printerid, pagecounter, lifepagecounter, softlimit, hardlimit, datelimit) VALUES (%s, %s, %s, %s, %s, %s, %s);" % 148 for oldquota in oldquotas.dictresult() : 149 db.query("INSERT INTO userpquota (userid, printerid, pagecounter, lifepagecounter, softlimit, hardlimit, datelimit) VALUES (%s, %s, %s, %s, %s, %s, %s);" % 150 150 (doQuote(newusers[oldquota["userid"]]) , doQuote(newprinters[oldquota["printerid"]]), doQuote(oldquota["pagecounter"]), doQuote(oldquota["lifepagecounter"]), doQuote(oldquota["softlimit"]), doQuote(oldquota["hardlimit"]), doQuote(oldquota["datelimit"]))) 151 except pg.error, msg : 151 except pg.error, msg : 152 152 sys.stderr.write("ERROR : %s\nABORTED.\n" % msg) 153 153 db.query("ROLLBACK;") 154 db.close() 154 db.close() 155 155 return -1 156 except : 156 except : 157 157 sys.stderr.write("Unknown error ! ABORTED.\n") 158 158 db.query("ROLLBACK;") 159 db.close() 159 db.close() 160 160 return -1 161 else : 161 else : 162 162 db.query("COMMIT;") 163 163 db.close() … … 165 165 print "NB : Last job on each printer was lost. This is normal !" 166 166 return 0 167 167 168 168 if __name__ == "__main__" : 169 169 sys.exit(main()) -
pykota/trunk/initscripts/postgresql/upgrade-to-1.14.sql
r3259 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 19 19 -- 20 20 -- 21 22 -- 21 22 -- 23 23 -- WARNING : YOU NEED A RECENT VERSION OF POSTGRESQL FOR THE ALTER COLUMN STATEMENT TO WORK ! 24 24 -- 25 25 26 -- 26 -- 27 27 -- Modify the old database schema 28 28 -- -
pykota/trunk/initscripts/postgresql/upgrade-to-1.16.sql
r3259 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. 17 -- 17 -- 18 18 -- $Id$ 19 19 -- … … 22 22 -- This script has to be used if you already 23 23 -- have a pre-1.16 version of PyKota to upgrade 24 -- your database schema. 24 -- your database schema. 25 25 -- 26 26 -- YOU DON'T NEED TO USE IT IF YOU'VE JUST INSTALLED PYKOTA 27 27 -- 28 29 -- 28 29 -- 30 30 -- WARNING : YOU NEED A RECENT VERSION OF POSTGRESQL FOR THE ALTER COLUMN STATEMENT TO WORK ! 31 31 -- 32 32 33 -- 33 -- 34 34 -- Modify the old database schema 35 35 -- … … 48 48 ALTER TABLE jobhistory ADD CONSTRAINT checkUserPQuota FOREIGN KEY (userid, printerid) REFERENCES userpquota (userid, printerid); 49 49 50 -- 50 -- 51 51 -- Add new tables 52 52 -- 53 -- 53 -- 54 54 -- Create the printer groups relationship 55 55 -- … … 58 58 PRIMARY KEY (groupid, printerid)); 59 59 60 -- 60 -- 61 61 -- Now add some indexes 62 62 -- … … 66 66 CREATE UNIQUE INDEX grouppquota_up_id_ix ON grouppquota (groupid, printerid); 67 67 68 -- 68 -- 69 69 -- And now sets some ACLs 70 -- 71 REVOKE ALL ON printergroupsmembers FROM public; 70 -- 71 REVOKE ALL ON printergroupsmembers FROM public; 72 72 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON printergroupsmembers TO pykotaadmin; 73 73 GRANT SELECT ON printergroupsmembers TO pykotauser; -
pykota/trunk/initscripts/postgresql/upgrade-to-1.19.sql
r3259 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 22 22 -- This script has to be used if you already 23 23 -- have a pre-1.19 version of PyKota to upgrade 24 -- your database schema. 24 -- your database schema. 25 25 -- 26 26 -- YOU DON'T NEED TO USE IT IF YOU'VE JUST INSTALLED PYKOTA 27 27 -- 28 29 -- 28 29 -- 30 30 -- WARNING : YOU NEED A RECENT VERSION OF POSTGRESQL FOR THE ALTER COLUMN STATEMENT TO WORK ! 31 31 -- 32 32 33 -- 33 -- 34 34 -- Modify the old database schema 35 35 -- … … 45 45 CREATE INDEX payments_date_ix ON payments (date); 46 46 47 REVOKE ALL ON payments FROM public; 47 REVOKE ALL ON payments FROM public; 48 48 REVOKE ALL ON payments_id_seq FROM public; 49 49 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON payments TO pykotaadmin; -
pykota/trunk/initscripts/postgresql/upgrade-to-1.21.sql
r3259 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 22 22 -- This script has to be used if you already 23 23 -- have a pre-1.21 version of PyKota to upgrade 24 -- your database schema. 24 -- your database schema. 25 25 -- 26 26 -- YOU DON'T NEED TO USE IT IF YOU'VE JUST INSTALLED PYKOTA 27 27 -- 28 29 -- 28 29 -- 30 30 -- Modify the old database schema 31 31 -- … … 51 51 CREATE INDEX jobhistory_u_id_ix ON jobhistory (userid); 52 52 53 -- 53 -- 54 54 -- Create the table for coefficients wrt paper sizes and the like 55 55 -- 56 CREATE TABLE coefficients (id SERIAL PRIMARY KEY NOT NULL, 57 printerid INTEGER NOT NULL REFERENCES printers(id), 58 label TEXT NOT NULL, 59 coefficient FLOAT DEFAULT 1.0, 56 CREATE TABLE coefficients (id SERIAL PRIMARY KEY NOT NULL, 57 printerid INTEGER NOT NULL REFERENCES printers(id), 58 label TEXT NOT NULL, 59 coefficient FLOAT DEFAULT 1.0, 60 60 CONSTRAINT coeffconstraint UNIQUE (printerid, label)); 61 62 REVOKE ALL ON coefficients FROM public; 61 62 REVOKE ALL ON coefficients FROM public; 63 63 REVOKE ALL ON coefficients_id_seq FROM public; 64 64 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON coefficients TO pykotaadmin; -
pykota/trunk/initscripts/postgresql/upgrade-to-1.23.sql
r3259 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 22 22 -- This script has to be used if you already 23 23 -- have a pre-1.23alpha30 version of PyKota to upgrade 24 -- your database schema. 24 -- your database schema. 25 25 -- 26 26 -- YOU DON'T NEED TO USE IT IF YOU'VE JUST INSTALLED PYKOTA 27 27 -- 28 29 -- 28 29 -- 30 30 -- Modify the old database schema 31 31 -- … … 49 49 UPDATE printers SET passthrough=FALSE; 50 50 51 -- 51 -- 52 52 -- Create the table for the billing codes 53 53 -- … … 59 59 ALTER TABLE billingcodes RENAME COLUMN label TO billingcode; 60 60 61 REVOKE ALL ON billingcodes FROM public; 61 REVOKE ALL ON billingcodes FROM public; 62 62 REVOKE ALL ON billingcodes_id_seq FROM public; 63 63 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON billingcodes TO pykotaadmin; -
pykota/trunk/initscripts/postgresql/VERYOLDpykota-upgrade-postgresql.sql
r3259 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 26 26 -- the normal script instead. 27 27 -- 28 29 -- 28 29 -- 30 30 -- WARNING : YOU NEED A RECENT VERSION OF POSTGRESQL FOR THE DROP COLUMN STATEMENT TO WORK ! 31 31 -- 32 32 33 -- 33 -- 34 34 -- Modify the old database schema 35 35 -- … … 37 37 ALTER TABLE grouppquota DROP COLUMN pagecounter; 38 38 39 -- 39 -- 40 40 -- Create the groups/members relationship 41 41 -- … … 43 43 userid INT4 REFERENCES users(id), 44 44 PRIMARY KEY (groupid, userid)); 45 46 -- 47 -- Set some ACLs 45 48 46 -- 49 REVOKE ALL ON groupsmembers FROM public; 47 -- Set some ACLs 48 -- 49 REVOKE ALL ON groupsmembers FROM public; 50 50 GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON groupsmembers TO pykotaadmin; -
pykota/trunk/initscripts/README
r3279 r3413 29 29 30 30 * postgresql/pykota-postgresql.sql : 31 31 32 32 This file creates an empty Quota Storage Database, using PostgreSQL 33 33 as a backend. You have to use it the first time you install PyKota 34 34 if you want to use PostgreSQL as the Quota Storage Backend. 35 36 * ldap/pykota.schema : 37 35 36 * ldap/pykota.schema : 37 38 38 This file adds the necessary classes and attributes to an existing 39 LDAP directory for use with PyKota. Read this file and the 39 LDAP directory for use with PyKota. Read this file and the 40 40 associated ldap/README.ldap files for details. 41 42 43 Old files, kept to allow people to upgrade from very old versions of PyKota : 41 42 43 Old files, kept to allow people to upgrade from very old versions of PyKota : 44 44 ============================================================================= 45 46 * upgrade-to-1.19.sql : 47 45 46 * upgrade-to-1.19.sql : 47 48 48 This file upgrades the PostgreSQL Quota Storage Database schema 49 49 from versions before 1.19alpha7 to version 1.19alpha7 and above. 50 50 NEVER USE IT IF YOU ALREADY RUN 1.19alpha7 OR ABOVE ! 51 52 * upgrade-to-1.16.sql : 53 51 52 * upgrade-to-1.16.sql : 53 54 54 This file upgrades the PostgreSQL Quota Storage Database schema 55 55 from versions before 1.16 to version 1.16. 56 56 NEVER USE IT IF YOU ALREADY RUN 1.16 OR ABOVE ! 57 58 * upgrade-to-1.14.sql : 59 57 58 * upgrade-to-1.14.sql : 59 60 60 This file upgrades the PostgreSQL Quota Storage Database schema 61 61 from versions before 1.14 to version 1.14. 62 62 NEVER USE IT IF YOU ALREADY RUN 1.14 OR ABOVE ! 63 63 64 64 * VERYOLDpykota-upgrade-postgresql.sql : 65 65 66 66 This file upgrades the PostgreSQL Quota Storage Database schema 67 67 from versions before 1.01 to version 1.01. 68 68 69 69 IT'S THERE FOR HISTORICAL REASONS ONLY : DON'T USE IT, USE 70 70 THE SCRIPT DESCRIBED BELOW INSTEAD ! 71 71 72 72 * upgrade-from-before-1.03.py : 73 73 74 74 This shell script upgrades the PostgreSQL Quota Storage Database schema 75 75 from versions 1.01 or 1.02 to version 1.03. 76 76 PLEASE DO A BACKUP OF YOUR PYKOTA DATABASE BEFORE RUNNING THIS SCRIPT ! 77 77 Also this script will try to connect to PostgreSQL as the postgres user 78 (i.e. PostgreSQL's administrator), on the local machine (PyKota Storage 79 Server), without prompting for a password. Please read this script and 78 (i.e. PostgreSQL's administrator), on the local machine (PyKota Storage 79 Server), without prompting for a password. Please read this script and 80 80 adapt it to your own configuration before running it. THIS IS IMPORTANT. 81 82 THIS SCRIPT MAKES ANY REASONABLE CHECK TO ENSURE THAT YOUR DATAS WON'T 81 82 THIS SCRIPT MAKES ANY REASONABLE CHECK TO ENSURE THAT YOUR DATAS WON'T 83 83 BE LOST, AND ALSO DUMPS YOUR OLD DATABASE TO A TEXT FILE BEFORE DOING 84 84 ANYTHING. IT WAS TESTED SEVERAL TIMES AND SHOULDN'T PRODUCE ANY ERROR 85 EXCEPT ABOUT THE pykotaadmin and pykotauser POSTGRESQL USERS WHO 85 EXCEPT ABOUT THE pykotaadmin and pykotauser POSTGRESQL USERS WHO 86 86 ALREADY EXIST WHEN THE DATABASE SCHEMA IS UPGRADED. THIS IS NORMAL ! 87 87 -
pykota/trunk/initscripts/sqlite/pykota-sqlite.sql
r3279 r3413 7 7 -- the Free Software Foundation, either version 3 of the License, or 8 8 -- (at your option) any later version. 9 -- 9 -- 10 10 -- This program is distributed in the hope that it will be useful, 11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 -- GNU General Public License for more details. 14 -- 14 -- 15 15 -- You should have received a copy of the GNU General Public License 16 16 -- along with this program. If not, see <http://www.gnu.org/licenses/>. … … 32 32 CREATE TABLE users(id INTEGER PRIMARY KEY NOT NULL, 33 33 username TEXT UNIQUE NOT NULL, 34 email TEXT, 34 email TEXT, 35 35 balance FLOAT DEFAULT 0.0, 36 36 lifetimepaid FLOAT DEFAULT 0.0, … … 38 38 description TEXT, 39 39 overcharge FLOAT NOT NULL DEFAULT 1.0); 40 40 41 41 -- 42 42 -- Create the groups table … … 46 46 description TEXT, 47 47 limitby TEXT DEFAULT 'quota'); 48 48 49 49 -- 50 50 -- Create the printers table … … 57 57 passthrough BOOLEAN DEFAULT FALSE, 58 58 maxjobsize INT4); 59 59 60 60 -- 61 61 -- Create the print quota table for users … … 70 70 datelimit TEXT, 71 71 maxjobsize INT4, 72 warncount INT4 DEFAULT 0); 72 warncount INT4 DEFAULT 0); 73 73 CREATE INDEX userpquota_u_id_ix ON userpquota (userid); 74 74 CREATE INDEX userpquota_p_id_ix ON userpquota (printerid); 75 75 CREATE UNIQUE INDEX userpquota_up_id_ix ON userpquota (userid, printerid); 76 76 77 77 -- 78 78 -- Create the job history table … … 103 103 CREATE INDEX jobhistory_pd_id_ix ON jobhistory (printerid, jobdate); 104 104 CREATE INDEX jobhistory_hostname_ix ON jobhistory (hostname); 105 105 106 106 -- 107 107 -- Create the print quota table for groups … … 117 117 CREATE INDEX grouppquota_p_id_ix ON grouppquota (printerid); 118 118 CREATE UNIQUE INDEX grouppquota_up_id_ix ON grouppquota (groupid, printerid); 119 120 -- 119 120 -- 121 121 -- Create the groups/members relationship 122 122 -- … … 124 124 userid INT4 REFERENCES users(id), 125 125 PRIMARY KEY (groupid, userid)); 126 127 -- 126 127 -- 128 128 -- Create the printer groups relationship 129 129 -- … … 133 133 -- 134 134 -- Create the table for payments 135 -- 135 -- 136 136 CREATE TABLE payments (id INTEGER PRIMARY KEY NOT NULL, 137 137 userid INT4 REFERENCES users(id), … … 141 141 CREATE INDEX payments_date_ix ON payments (date); 142 142 143 -- 143 -- 144 144 -- Create the table for coefficients wrt paper sizes and the like 145 145 -- 146 CREATE TABLE coefficients (id INTEGER PRIMARY KEY NOT NULL, 147 printerid INTEGER NOT NULL REFERENCES printers(id), 148 label TEXT NOT NULL, 149 coefficient FLOAT DEFAULT 1.0, 146 CREATE TABLE coefficients (id INTEGER PRIMARY KEY NOT NULL, 147 printerid INTEGER NOT NULL REFERENCES printers(id), 148 label TEXT NOT NULL, 149 coefficient FLOAT DEFAULT 1.0, 150 150 CONSTRAINT coeffconstraint UNIQUE (printerid, label)); 151 151 152 -- 152 -- 153 153 -- Create the table for the billing codes 154 154 -- -
pykota/trunk/initscripts/sqlite/README.sqlite
r3279 r3413 27 27 for use with PyKota, in the case you don't want to use 28 28 either PostgreSQL, MySQL, or LDAP : 29 29 30 30 NB : an SQLite3 database can't be shared between several 31 31 PyKota managed print servers, contrarily to the other 32 32 database backends. 33 33 34 34 HowTo : 35 35 36 36 - Install SQLite v3.2.1 or higher, and its development files, 37 37 for example on my Debian box : 38 38 39 39 # apt-get install sqlite3 libsqlite3-dev 40 41 You can also download SQLite from http://www.sqlite.org 40 41 You can also download SQLite from http://www.sqlite.org 42 42 43 43 - Download and install PySQLite v2.0.5 or higher from : 44 44 45 45 http://www.pysqlite.org 46 46 … … 50 50 # cd pysqlite-2.0.5 51 51 # python setup.py install 52 52 53 53 Under Debian, if the package exists for your version of Debian, 54 54 simply do : 55 55 56 56 # apt-get install python-pysqlite2 57 57 58 58 - Create an SQLite3 database for PyKota : 59 59 … … 62 62 # chmod 660 ~pykota/pykota.db 63 63 # chown pykota.pykota ~pykota (seems to be necessary) 64 64 65 65 NB : adapt the permissions so that the user your printing 66 66 system runs as (e.g. user 'lp') can read and write 67 67 to the /etc/pykota/pykota.db file. 68 68 69 69 - In ~pykota/pykotadmin.conf, just comment out all the lines 70 70 … … 74 74 storagebackend : sqlitestorage 75 75 storagename : /etc/pykota/pykota.db 76 76 77 77 And comment out all other directives which name begins with 'storage'. 78 78 NB : feel free to use a different path to store pykota.db, and 79 79 adapt your configuration files and permissions accordingly. 80 81 Your PyKota setup is now ready to be used with an SQLite3 database. 80 81 Your PyKota setup is now ready to be used with an SQLite3 database. 82 82 83 83 IMPORTANT : with PyKota's SQLite backend there's no possibility to separate