From cbfaae155e75c6e93e36a0d6ba68fc73744d3bca Mon Sep 17 00:00:00 2001 From: Vincent Zanotti Date: Fri, 25 Jan 2008 17:00:31 +0100 Subject: [PATCH] Adds basic Google Apps support. * Adds minimal configuration directives in platal.ini. * Adds the SQL tables for the Plat/al - GAppsDaemon interactions. * Adds the Google Apps sql table cleanup cron. Signed-off-by: Vincent Zanotti --- bin/cron/google_apps.php | 43 ++++++++++++++++++++ configs/platal.cron.in | 3 ++ upgrade/0.9.16/06_google_apps.sql | 86 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100755 bin/cron/google_apps.php create mode 100644 upgrade/0.9.16/06_google_apps.sql diff --git a/bin/cron/google_apps.php b/bin/cron/google_apps.php new file mode 100755 index 0000000..76cfcc5 --- /dev/null +++ b/bin/cron/google_apps.php @@ -0,0 +1,43 @@ +#!/usr/bin/php5 -q +googleapps->domain) { + exit; +} + +/* Updates the l_userid parameter for newer user accounts. */ +$res = XDB::iterator("SELECT g.g_account_name, a.id + FROM gapps_accounts AS g + LEFT JOIN aliases as a ON (a.alias = g.g_account_name AND a.type = 'a_vie') + WHERE (g.l_userid IS NULL OR g.l_userid <= 0) AND + a.id IS NOT NULL"); +while ($account = $res->next()) { + XDB::execute("UPDATE gapps_accounts + SET l_userid = {?} + WHERE g_account_name = {?}", + $account['id'], $account['g_account_name']); +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?> diff --git a/configs/platal.cron.in b/configs/platal.cron.in index 05de023..4c57ba8 100644 --- a/configs/platal.cron.in +++ b/configs/platal.cron.in @@ -30,4 +30,7 @@ WD=/home/web/prod/platal/bin/cron # ml moderation * * * * * web cd $WD; ./cron_ml_moderate.php > /dev/null +# synchronisation google apps - plat/al +0 3 * * * web cd $WD; ./google_apps.php + # vim:set noet syntax=crontab ts=8 sw=8 sts=8 enc=utf-8: diff --git a/upgrade/0.9.16/06_google_apps.sql b/upgrade/0.9.16/06_google_apps.sql new file mode 100644 index 0000000..1ad53f3 --- /dev/null +++ b/upgrade/0.9.16/06_google_apps.sql @@ -0,0 +1,86 @@ +-- This SQL table comes from the 'gapps-daemon' project. + +-- Table `gapps_reporting`. +-- The table contains daily statistics of the Google Apps domain. They are +-- obtained with the Summary and Actvity reports of the Google Apps Reorting +-- API. +CREATE TABLE IF NOT EXISTS `gapps_reporting` ( + date DATE NOT NULL, + num_accounts INTEGER UNSIGNED DEFAULT NULL, + count_1_day_actives INTEGER UNSIGNED DEFAULT NULL, + count_7_day_actives INTEGER UNSIGNED DEFAULT NULL, + count_14_day_actives INTEGER UNSIGNED DEFAULT NULL, + count_30_day_actives INTEGER UNSIGNED DEFAULT NULL, + count_30_day_idle INTEGER UNSIGNED DEFAULT NULL, + count_60_day_idle INTEGER UNSIGNED DEFAULT NULL, + count_90_day_idle INTEGER UNSIGNED DEFAULT NULL, + usage_in_bytes BIGINT UNSIGNED DEFAULT NULL, + quota_in_mb INTEGER UNSIGNED DEFAULT NULL, + PRIMARY KEY(date) +) CHARSET=utf8; + +-- Table `gapps_accounts`. +-- Holds the Google Apps account list, ie. a list of all registered accounts on +-- the Google Apps domain. +CREATE TABLE IF NOT EXISTS `gapps_accounts` ( + -- Application-specific fields. + l_userid SMALLINT UNSIGNED DEFAULT NULL, + l_sync_password BOOL DEFAULT TRUE, + l_activate_mail_redirection BOOL DEFAULT TRUE, + + -- Shared fields. + g_account_id CHAR(16) DEFAULT NULL, + g_account_name VARCHAR(256) NOT NULL, + g_first_name VARCHAR(40) NOT NULL, + g_last_name VARCHAR(40) NOT NULL, + g_status ENUM('unprovisioned', 'disabled', 'active') DEFAULT 'unprovisioned', + g_admin BOOL DEFAULT NULL, + g_suspension VARCHAR(256) DEFAULT NULL, + + -- Google-owned fields. + r_disk_usage BIGINT DEFAULT NULL, + r_creation DATE DEFAULT NULL, + r_last_login DATE DEFAULT NULL, + r_last_webmail DATE DEFAULT NULL, + + -- Indexes. + PRIMARY KEY(g_account_name), + INDEX l_userid(l_userid) +) CHARSET=utf8; + +-- Table `gapps_queue`. +-- Holds queued API requests that are to be processed by the gappsd. It also +-- includes processed but not yet acknowledged requests. +CREATE TABLE IF NOT EXISTS `gapps_queue` ( + -- Queue identification fields. + q_id INT NOT NULL AUTO_INCREMENT, + q_owner_id SMALLINT DEFAULT NULL, + q_recipient_id SMALLINT DEFAULT NULL, + + -- Queue management information. + p_entry_date DATETIME NOT NULL, + p_notbefore_date DATETIME NOT NULL, + p_start_date DATETIME DEFAULT NULL, + p_end_date DATETIME DEFAULT NULL, + p_status ENUM('idle', 'active', 'success', 'hardfail', 'softfail') DEFAULT 'idle' NOT NULL, + p_priority ENUM('immediate', 'normal', 'offline') DEFAULT 'offline' NOT NULL, + p_admin_request BOOLEAN DEFAULT false NOT NULL, + + -- Job content fields. + j_type ENUM('r_activity', 'r_accounts', 'u_create', 'u_delete', 'u_update', 'u_sync') NOT NULL, + j_parameters TEXT DEFAULT NULL, + + -- Job execution result fields. + r_softfail_date DATETIME DEFAULT NULL, + r_softfail_count SMALLINT DEFAULT 0 NOT NULL, + r_result VARCHAR(256) DEFAULT NULL, + + -- Indexes. + PRIMARY KEY(q_id), + INDEX q_owner_id(q_owner_id), + INDEX q_recipient_id(q_recipient_id), + INDEX p_status(p_status), + INDEX p_priority(p_priority) +) CHARSET=utf8; + +-- vim:set syntax=mysql: -- 2.1.4