From 36930ed080f823bee984db28b20782eafdabdf1c Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Tue, 20 Apr 2021 14:26:46 -0700 Subject: [PATCH] first commit --- README.md | 9 + config/config.inc.php | 91 ++++ install.sh | 71 +++ plugins/password/config.inc.php | 496 ++++++++++++++++++ plugins/sauserprefs/config.inc.php | 126 +++++ rc.sql | 792 +++++++++++++++++++++++++++++ sbin/rc-cron.sh | 6 + systemd/rc-cron.service | 13 + systemd/rc-cron.timer | 14 + 9 files changed, 1618 insertions(+) create mode 100644 README.md create mode 100644 config/config.inc.php create mode 100644 install.sh create mode 100644 plugins/password/config.inc.php create mode 100644 plugins/sauserprefs/config.inc.php create mode 100644 rc.sql create mode 100644 sbin/rc-cron.sh create mode 100644 systemd/rc-cron.service create mode 100644 systemd/rc-cron.timer diff --git a/README.md b/README.md new file mode 100644 index 0000000..6915956 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# vmail-webmail + +## Install +``` +cd /usr/local/src +git clone https://git.stack-source.com/msb/letsencrypt-tools.git +cd letsencrypt-tools +bash install.sh +``` diff --git a/config/config.inc.php b/config/config.inc.php new file mode 100644 index 0000000..d9f5c0a --- /dev/null +++ b/config/config.inc.php @@ -0,0 +1,91 @@ + 'domain' values to support multiple hosts +// Supported replacement variables: +// %h - user's IMAP hostname +// %n - hostname ($_SERVER['SERVER_NAME']) +// %t - hostname without the first part +// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part) +// %z - IMAP domain (IMAP hostname without the first part) +// For example %n = mail.domain.tld, %t = domain.tld +$config['username_domain'] = '%d'; + +// Name your service. This is displayed on the login screen and in the window title +$config['product_name'] = ''; + +// List of active plugins (in plugins/ directory) +$config['plugins'] = array('archive', 'password', 'sauserprefs', 'zipdownload'); + +// automatically create the above listed default folders on user login +$config['create_default_folders'] = true; + +// Disable localization of the default folder names listed above +$config['show_real_foldernames'] = true; + +// Set the spell checking engine. Possible values: +// - 'googie' - the default (also used for connecting to Nox Spell Server, see 'spellcheck_uri' setting) +// - 'pspell' - requires the PHP Pspell module and aspell installed +// - 'enchant' - requires the PHP Enchant module +// - 'atd' - install your own After the Deadline server or check with the people at http://www.afterthedeadline.com before using their API +// Since Google shut down their public spell checking service, the default settings +// connect to http://spell.roundcube.net which is a hosted service provided by Roundcube. +// You can connect to any other googie-compliant service by setting 'spellcheck_uri' accordingly. +$config['spellcheck_engine'] = 'pspell'; + +// When replying: +// -1 - don't cite the original message +// 0 - place cursor below the original message +// 1 - place cursor above original message (top posting) +// 2 - place cursor above original message (top posting), but do not indent the quote +$config['reply_mode'] = 1; + +$config['archive_mbox'] = 'Archives'; + +$config['archive_type'] = 'year'; diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..525e1a8 --- /dev/null +++ b/install.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +# must be root +if [ "$USER" != "root" ]; then + echo "You must be root to run this installer." + exit +fi + +# Check for vmail-stack & vhost-stack installs & required configs +if [ -f "/usr/local/bin/vhost.sh" ] && [ -d "/srv/www/html" ] && [ -f "/usr/local/bin/vmail.sh" ] && [ -f "/var/vmail/.my.cnf" ]; then + # check for existing roundcube webmail install + if [ -d "/srv/www/html/roundcube" ]; then + echo "Roundcube webmail app is already installed." + exit + fi +else + echo "Missing required installs/configurations." + echo "You must install vhost-stack & vmail-stack first." + exit +fi + +# get current working dir, so we can come back here later +installer_dir=$(dirname $(readlink -f $0)) + +cd /usr/local/src/ +wget https://github.com/roundcube/roundcubemail/releases/download/1.4.11/roundcubemail-1.4.11-complete.tar.gz +tar zxf roundcubemail-1.4.11-complete.tar.gz +mv roundcubemail-1.4.11 /srv/www/html/roundcube + +cd /usr/local/src/ +wget https://github.com/johndoh/roundcube-sauserprefs/archive/refs/tags/1.18.4.tar.gz -O roundcube-sauserprefs-1.18.4.tar.gz +tar zxf roundcube-sauserprefs-1.18.4.tar.gz +mv roundcube-sauserprefs-1.18.4 /srv/www/html/roundcube/plugins/sauserprefs + +cd $installer_dir + +cp config/config.inc.php /srv/www/html/roundcube/config/config.inc.php +# get vmail db settings and set db connection info +dbhost=`grep -m 1 host /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2` +dbdatabase=`grep -m 1 database /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2` +dbuser=`grep -m 1 user /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2` +dbpass=`grep -m 1 password /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2` +sed -i "s|.*db_dsnw.*|\$config['db_dsnw'] = 'mysql://$dbuser:$vmail_password@$dbhost/$dbdatabase';|g" /srv/www/html/roundcube/config/config.inc.php + +# make sure pwgen is installed +apt-get -qq -y install pwgen + +# create random key +des_key=`pwgen -1 24` +sed -i "s|.*des_key.*|\$config['des_key'] = '$des_key';|g" /srv/www/html/roundcube/config/config.inc.php + +# install plugins / configs +cp -a plugins/* /srv/www/html/roundcube/plugins/ +sed -i "s|.*sauserprefs_db_dsnw*|\$config['sauserprefs_db_dsnw'] = 'mysql://$dbuser:$vmail_password@$dbhost/$dbdatabase';|g" /srv/www/html/roundcube/plugins/sauserprefs/config.inc.php + +# create tmp files storage dir +install --owner=www-data --group=www-data --mode=750 --directory /var/tmp/roundcube + +# set permissions +# # USER=$(stat -c '%U' /srv/www/html) +# # GROUP=$(stat -c '%G' /srv/www/html) +# # chown -R $USER:$GROUP /srv/www/html/roundcube +find /srv/www/html/roundcube -type d -exec chmod 755 {} + +find /srv/www/html/roundcube -type f -exec chmod 644 {} + +chmod 755 /srv/www/html/roundcube/bin/*.sh + +# load roundcube database tables +mysql vmail < rc.sql + +echo "Roundcube webmail installed." +echo "You can optionally set the vars 'product_name' & 'support_url' in /srv/www/html/roundcube/config/config.inc.php" diff --git a/plugins/password/config.inc.php b/plugins/password/config.inc.php new file mode 100644 index 0000000..e704265 --- /dev/null +++ b/plugins/password/config.inc.php @@ -0,0 +1,496 @@ + Clusters -> Remote Access Key +$config['password_cpanel_hash'] = ''; + +// The cPanel port to use +$config['password_cpanel_port'] = 2087; + + +// cPanel Webmail Driver options +// ----------------------------- +// The cPanel Host name +$config['password_cpanel_webmail_host'] = 'host.domain.com'; + +// The cPanel port to use +$config['password_cpanel_webmail_port'] = 2096; + + +// XIMSS (Communigate server) Driver options +// ----------------------------------------- +// Host name of the Communigate server +$config['password_ximss_host'] = 'mail.example.com'; + +// XIMSS port on Communigate server +$config['password_ximss_port'] = 11024; + + +// chpasswd Driver options +// --------------------- +// Command to use (see "Sudo setup" in README) +$config['password_chpasswd_cmd'] = 'sudo /usr/sbin/chpasswd 2> /dev/null'; + + +// XMail Driver options +// --------------------- +$config['xmail_host'] = 'localhost'; +$config['xmail_user'] = 'YourXmailControlUser'; +$config['xmail_pass'] = 'YourXmailControlPass'; +$config['xmail_port'] = 6017; + + +// hMail Driver options +// ----------------------- +// Remote hMailServer configuration +// true: HMailserver is on a remote box (php.ini: com.allow_dcom = true) +// false: Hmailserver is on same box as PHP +$config['hmailserver_remote_dcom'] = false; +// Windows credentials +$config['hmailserver_server'] = array( + 'Server' => 'localhost', // hostname or ip address + 'Username' => 'administrator', // windows username + 'Password' => 'password' // windows user password +); + + +// pw_usermod Driver options +// -------------------------- +// Use comma delimited exlist to disable password change for users. +// See "Sudo setup" in README file. +$config['password_pw_usermod_cmd'] = 'sudo /usr/sbin/pw usermod -h 0 -n'; + + +// DBMail Driver options +// ------------------- +// Additional arguments for the dbmail-users call +$config['password_dbmail_args'] = '-p sha512'; + + +// Expect Driver options +// --------------------- +// Location of expect binary +$config['password_expect_bin'] = '/usr/bin/expect'; + +// Location of expect script (see helpers/passwd-expect) +$config['password_expect_script'] = ''; + +// Arguments for the expect script. See the helpers/passwd-expect file for details. +// This is probably a good starting default: +// -telent -host localhost -output /tmp/passwd.log -log /tmp/passwd.log +$config['password_expect_params'] = ''; + + +// smb Driver options +// --------------------- +// Samba host (default: localhost) +// Supported replacement variables: +// %n - hostname ($_SERVER['SERVER_NAME']) +// %t - hostname without the first part +// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part) +$config['password_smb_host'] = 'localhost'; +// Location of smbpasswd binary (default: /usr/bin/smbpasswd) +$config['password_smb_cmd'] = '/usr/bin/smbpasswd'; + +// gearman driver options +// --------------------- +// Gearman host (default: localhost) +$config['password_gearman_host'] = 'localhost'; + + +// Plesk/PPA Driver options +// -------------------- +// You need to allow RCP for IP of roundcube-server in Plesk/PPA Panel + +// Plesk RCP Host +$config['password_plesk_host'] = '10.0.0.5'; + +// Plesk RPC Username +$config['password_plesk_user'] = 'admin'; + +// Plesk RPC Password +$config['password_plesk_pass'] = 'password'; + +// Plesk RPC Port +$config['password_plesk_rpc_port'] = '8443'; + +// Plesk RPC Path +$config['password_plesk_rpc_path'] = 'enterprise/control/agent.php'; + + +// kasswd Driver options +// --------------------- +// Command to use +$config['password_kpasswd_cmd'] = '/usr/bin/kpasswd'; + + +// Modoboa Driver options +// --------------------- +// put token number from Modoboa server +$config['password_modoboa_api_token'] = ''; diff --git a/plugins/sauserprefs/config.inc.php b/plugins/sauserprefs/config.inc.php new file mode 100644 index 0000000..48eb40e --- /dev/null +++ b/plugins/sauserprefs/config.inc.php @@ -0,0 +1,126 @@ + 'mail1_config.inc.php', +// 'mail2.domain.tld' => 'mail2_config.inc.php', +// ); +$config['sauserprefs_host_config'] = null; + +// default settings +// these are overridden by $GLOBAL and user settings from the database +$config['sauserprefs_default_prefs'] = array( +// 'required_score' => 5, +// 'rewrite_header Subject' => '', +// 'ok_languages' => 'all', +// 'ok_locales' => 'all', +// 'fold_headers' => 1, +// 'add_header all Level' => '_STARS(*)_', +// 'use_razor1' => 0, +// 'use_razor2' => 1, +// 'use_pyzor' => 1, +// 'use_dcc' => 1, +// 'use_bayes' => 1, +// 'skip_rbl_checks' => 0, +// 'report_safe' => 1, +// 'bayes_auto_learn' => 1, +// 'bayes_auto_learn_threshold_nonspam' => 0.1, +// 'bayes_auto_learn_threshold_spam' => 12.0, +// 'use_bayes_rules' => 1, +// 'use_auto_whitelist' => 0, +// 'score USER_IN_BLACKLIST' => 10, +// 'score USER_IN_WHITELIST' => -10 + ); + +// score options +// define the ranges for the various score select boxes +// '[field name]' => array('min' => [min], 'max' => [max], 'increment' => [increment], 'extra' => array()) +// note: the 'extra' key is optional and should contain further arrays with min, max and increment keys +$config['sauserprefs_score_options'] = array( +// '*' => array('min' => 1, 'max' => 10, 'increment' => 1), +// '_bayesnonspam' => array('min' => -1, 'max' => 1, 'increment' => 0.1), +// '_bayesspam' => array('min' => 1, 'max' => 20, 'increment' => 1), + '_score_user_blacklist' => array('min' => 0, 'max' => 100, 'increment' => 10, 'extra' => array(array('min' => 1, 'max' => 10, 'increment' => 1))), + '_score_user_whitelist' => array('min' => -100, 'max' => -1, 'increment' => 10, 'extra' => array(array('min' => -10, 'max' => -1, 'increment' => 1))) + ); + +// delete user bayesian data stored in database +// the query can contain the following macros that will be expanded as follows: +// %u is replaced with the username from the sauserprefs_userid setting above +// use an array to run multiple queries +// set to null to disable this option +// eg. $config['sauserprefs_bayes_delete_query'] = array( +// 'DELETE FROM bayes_seen WHERE id IN (SELECT id FROM bayes_vars WHERE username = %u);', +// 'DELETE FROM bayes_token WHERE id IN (SELECT id FROM bayes_vars WHERE username = %u);', +// 'DELETE FROM bayes_vars WHERE username = %u;' +// ); +$config['sauserprefs_bayes_delete_query'] = null; + +// allowed languages +// set to array of language codes to limit the language list available for the ok_languages option +// eg array('en', 'es', 'ru', 'zh'); +// see the README for a full list of supported languages +// set to null for all possible languages +$config['sauserprefs_langs_allowed'] = null; diff --git a/rc.sql b/rc.sql new file mode 100644 index 0000000..059a5b9 --- /dev/null +++ b/rc.sql @@ -0,0 +1,792 @@ +-- Host: localhost + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `vmail` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_cache` +-- + +CREATE TABLE `rc_cache` ( + `user_id` int(10) UNSIGNED NOT NULL, + `cache_key` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `expires` datetime DEFAULT NULL, + `data` longtext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_cache`: +-- `user_id` +-- `rc_users` -> `user_id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_cache_index` +-- + +CREATE TABLE `rc_cache_index` ( + `user_id` int(10) UNSIGNED NOT NULL, + `mailbox` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `expires` datetime DEFAULT NULL, + `valid` tinyint(1) NOT NULL DEFAULT 0, + `data` longtext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_cache_index`: +-- `user_id` +-- `rc_users` -> `user_id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_cache_messages` +-- + +CREATE TABLE `rc_cache_messages` ( + `user_id` int(10) UNSIGNED NOT NULL, + `mailbox` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `uid` int(11) UNSIGNED NOT NULL DEFAULT 0, + `expires` datetime DEFAULT NULL, + `data` longtext NOT NULL, + `flags` int(11) NOT NULL DEFAULT 0 +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_cache_messages`: +-- `user_id` +-- `rc_users` -> `user_id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_cache_shared` +-- + +CREATE TABLE `rc_cache_shared` ( + `cache_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `expires` datetime DEFAULT NULL, + `data` longtext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_cache_shared`: +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_cache_thread` +-- + +CREATE TABLE `rc_cache_thread` ( + `user_id` int(10) UNSIGNED NOT NULL, + `mailbox` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `expires` datetime DEFAULT NULL, + `data` longtext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_cache_thread`: +-- `user_id` +-- `rc_users` -> `user_id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_carddav_addressbooks` +-- + +CREATE TABLE `rc_carddav_addressbooks` ( + `id` int(10) UNSIGNED NOT NULL, + `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `username` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `password` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `url` varchar(4095) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `active` tinyint(3) UNSIGNED NOT NULL DEFAULT 1, + `user_id` int(10) UNSIGNED NOT NULL, + `last_updated` timestamp NOT NULL DEFAULT '2000-01-01 08:00:01', + `refresh_time` time NOT NULL DEFAULT '01:00:00', + `sync_token` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `presetname` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `use_categories` int(11) NOT NULL DEFAULT 0 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- RELATIONSHIPS FOR TABLE `rc_carddav_addressbooks`: +-- `user_id` +-- `rc_users` -> `user_id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_carddav_contacts` +-- + +CREATE TABLE `rc_carddav_contacts` ( + `id` int(10) UNSIGNED NOT NULL, + `abook_id` int(10) UNSIGNED NOT NULL, + `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `email` varchar(4095) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `firstname` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `surname` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `organization` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `showas` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `vcard` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `etag` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `uri` varchar(700) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `cuid` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- RELATIONSHIPS FOR TABLE `rc_carddav_contacts`: +-- `abook_id` +-- `rc_carddav_addressbooks` -> `id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_carddav_groups` +-- + +CREATE TABLE `rc_carddav_groups` ( + `id` int(10) UNSIGNED NOT NULL, + `abook_id` int(10) UNSIGNED NOT NULL, + `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `vcard` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `etag` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `uri` varchar(700) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `cuid` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- RELATIONSHIPS FOR TABLE `rc_carddav_groups`: +-- `abook_id` +-- `rc_carddav_addressbooks` -> `id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_carddav_group_user` +-- + +CREATE TABLE `rc_carddav_group_user` ( + `group_id` int(10) UNSIGNED NOT NULL, + `contact_id` int(10) UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- RELATIONSHIPS FOR TABLE `rc_carddav_group_user`: +-- `group_id` +-- `rc_carddav_groups` -> `id` +-- `contact_id` +-- `rc_carddav_contacts` -> `id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_carddav_migrations` +-- + +CREATE TABLE `rc_carddav_migrations` ( + `ID` bigint(20) UNSIGNED NOT NULL, + `filename` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `processed_at` timestamp NOT NULL DEFAULT current_timestamp() +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- RELATIONSHIPS FOR TABLE `rc_carddav_migrations`: +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_carddav_xsubtypes` +-- + +CREATE TABLE `rc_carddav_xsubtypes` ( + `id` int(10) UNSIGNED NOT NULL, + `typename` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `subtype` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `abook_id` int(10) UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- RELATIONSHIPS FOR TABLE `rc_carddav_xsubtypes`: +-- `abook_id` +-- `rc_carddav_addressbooks` -> `id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_contactgroupmembers` +-- + +CREATE TABLE `rc_contactgroupmembers` ( + `contactgroup_id` int(10) UNSIGNED NOT NULL, + `contact_id` int(10) UNSIGNED NOT NULL, + `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- +-- RELATIONSHIPS FOR TABLE `rc_contactgroupmembers`: +-- `contact_id` +-- `rc_contacts` -> `contact_id` +-- `contactgroup_id` +-- `rc_contactgroups` -> `contactgroup_id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_contactgroups` +-- + +CREATE TABLE `rc_contactgroups` ( + `contactgroup_id` int(10) UNSIGNED NOT NULL, + `user_id` int(10) UNSIGNED NOT NULL, + `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00', + `del` tinyint(1) NOT NULL DEFAULT 0, + `name` varchar(128) NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_contactgroups`: +-- `user_id` +-- `rc_users` -> `user_id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_contacts` +-- + +CREATE TABLE `rc_contacts` ( + `contact_id` int(10) UNSIGNED NOT NULL, + `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00', + `del` tinyint(1) NOT NULL DEFAULT 0, + `name` varchar(128) NOT NULL DEFAULT '', + `email` text NOT NULL, + `firstname` varchar(128) NOT NULL DEFAULT '', + `surname` varchar(128) NOT NULL DEFAULT '', + `vcard` longtext DEFAULT NULL, + `words` text DEFAULT NULL, + `user_id` int(10) UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_contacts`: +-- `user_id` +-- `rc_users` -> `user_id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_dictionary` +-- + +CREATE TABLE `rc_dictionary` ( + `id` int(10) UNSIGNED NOT NULL, + `user_id` int(10) UNSIGNED DEFAULT NULL, + `language` varchar(5) NOT NULL, + `data` longtext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_dictionary`: +-- `user_id` +-- `rc_users` -> `user_id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_filestore` +-- + +CREATE TABLE `rc_filestore` ( + `file_id` int(10) UNSIGNED NOT NULL, + `user_id` int(10) UNSIGNED NOT NULL, + `context` varchar(32) NOT NULL, + `filename` varchar(128) NOT NULL, + `mtime` int(10) NOT NULL, + `data` longtext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_filestore`: +-- `user_id` +-- `rc_users` -> `user_id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_identities` +-- + +CREATE TABLE `rc_identities` ( + `identity_id` int(10) UNSIGNED NOT NULL, + `user_id` int(10) UNSIGNED NOT NULL, + `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00', + `del` tinyint(1) NOT NULL DEFAULT 0, + `standard` tinyint(1) NOT NULL DEFAULT 0, + `name` varchar(128) NOT NULL, + `organization` varchar(128) NOT NULL DEFAULT '', + `email` varchar(128) NOT NULL, + `reply-to` varchar(128) NOT NULL DEFAULT '', + `bcc` varchar(128) NOT NULL DEFAULT '', + `signature` longtext DEFAULT NULL, + `html_signature` tinyint(1) NOT NULL DEFAULT 0 +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_identities`: +-- `user_id` +-- `rc_users` -> `user_id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_searches` +-- + +CREATE TABLE `rc_searches` ( + `search_id` int(10) UNSIGNED NOT NULL, + `user_id` int(10) UNSIGNED NOT NULL, + `type` int(3) NOT NULL DEFAULT 0, + `name` varchar(128) NOT NULL, + `data` text DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_searches`: +-- `user_id` +-- `rc_users` -> `user_id` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_session` +-- + +CREATE TABLE `rc_session` ( + `sess_id` varchar(128) NOT NULL, + `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00', + `ip` varchar(40) NOT NULL, + `vars` mediumtext NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_session`: +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_system` +-- + +CREATE TABLE `rc_system` ( + `name` varchar(64) NOT NULL, + `value` mediumtext DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_system`: +-- + +-- +-- Dumping data for table `rc_system` +-- + +INSERT INTO `rc_system` (`name`, `value`) VALUES +('roundcube-version', '2019092900'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rc_users` +-- + +CREATE TABLE `rc_users` ( + `user_id` int(10) UNSIGNED NOT NULL, + `username` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `mail_host` varchar(128) NOT NULL, + `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00', + `last_login` datetime DEFAULT NULL, + `failed_login` datetime DEFAULT NULL, + `failed_login_counter` int(10) UNSIGNED DEFAULT NULL, + `language` varchar(5) DEFAULT NULL, + `preferences` longtext DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- RELATIONSHIPS FOR TABLE `rc_users`: +-- + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `rc_cache` +-- +ALTER TABLE `rc_cache` + ADD PRIMARY KEY (`user_id`,`cache_key`), + ADD KEY `expires_index` (`expires`); + +-- +-- Indexes for table `rc_cache_index` +-- +ALTER TABLE `rc_cache_index` + ADD PRIMARY KEY (`user_id`,`mailbox`), + ADD KEY `expires_index` (`expires`); + +-- +-- Indexes for table `rc_cache_messages` +-- +ALTER TABLE `rc_cache_messages` + ADD PRIMARY KEY (`user_id`,`mailbox`,`uid`), + ADD KEY `expires_index` (`expires`); + +-- +-- Indexes for table `rc_cache_shared` +-- +ALTER TABLE `rc_cache_shared` + ADD PRIMARY KEY (`cache_key`), + ADD KEY `expires_index` (`expires`); + +-- +-- Indexes for table `rc_cache_thread` +-- +ALTER TABLE `rc_cache_thread` + ADD PRIMARY KEY (`user_id`,`mailbox`), + ADD KEY `expires_index` (`expires`); + +-- +-- Indexes for table `rc_carddav_addressbooks` +-- +ALTER TABLE `rc_carddav_addressbooks` + ADD PRIMARY KEY (`id`), + ADD KEY `user_id` (`user_id`) USING BTREE; + +-- +-- Indexes for table `rc_carddav_contacts` +-- +ALTER TABLE `rc_carddav_contacts` + ADD PRIMARY KEY (`id`), + ADD UNIQUE KEY `cuid` (`cuid`(191),`abook_id`) USING BTREE, + ADD UNIQUE KEY `uri` (`uri`(191),`abook_id`) USING BTREE, + ADD KEY `abook_id` (`abook_id`); + +-- +-- Indexes for table `rc_carddav_groups` +-- +ALTER TABLE `rc_carddav_groups` + ADD PRIMARY KEY (`id`), + ADD UNIQUE KEY `cuid` (`cuid`(191),`abook_id`) USING BTREE, + ADD UNIQUE KEY `uri` (`uri`(191),`abook_id`) USING BTREE, + ADD KEY `abook_id` (`abook_id`); + +-- +-- Indexes for table `rc_carddav_group_user` +-- +ALTER TABLE `rc_carddav_group_user` + ADD PRIMARY KEY (`group_id`,`contact_id`), + ADD KEY `contact_id` (`contact_id`); + +-- +-- Indexes for table `rc_carddav_migrations` +-- +ALTER TABLE `rc_carddav_migrations` + ADD PRIMARY KEY (`ID`), + ADD UNIQUE KEY `filename` (`filename`); + +-- +-- Indexes for table `rc_carddav_xsubtypes` +-- +ALTER TABLE `rc_carddav_xsubtypes` + ADD PRIMARY KEY (`id`), + ADD UNIQUE KEY `typename` (`typename`,`subtype`,`abook_id`), + ADD KEY `abook_id` (`abook_id`); + +-- +-- Indexes for table `rc_contactgroupmembers` +-- +ALTER TABLE `rc_contactgroupmembers` + ADD PRIMARY KEY (`contactgroup_id`,`contact_id`), + ADD KEY `contactgroupmembers_contact_index` (`contact_id`); + +-- +-- Indexes for table `rc_contactgroups` +-- +ALTER TABLE `rc_contactgroups` + ADD PRIMARY KEY (`contactgroup_id`), + ADD KEY `contactgroups_user_index` (`user_id`,`del`); + +-- +-- Indexes for table `rc_contacts` +-- +ALTER TABLE `rc_contacts` + ADD PRIMARY KEY (`contact_id`), + ADD KEY `user_contacts_index` (`user_id`,`del`); + +-- +-- Indexes for table `rc_dictionary` +-- +ALTER TABLE `rc_dictionary` + ADD PRIMARY KEY (`id`), + ADD UNIQUE KEY `uniqueness` (`user_id`,`language`); + +-- +-- Indexes for table `rc_filestore` +-- +ALTER TABLE `rc_filestore` + ADD PRIMARY KEY (`file_id`), + ADD UNIQUE KEY `uniqueness` (`user_id`,`context`,`filename`); + +-- +-- Indexes for table `rc_identities` +-- +ALTER TABLE `rc_identities` + ADD PRIMARY KEY (`identity_id`), + ADD KEY `user_identities_index` (`user_id`,`del`), + ADD KEY `email_identities_index` (`email`,`del`); + +-- +-- Indexes for table `rc_searches` +-- +ALTER TABLE `rc_searches` + ADD PRIMARY KEY (`search_id`), + ADD UNIQUE KEY `uniqueness` (`user_id`,`type`,`name`); + +-- +-- Indexes for table `rc_session` +-- +ALTER TABLE `rc_session` + ADD PRIMARY KEY (`sess_id`), + ADD KEY `changed_index` (`changed`); + +-- +-- Indexes for table `rc_system` +-- +ALTER TABLE `rc_system` + ADD PRIMARY KEY (`name`); + +-- +-- Indexes for table `rc_users` +-- +ALTER TABLE `rc_users` + ADD PRIMARY KEY (`user_id`), + ADD UNIQUE KEY `username` (`username`,`mail_host`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `rc_carddav_addressbooks` +-- +ALTER TABLE `rc_carddav_addressbooks` + MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `rc_carddav_contacts` +-- +ALTER TABLE `rc_carddav_contacts` + MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `rc_carddav_groups` +-- +ALTER TABLE `rc_carddav_groups` + MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `rc_carddav_migrations` +-- +ALTER TABLE `rc_carddav_migrations` + MODIFY `ID` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `rc_carddav_xsubtypes` +-- +ALTER TABLE `rc_carddav_xsubtypes` + MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `rc_contactgroups` +-- +ALTER TABLE `rc_contactgroups` + MODIFY `contactgroup_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `rc_contacts` +-- +ALTER TABLE `rc_contacts` + MODIFY `contact_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `rc_dictionary` +-- +ALTER TABLE `rc_dictionary` + MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `rc_filestore` +-- +ALTER TABLE `rc_filestore` + MODIFY `file_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `rc_identities` +-- +ALTER TABLE `rc_identities` + MODIFY `identity_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `rc_searches` +-- +ALTER TABLE `rc_searches` + MODIFY `search_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `rc_users` +-- +ALTER TABLE `rc_users` + MODIFY `user_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- Constraints for dumped tables +-- + +-- +-- Constraints for table `rc_cache` +-- +ALTER TABLE `rc_cache` + ADD CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_cache_index` +-- +ALTER TABLE `rc_cache_index` + ADD CONSTRAINT `user_id_fk_cache_index` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_cache_messages` +-- +ALTER TABLE `rc_cache_messages` + ADD CONSTRAINT `user_id_fk_cache_messages` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_cache_thread` +-- +ALTER TABLE `rc_cache_thread` + ADD CONSTRAINT `user_id_fk_cache_thread` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_carddav_addressbooks` +-- +ALTER TABLE `rc_carddav_addressbooks` + ADD CONSTRAINT `rc_carddav_addressbooks_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_carddav_contacts` +-- +ALTER TABLE `rc_carddav_contacts` + ADD CONSTRAINT `rc_carddav_contacts_ibfk_1` FOREIGN KEY (`abook_id`) REFERENCES `rc_carddav_addressbooks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_carddav_groups` +-- +ALTER TABLE `rc_carddav_groups` + ADD CONSTRAINT `rc_carddav_groups_ibfk_1` FOREIGN KEY (`abook_id`) REFERENCES `rc_carddav_addressbooks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_carddav_group_user` +-- +ALTER TABLE `rc_carddav_group_user` + ADD CONSTRAINT `rc_carddav_group_user_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `rc_carddav_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `rc_carddav_group_user_ibfk_2` FOREIGN KEY (`contact_id`) REFERENCES `rc_carddav_contacts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_carddav_xsubtypes` +-- +ALTER TABLE `rc_carddav_xsubtypes` + ADD CONSTRAINT `rc_carddav_xsubtypes_ibfk_1` FOREIGN KEY (`abook_id`) REFERENCES `rc_carddav_addressbooks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_contactgroupmembers` +-- +ALTER TABLE `rc_contactgroupmembers` + ADD CONSTRAINT `contact_id_fk_contacts` FOREIGN KEY (`contact_id`) REFERENCES `rc_contacts` (`contact_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `contactgroup_id_fk_contactgroups` FOREIGN KEY (`contactgroup_id`) REFERENCES `rc_contactgroups` (`contactgroup_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_contactgroups` +-- +ALTER TABLE `rc_contactgroups` + ADD CONSTRAINT `user_id_fk_contactgroups` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_contacts` +-- +ALTER TABLE `rc_contacts` + ADD CONSTRAINT `user_id_fk_contacts` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_dictionary` +-- +ALTER TABLE `rc_dictionary` + ADD CONSTRAINT `user_id_fk_dictionary` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_filestore` +-- +ALTER TABLE `rc_filestore` + ADD CONSTRAINT `user_id_fk_filestore` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_identities` +-- +ALTER TABLE `rc_identities` + ADD CONSTRAINT `user_id_fk_identities` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `rc_searches` +-- +ALTER TABLE `rc_searches` + ADD CONSTRAINT `user_id_fk_searches` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/sbin/rc-cron.sh b/sbin/rc-cron.sh new file mode 100644 index 0000000..b20f51a --- /dev/null +++ b/sbin/rc-cron.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +/usr/bin/php /srv/www/html/roundcube/bin/cleandb.sh > /dev/null +/usr/bin/php /srv/www/html/roundcube/bin/deluser.sh --age=365 --dry-run > /dev/null +/usr/bin/php /srv/www/html/roundcube/bin/gc.sh +/usr/bin/php /srv/www/html/roundcube/bin/indexcontacts.sh > /dev/null diff --git a/systemd/rc-cron.service b/systemd/rc-cron.service new file mode 100644 index 0000000..0e097c2 --- /dev/null +++ b/systemd/rc-cron.service @@ -0,0 +1,13 @@ +# vmail-webmail +# https://git.stack-source.com/msb/vmail-webmail +# MIT License Copyright (c) 2021 Matthew Saunders Brown +# +[Unit] +Description=Roundcube cron + +[Service] +Type=simple +ExecStart=/usr/local/sbin/rc-cron.sh + +[Install] +WantedBy=multi-user.target diff --git a/systemd/rc-cron.timer b/systemd/rc-cron.timer new file mode 100644 index 0000000..e4572d2 --- /dev/null +++ b/systemd/rc-cron.timer @@ -0,0 +1,14 @@ +# vmail-webmail +# https://git.stack-source.com/msb/vmail-webmail +# MIT License Copyright (c) 2021 Matthew Saunders Brown +# +[Unit] +Description=Roundcubemail cron once per day + +[Timer] +OnCalendar=daily +Unit=rc-cron.service +AccuracySec=6h + +[Install] +WantedBy=multi-user.target