From 0af593eec801eaeaf2af2fd54d848b840a619a0e Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Sat, 11 May 2024 12:54:43 +0300 Subject: [PATCH] update --- web/Modules/Email/ldap-compose.yaml | 38 +++++++++++++++++++ .../Email/shell-scripts/install-docker.sh | 4 -- web/app/Models/Backup.php | 20 +++++----- 3 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 web/Modules/Email/ldap-compose.yaml diff --git a/web/Modules/Email/ldap-compose.yaml b/web/Modules/Email/ldap-compose.yaml new file mode 100644 index 00000000..47dba255 --- /dev/null +++ b/web/Modules/Email/ldap-compose.yaml @@ -0,0 +1,38 @@ +services: + phyre-mail-server: + image: ghcr.io/docker-mailserver/docker-mailserver:latest + container_name: mailserver + # Provide the FQDN of your mail server here (Your DNS MX record should point to this value) + hostname: mail.test.phyrepanel.com + ports: + - "25:25" + - "465:465" + - "587:587" + - "993:993" + volumes: + - ./docker-data/dms/mail-data/:/var/mail/ + - ./docker-data/dms/mail-state/:/var/mail-state/ + - ./docker-data/dms/mail-logs/:/var/log/mail/ + - ./docker-data/dms/config/:/tmp/docker-mailserver/ + - /etc/localtime:/etc/localtime:ro + environment: + - ACCOUNT_PROVISIONER=LDAP + - LDAP_SERVER_HOST=ldap # your ldap container/IP/ServerName + - LDAP_SEARCH_BASE=ou=people,dc=localhost,dc=localdomain + - LDAP_BIND_DN=cn=admin,dc=localhost,dc=localdomain + - LDAP_BIND_PW=admin + - LDAP_QUERY_FILTER_USER=(&(mail=%s)(mailEnabled=TRUE)) + - LDAP_QUERY_FILTER_GROUP=(&(mailGroupMember=%s)(mailEnabled=TRUE)) + - LDAP_QUERY_FILTER_ALIAS=(|(&(mailAlias=%s)(objectClass=PostfixBookMailForward))(&(mailAlias=%s)(objectClass=PostfixBookMailAccount)(mailEnabled=TRUE))) + - LDAP_QUERY_FILTER_DOMAIN=(|(&(mail=*@%s)(objectClass=PostfixBookMailAccount)(mailEnabled=TRUE))(&(mailGroupMember=*@%s)(objectClass=PostfixBookMailAccount)(mailEnabled=TRUE))(&(mailalias=*@%s)(objectClass=PostfixBookMailForward))) + - DOVECOT_PASS_FILTER=(&(objectClass=PostfixBookMailAccount)(uniqueIdentifier=%n)) + - DOVECOT_USER_FILTER=(&(objectClass=PostfixBookMailAccount)(uniqueIdentifier=%n)) + - ENABLE_SASLAUTHD=1 + - SASLAUTHD_MECHANISMS=ldap + - SASLAUTHD_LDAP_SERVER=ldap + - SASLAUTHD_LDAP_BIND_DN=cn=admin,dc=localhost,dc=localdomain + - SASLAUTHD_LDAP_PASSWORD=admin + - SASLAUTHD_LDAP_SEARCH_BASE=ou=people,dc=localhost,dc=localdomain + - SASLAUTHD_LDAP_FILTER=(&(objectClass=PostfixBookMailAccount)(uniqueIdentifier=%U)) + - POSTMASTER_ADDRESS=postmaster@localhost.localdomain + restart: always diff --git a/web/Modules/Email/shell-scripts/install-docker.sh b/web/Modules/Email/shell-scripts/install-docker.sh index ed9b73da..f5ec9c10 100644 --- a/web/Modules/Email/shell-scripts/install-docker.sh +++ b/web/Modules/Email/shell-scripts/install-docker.sh @@ -13,8 +13,4 @@ sudo apt-get update sudo apt-get install docker-compose docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y - - - - echo "Done!" diff --git a/web/app/Models/Backup.php b/web/app/Models/Backup.php index 726b6236..742d7cd2 100644 --- a/web/app/Models/Backup.php +++ b/web/app/Models/Backup.php @@ -98,34 +98,34 @@ public function checkBackup() shell_exec('cd '.$tempValidatePath.' && unzip -o '.$this->file_path); $validateDatabaseFile = $tempValidatePath.'/database.sql'; - $validateEnvFile = $tempValidatePath.'/.env'; + $validatePhyreConfigFile = $tempValidatePath.'/phyre-config.ini'; $errorsBag = []; if (! file_exists($validateDatabaseFile)) { $errorsBag[] = 'Database file not found'; } - if (! file_exists($validateEnvFile)) { - $errorsBag[] = 'Env file not found'; + if (! file_exists($validatePhyreConfigFile)) { + $errorsBag[] = 'Phyre config file not found'; } if (count($errorsBag) > 0) { $this->status = 'failed'; - $this->backup_log = 'Backup failed. Database or env file missing.'; + $this->backup_log = 'Backup failed. Database or phyre config file missing.'; $this->save(); return [ 'status' => 'failed', - 'message' => 'Backup failed. Database or env file missing.', + 'message' => 'Backup failed. Database or phyre config file missing.', 'errors' => $errorsBag ]; } - $originalEnvContent = file_get_contents(base_path().'/.env'); - $backupEnvContent = file_get_contents($validateEnvFile); - if ($originalEnvContent != $backupEnvContent) { - $errorsBag[] = 'Env file content mismatch'; + $originalPhyreConfigContent = file_get_contents(base_path().'/phyre-config.ini'); + $backupPhyreConfigContent = file_get_contents($validatePhyreConfigFile); + if ($originalPhyreConfigContent != $backupPhyreConfigContent) { + $errorsBag[] = 'Phyre config content mismatch'; } if (count($errorsBag) > 0) { $this->status = 'failed'; - $this->backup_log = 'Backup failed. Database or env file content mismatch.'; + $this->backup_log = 'Backup failed. Database or phyre config file content mismatch.'; $this->save(); return [ 'status' => 'failed',