diff --git a/README.md b/README.md index fbc9789..f876a98 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,8 @@ Install [acme.sh](https://github.com/acmesh-official/acme.sh) or [certbot](https nano /etc/postfix/main.cf /etc/nginx/nginx.conf /etc/turnserver.conf ``` +Replace `YOUR_PASSWORD` in `/etc/postfix/sql/mysql_tls_policy_out.cf` with the one you've generated previously on the other server. + Generate a wireguard keypair and add the public key generated here to the primary mail server wireguard config: ``` export PRIV=$(wg genkey) @@ -152,6 +154,12 @@ nano /etc/wireguard/wg0.conf systemctl enable wg-quick@wg0 && systemctl start wg-quick@wg0 ``` +Edit and create your admin user with the following script: +``` +nano /var/www/mail/tools/create_admin.php +php /var/www/mail/tools/create_admin.php +``` + Final step is to reboot the server and check that everything is working. ### General Domain settings diff --git a/common_config.php b/common_config.php index 18ab453..07bcff5 100644 --- a/common_config.php +++ b/common_config.php @@ -27,6 +27,7 @@ const DBUSER_PROSODY = 'prosody'; // Database user const DBPASS_PROSODY = 'YOUR_PASSWORD'; // Database password const DBNAME_PROSODY = 'prosody'; // Database const REGISTRATION_ENABLED = true; // Whether registration is enabled +const PRIMARY_DOMAIN='danwin1210.de'; // Primary domain to use when a username without domain part was specified const LANGUAGES = [ 'cs' => ['name' => 'čeština', 'locale' => 'cs_CZ', 'flag' => '🇨🇿', 'show_in_menu' => true, 'dir' => 'ltr'], diff --git a/install_binaries.sh b/install_binaries.sh index d50829c..a552805 100755 --- a/install_binaries.sh +++ b/install_binaries.sh @@ -52,7 +52,7 @@ chown _rspamd: /var/lib/rspamd/dkim if [ ! -e /var/www/html/mail ]; then ln -s ../mail/www /var/www/html/mail fi -cp -r composer.json cron.php setup.php www /var/www/mail/ +cp -r composer.json cron.php setup.php www tools /var/www/mail/ cd /var/www/mail/ composer install --no-dev diff --git a/tools/create_admin.php b/tools/create_admin.php new file mode 100644 index 0000000..abeff1b --- /dev/null +++ b/tools/create_admin.php @@ -0,0 +1,11 @@ +prepare( 'INSERT INTO admin (password_hash_type, password, superadmin, username, created, modified) VALUES ("{ARGON2ID}", ?, 1, ?, NOW(), NOW());' ); +$stmt->execute( [ $hash, ADMIN_USER ] ); +$stmt = $db->prepare( 'INSERT IGNORE INTO domain (domain, created, modified) VALUES (?, NOW(), NOW())' ); +$stmt->execute( [ PRIMARY_DOMAIN ] ); \ No newline at end of file diff --git a/www/manage_account.php b/www/manage_account.php index 837d5af..26fc177 100644 --- a/www/manage_account.php +++ b/www/manage_account.php @@ -49,7 +49,7 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) { if ( $ok ) { $db = get_db_instance(); $user = $match[ 1 ]; - $domain = $match[ 3 ] ?? 'danwin1210.de'; + $domain = $match[ 3 ] ?? PRIMARY_DOMAIN; $stmt = $db->prepare( 'SELECT target_domain FROM alias_domain WHERE alias_domain = ? AND active=1;' ); $stmt->execute( [ $domain ] ); if ( $tmp = $stmt->fetch( PDO::FETCH_ASSOC ) ) { diff --git a/www/register.php b/www/register.php index 7c86006..05a57e5 100644 --- a/www/register.php +++ b/www/register.php @@ -31,7 +31,7 @@ if ( isset( $_POST[ 'user' ] ) ) { $msg .= ''; } $user = mb_strtolower( $match[ 1 ] ?? '' ); - $domain = $match[ 3 ] ?? 'danwin1210.de'; + $domain = $match[ 3 ] ?? PRIMARY_DOMAIN; if ( $ok && ( empty( $_POST[ 'pwd' ] ) || empty( $_POST[ 'pwd2' ] ) || $_POST[ 'pwd' ] !== $_POST[ 'pwd2' ] ) ) { $ok = false; $msg .= '';