Add primary domain in setup.php

This commit is contained in:
Daniel Winzen 2024-06-06 16:38:45 +02:00
parent f197f10228
commit bef733240f
No known key found for this signature in database
GPG key ID: 222FCC3F35C41077
7 changed files with 15 additions and 6 deletions

View file

@ -160,6 +160,8 @@ nano /var/www/mail/tools/create_admin.php
php /var/www/mail/tools/create_admin.php php /var/www/mail/tools/create_admin.php
``` ```
Copy the file `/etc/postfix/danwin1210-mail.crt` from your main server to the same location on the proxy server.
Final step is to reboot the server and check that everything is working. Final step is to reboot the server and check that everything is working.
### General Domain settings ### General Domain settings

View file

@ -27,7 +27,6 @@ const DBUSER_PROSODY = 'prosody'; // Database user
const DBPASS_PROSODY = 'YOUR_PASSWORD'; // Database password const DBPASS_PROSODY = 'YOUR_PASSWORD'; // Database password
const DBNAME_PROSODY = 'prosody'; // Database const DBNAME_PROSODY = 'prosody'; // Database
const REGISTRATION_ENABLED = true; // Whether registration is enabled 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 = [ const LANGUAGES = [
'cs' => ['name' => 'čeština', 'locale' => 'cs_CZ', 'flag' => '🇨🇿', 'show_in_menu' => true, 'dir' => 'ltr'], 'cs' => ['name' => 'čeština', 'locale' => 'cs_CZ', 'flag' => '🇨🇿', 'show_in_menu' => true, 'dir' => 'ltr'],

View file

@ -36,7 +36,7 @@ ip6tables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -i lo -j ACCEPT
ip6tables -A INPUT -i lo -j ACCEPT ip6tables -A INPUT -i lo -j ACCEPT
#unrestricted access to these IPs #unrestricted access to these IPs
for clearnet in 127.0.0.0/8; do( for clearnet in 127.0.0.0/8 10.9.0.0/24; do(
iptables -t nat -A OUTPUT -d $clearnet -j RETURN iptables -t nat -A OUTPUT -d $clearnet -j RETURN
iptables -A OUTPUT -d $clearnet -j ACCEPT iptables -A OUTPUT -d $clearnet -j ACCEPT
) done ) done

View file

@ -60,3 +60,13 @@ try{
echo $e->getMessage() . PHP_EOL; echo $e->getMessage() . PHP_EOL;
} }
} }
try {
$stmt = $db->prepare( 'INSERT IGNORE INTO domain (domain, created, modified) VALUES (?, NOW(), NOW())' );
$stmt->execute( [ CLEARNET_SERVER ] );
$stmt->execute( [ ONION_SERVER ] );
$stmt = $db->prepare( 'INSERT IGNORE INTO alias_domain (alias_domain, target_domain, created, modified) VALUES (?, ?, NOW(), NOW())' );
$stmt->execute( [ ONION_SERVER, CLEARNET_SERVER ] );
} catch( PDOException $e ) {
echo _('Error adding primary domain:') . PHP_EOL;
echo $e->getMessage() . PHP_EOL;
}

View file

@ -7,5 +7,3 @@ $db = get_db_instance();
$hash = password_hash( ADMIN_PASS, PASSWORD_ARGON2ID ); $hash = password_hash( ADMIN_PASS, PASSWORD_ARGON2ID );
$stmt = $db->prepare( 'INSERT INTO admin (password_hash_type, password, superadmin, username, created, modified) VALUES ("{ARGON2ID}", ?, 1, ?, NOW(), NOW());' ); $stmt = $db->prepare( 'INSERT INTO admin (password_hash_type, password, superadmin, username, created, modified) VALUES ("{ARGON2ID}", ?, 1, ?, NOW(), NOW());' );
$stmt->execute( [ $hash, ADMIN_USER ] ); $stmt->execute( [ $hash, ADMIN_USER ] );
$stmt = $db->prepare( 'INSERT IGNORE INTO domain (domain, created, modified) VALUES (?, NOW(), NOW())' );
$stmt->execute( [ PRIMARY_DOMAIN ] );

View file

@ -49,7 +49,7 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) {
if ( $ok ) { if ( $ok ) {
$db = get_db_instance(); $db = get_db_instance();
$user = $match[ 1 ]; $user = $match[ 1 ];
$domain = $match[ 3 ] ?? PRIMARY_DOMAIN; $domain = $match[ 3 ] ?? CLEARNET_SERVER;
$stmt = $db->prepare( 'SELECT target_domain FROM alias_domain WHERE alias_domain = ? AND active=1;' ); $stmt = $db->prepare( 'SELECT target_domain FROM alias_domain WHERE alias_domain = ? AND active=1;' );
$stmt->execute( [ $domain ] ); $stmt->execute( [ $domain ] );
if ( $tmp = $stmt->fetch( PDO::FETCH_ASSOC ) ) { if ( $tmp = $stmt->fetch( PDO::FETCH_ASSOC ) ) {

View file

@ -31,7 +31,7 @@ if ( isset( $_POST[ 'user' ] ) ) {
$msg .= '<div class="red" role="alert">'.htmlspecialchars(_('Invalid username. It may not contain a +, \', " or /.')).'</div>'; $msg .= '<div class="red" role="alert">'.htmlspecialchars(_('Invalid username. It may not contain a +, \', " or /.')).'</div>';
} }
$user = mb_strtolower( $match[ 1 ] ?? '' ); $user = mb_strtolower( $match[ 1 ] ?? '' );
$domain = $match[ 3 ] ?? PRIMARY_DOMAIN; $domain = $match[ 3 ] ?? CLEARNET_SERVER;
if ( $ok && ( empty( $_POST[ 'pwd' ] ) || empty( $_POST[ 'pwd2' ] ) || $_POST[ 'pwd' ] !== $_POST[ 'pwd2' ] ) ) { if ( $ok && ( empty( $_POST[ 'pwd' ] ) || empty( $_POST[ 'pwd2' ] ) || $_POST[ 'pwd' ] !== $_POST[ 'pwd2' ] ) ) {
$ok = false; $ok = false;
$msg .= '<div class="red" role="alert">'.htmlspecialchars(_('Passwords empty or don\'t match')).'</div>'; $msg .= '<div class="red" role="alert">'.htmlspecialchars(_('Passwords empty or don\'t match')).'</div>';