From dc36299dd1df10a08af6203cfbe045b5a0d206b4 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Tue, 13 Apr 2021 14:13:14 -0700 Subject: [PATCH] rename to vmail- --- ...> vmail-roundcubemail-settings-export.php} | 19 +++++++---------- ...> vmail-roundcubemail-settings-import.php} | 21 ++++++++++++------- ...il-disable.sh => vmail-webmail-disable.sh} | 0 ...mail-enable.sh => vmail-webmail-enable.sh} | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) rename bin/{roundcubemail-settings-export.php => vmail-roundcubemail-settings-export.php} (80%) rename bin/{roundcubemail-settings-import.php => vmail-roundcubemail-settings-import.php} (89%) rename bin/{webmail-disable.sh => vmail-webmail-disable.sh} (100%) rename bin/{webmail-enable.sh => vmail-webmail-enable.sh} (89%) diff --git a/bin/roundcubemail-settings-export.php b/bin/vmail-roundcubemail-settings-export.php similarity index 80% rename from bin/roundcubemail-settings-export.php rename to bin/vmail-roundcubemail-settings-export.php index b7cc224..8165271 100755 --- a/bin/roundcubemail-settings-export.php +++ b/bin/vmail-roundcubemail-settings-export.php @@ -24,20 +24,17 @@ if (!is_writable("/var/vmail/$virtualhost")) { $roundcubemail = array(); -if (!is_readable('/usr/local/etc/vmail-db-info.conf')) { - $user = posix_getpwuid(posix_geteuid()); - $username = $user['name']; - echo "/var/vmail/$virtualhost is not writable by this user ($username).\n"; - echo "re-run this script as user vmail or root or another user that can read the /usr/local/etc/vmail-db-info.conf config file\n"; +if (is_readable("/var/vmail/.my.cnf")) { + $dbHost = trim(`grep -m 1 host /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2`); + $dbDatabase = trim(`grep -m 1 database /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2`); + $dbUser = trim(`grep -m 1 user /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2`); + $dbPass = trim(`grep -m 1 password /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2`); + $dbLink = mysqli_connect($dbHost, $dbUser, "$dbPass", $dbDatabase); +} else { + echo "vmail .my.cnf config file does not exist or is not readable by you\n"; exit; } -$dbHost = trim(`grep -m 1 host /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`); -$dbDatabase = trim(`grep -m 1 database /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`); -$dbUser = trim(`grep -m 1 user /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`); -$dbPass = trim(`grep -m 1 password /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`); -$dbLink = mysqli_connect($dbHost, $dbUser, "$dbPass", $dbDatabase); - $dbQuery = "SELECT * FROM rc_users WHERE username LIKE '%@$virtualhost'"; $dbResult = mysqli_query($dbLink, $dbQuery); while ($row_users = mysqli_fetch_assoc($dbResult)) { diff --git a/bin/roundcubemail-settings-import.php b/bin/vmail-roundcubemail-settings-import.php similarity index 89% rename from bin/roundcubemail-settings-import.php rename to bin/vmail-roundcubemail-settings-import.php index 77ecdf0..6eb0e9e 100755 --- a/bin/roundcubemail-settings-import.php +++ b/bin/vmail-roundcubemail-settings-import.php @@ -9,18 +9,23 @@ if ($virtualhost == "") { exit; } -if (!is_readable("/var/vmail/$virtualhost/roundcubemail")) { +if (is_readable("/var/vmail/$virtualhost/roundcubemail")) { + $roundcubemail = unserialize(file_get_contents("/var/vmail/$virtualhost/roundcubemail")); +} else { echo "$virtualhost roundcubemail file does not exist or is not readable by you\n"; exit; } -$roundcubemail = unserialize(file_get_contents("/var/vmail/$virtualhost/roundcubemail")); - -$dbHost = trim(`grep -m 1 host /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`); -$dbDatabase = trim(`grep -m 1 database /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`); -$dbUser = trim(`grep -m 1 user /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`); -$dbPass = trim(`grep -m 1 password /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`); -$dbLink = mysqli_connect($dbHost, $dbUser, "$dbPass", $dbDatabase); +if (is_readable("/var/vmail/.my.cnf")) { + $dbHost = trim(`grep -m 1 host /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2`); + $dbDatabase = trim(`grep -m 1 database /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2`); + $dbUser = trim(`grep -m 1 user /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2`); + $dbPass = trim(`grep -m 1 password /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2`); + $dbLink = mysqli_connect($dbHost, $dbUser, "$dbPass", $dbDatabase); +} else { + echo "vmail .my.cnf config file does not exist or is not readable by you\n"; + exit; +} $user_id_new = 0; $identity_id_new = 0; diff --git a/bin/webmail-disable.sh b/bin/vmail-webmail-disable.sh similarity index 100% rename from bin/webmail-disable.sh rename to bin/vmail-webmail-disable.sh diff --git a/bin/webmail-enable.sh b/bin/vmail-webmail-enable.sh similarity index 89% rename from bin/webmail-enable.sh rename to bin/vmail-webmail-enable.sh index f2e7ca7..471ce33 100755 --- a/bin/webmail-enable.sh +++ b/bin/vmail-webmail-enable.sh @@ -25,7 +25,7 @@ fi # enable webmail vhost & restart apache if [ ! -f "/etc/apache2/sites-available/mail.$virtualhost.conf" ]; then - echo "Use VHostMAIL $virtualhost" > /etc/apache2/sites-available/mail.$virtualhost.conf + echo "Use VMailHTTPS mail.$virtualhost" > /etc/apache2/sites-available/mail.$virtualhost.conf fi if [ ! -h "/etc/apache2/sites-enabled/mail.$virtualhost.conf" ]; then