-- $ Id: $

-- Convenience script for creating mysql-databse - users for use with Origo.
-- Note: if you create DB-users with this script, the passwords in /etc/origo/orgio.conf must match the ones used here!

-- Change these passworts to custom ones!!!
SET @snmp_pwd = 'NJ0zVh5GKF1tloSL';
SET @storage = '6pGn4GTj3phaCWfJ';
SET @manager = 'MHEx8VqRTnUbLEGE';
SET @db_crawler = 'UnqrryVvsGYnHfA3';
SET @drupalcron = 'vKTxzaqfWADscEnx';
SET @data_mgmt = '3LeFtCScS6GaHasS';


-- only edit stuff below this line if you're really sure what you're doing.

-- readonly user 'origo_snmp'
CREATE USER 'origo_snmp'@'localhost' IDENTIFIED BY '@snmp_pwd';
GRANT USAGE ON * . * TO 'origo_snmp'@'localhost' IDENTIFIED BY '@snmp_pwd' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
  -- grant readonly rights on origo-DB
GRANT SELECT ON `origo` . * TO 'origo_snmp'@'localhost';

-- user 'storage_user' - full rights
CREATE USER 'origo_storage'@'localhost' IDENTIFIED BY '@storage';
GRANT USAGE ON * . * TO 'origo_storage'@'localhost' IDENTIFIED BY '@storage' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
-- grant full rights on origo-DB
GRANT ALL PRIVILEGES ON `origo` . * TO 'origo_storage'@'localhost' WITH GRANT OPTION ;

-- user 'manager_user' - full rights
CREATE USER 'origo_manager'@'localhost' IDENTIFIED BY '@manager';
GRANT USAGE ON * . * TO 'origo_manager'@'localhost' IDENTIFIED BY '@manager' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
-- grant full rights on origo-DB
GRANT ALL PRIVILEGES ON * . * TO 'origo_manager'@'localhost' WITH GRANT OPTION ;

-- user 'db_crawler' - full rights
CREATE USER 'origo_db_crawler'@'localhost' IDENTIFIED BY '@db_crawler';
GRANT USAGE ON * . * TO 'origo_db_crawler'@'localhost' IDENTIFIED BY '@db_crawler' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
-- grant full rights on origo-DB
GRANT ALL PRIVILEGES ON `origo` . * TO 'origo_db_crawler'@'localhost' WITH GRANT OPTION ;

-- user 'drupal_cron' - full rights
CREATE USER 'origo_drupalcron'@'localhost' IDENTIFIED BY '@drupalcron';
GRANT USAGE ON * . * TO 'origo_drupalcron'@'localhost' IDENTIFIED BY '@drupalcron' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
-- grant full rights on origo-DB
GRANT ALL PRIVILEGES ON `origo` . * TO 'origo_drupalcron'@'localhost' WITH GRANT OPTION ;

-- user 'origo_data_mgmt' - full rights
CREATE USER 'origo_data_mgmt'@'localhost' IDENTIFIED BY '@data_mgmt';
GRANT USAGE ON * . * TO 'origo_data_mgmt'@'localhost' IDENTIFIED BY '@data_mgmt' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
-- grant full rights on origo-DB
GRANT ALL PRIVILEGES ON `origo` . * TO 'origo_data_mgmt'@'localhost' WITH GRANT OPTION ;


-- User used for running unittests\
-- NOTE: do not change its password
CREATE USER 'origo_test'@'localhost' IDENTIFIED BY 'origo';
GRANT USAGE ON * . * TO 'origo_test'@'localhost' IDENTIFIED BY 'origo' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
GRANT ALL PRIVILEGES ON `origo\_test` . * TO 'origo_test'@'localhost' WITH GRANT OPTION ;

FLUSH PRIVILEGES;
