
##############################################################################
# UPGRADING from pre-self-release version:

CREATE TABLE gxrelease_jobs_pre_upgrade SELECT * from gxrelease_jobs;
CREATE TABLE gxrelease_jobs_old_pre_upgrade SELECT * from gxrelease_jobs_old;
CREATE TABLE IF NOT EXISTS gxrelease_balances (user VARCHAR(64), balance FLOAT, PRIMARY KEY (user));
CREATE TABLE IF NOT EXISTS gxrelease_txlog ( timestamp DATETIME, source TINYINT , username VARCHAR(64), adjustment DECIMAL(6,2) , balance DECIMAL(6,2) );

DROP TABLE gxrelease_jobs;
DROP TABLE gxrelease_jobs_old;


#ALTER TABLE gxrelease_jobs DROP PRIMARY KEY ;
#ALTER TABLE gxrelease_jobs ADD id INT NOT NULL auto_increment FIRST, ADD PRIMARY KEY (id) ;
#ALTER TABLE gxrelease_jobs ADD completed TINYINT;
#ALTER TABLE gxrelease_jobs_old DROP PRIMARY KEY ;
#ALTER TABLE gxrelease_jobs_old ADD id INT NOT NULL auto_increment FIRST, ADD PRIMARY KEY (id) ;
#ALTER TABLE gxrelease_jobs_old ADD completed TINYINT;
##############################################################################



apt-get-dontask install pkpgcounter

#only necessary if we want to test it out by printing from the server itself:
apt-get-dontask install groovix-print-release


CREATE TABLE IF NOT EXISTS gxrelease_jobs  (id INT NOT NULL auto_increment, job_id INT, release_state TINYINT, submit_time DATETIME,client VARCHAR(64),user VARCHAR(64),title VARCHAR(256),size INT,printer VARCHAR(128),printer_uri VARCHAR(256),release_hostname VARCHAR(64),pages SMALLINT, cost_per_page FLOAT, completed TINYINT, PRIMARY KEY (id) );
CREATE TABLE gxrelease_jobs_old   SELECT * from gxrelease_jobs;
CREATE TABLE IF NOT EXISTS gxrelease_balances (user VARCHAR(64), balance FLOAT, PRIMARY KEY (user));
CREATE TABLE IF NOT EXISTS gxrelease_txlog ( timestamp DATETIME, source TINYINT , username VARCHAR(64), adjustment DECIMAL(6,2) , balance DECIMAL(6,2) );


#old: before id field used PRIMARY KEY (job_id,release_hostname)
#CREATE TABLE IF NOT EXISTS gxrelease_jobs  (id INT not NULL auto_increment, job_id INT, release_state TINYINT, submit_time DATETIME,client VARCHAR(64),user VARCHAR(64),title VARCHAR(256),size INT,printer VARCHAR(128),printer_uri VARCHAR(256),release_hostname VARCHAR(64),pages SMALLINT, cost_per_page FLOAT, PRIMARY KEY (job_id,release_hostname) );

#additions for lcplin first prints are free:
#ALTER TABLE gxrelease_jobs ADD COLUMN credit FLOAT;
#ALTER TABLE gxrelease_jobs_old ADD COLUMN credit FLOAT;



configure sql_config.py , can probably use values from cmon/python
configure server_config.py , can probably use values from cmon/python
configure my_config.bash , can probably use values from stats
configure move_to_old.sql and move_to_old.bash

add these lines to crontab:
#move all print jobs to old at 1AM every day
0 1 * * * root /var/www/groovix/gxrelease/move_to_old.bash

#for running stats on server on the first of the month
0 6 1 * * root  /var/www/groovix/gxrelease/run_monthly_report.bash


#do this on machine that will function as print server
/etc/init.d/cups stop
vi /etc/cups/cupsd.conf
	- start with default cupsd.conf, allow remote admin, keep print jobs for reprinting, etc.  
	- restart cups
        - by hand: remove Release-Job and Cancel-Job and Restart-Job from limitation lists (see example-cupsd.conf) -  in future: change the code to authenticate with cups
		- 
/etc/init.d/cups start



