rename to vmail-

This commit is contained in:
Matthew Saunders Brown 2021-04-13 14:13:14 -07:00
parent 3585a8c0ad
commit dc36299dd1
4 changed files with 22 additions and 20 deletions

View File

@ -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)) {

View File

@ -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`);
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;

View File

@ -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