Compare commits

..

10 Commits

Author SHA1 Message Date
Marek Miklewicz 6e3d6e7667 Add selective plugin install toggles 2026-06-14 14:04:05 +02:00
Marek Miklewicz 89fab85e8e Enable CustomBuild targets before building 2026-06-13 22:46:40 +02:00
Marek Miklewicz 9e8b4aee67 Enable Composer before CustomBuild install 2026-06-13 22:42:41 +02:00
Marek Miklewicz fdfab822c8 Remove invalid http_methods CustomBuild option 2026-06-13 22:17:24 +02:00
Marek Miklewicz c24dc98a45 Use current CustomBuild PHP extension options 2026-06-13 21:50:19 +02:00
Marek Miklewicz c0261418c8 Fix hostname SSL toggle and PHP mode option 2026-06-13 21:25:45 +02:00
Marek Miklewicz 678cbc9066 Use DirectAdmin server_cert for hostname certificate 2026-06-13 21:15:07 +02:00
Marek Miklewicz bd6c5925d3 Do not abort when DA certificate request fails 2026-06-13 21:08:46 +02:00
Marek Miklewicz 091ac31dee Use MARIADB_USAGE for MariaDB memory budget 2026-06-13 21:00:45 +02:00
Marek Miklewicz db01ba1ea0 Tune MariaDB config generation 2026-06-13 20:49:00 +02:00
4 changed files with 459 additions and 81 deletions
+67 -21
View File
@@ -16,8 +16,17 @@ DEFAULT_NS1=dns3.hitme.net.pl
DEFAULT_NS2=dns4.hitme.net.pl DEFAULT_NS2=dns4.hitme.net.pl
SSH_PORT=10022 SSH_PORT=10022
REDIS_VERSION=8 REDIS_VERSION=8
HOSTNAME_SSL=1
SETUP_TXT="$DADIR/conf/setup.txt" SETUP_TXT="$DADIR/conf/setup.txt"
PLUGIN_ARCHIVE_DIR="$DAPOSTINSTALL_DIR/plugins" PLUGIN_ARCHIVE_DIR="$DAPOSTINSTALL_DIR/plugins"
# PLUGINY
# Nazwa zmiennej odpowiada nazwie paczki: borg-restore.tar.gz -> PLUGIN_BORG_RESTORE.
PLUGIN_BORG_RESTORE=1
PLUGIN_DB_MANAGER=1
PLUGIN_IMAPSYNC=1
PLUGIN_REDIS_MANAGER=1
BRANDING_DIR="$DAPOSTINSTALL_DIR/branding" BRANDING_DIR="$DAPOSTINSTALL_DIR/branding"
DA_TEMPLATES_ARCHIVE="$BRANDING_DIR/da_templates.tar" DA_TEMPLATES_ARCHIVE="$BRANDING_DIR/da_templates.tar"
DA_BRANDING_ARCHIVE="$BRANDING_DIR/da-branding-hitme.tar.gz" DA_BRANDING_ARCHIVE="$BRANDING_DIR/da-branding-hitme.tar.gz"
@@ -50,33 +59,58 @@ configure_custombuild_php() {
release_var="php${idx}_release" release_var="php${idx}_release"
release="${!release_var}" release="${!release_var}"
da build set "php${idx}_release" "$release" da build set "php${idx}_release" "$release"
if [[ "$release" != "no" ]]; then
da build set "php${idx}_mode" "php-fpm"
fi
done done
da build set "php1_mode" "php-fpm"
da build php da build php
da build rewrite_confs da build rewrite_confs
} }
build_php_extension() { build_php_extension() {
local enabled="$1" local enabled="$1"
local option="$2" local extension="$2"
local target="$3"
[[ "$enabled" == "yes" ]] || return 0 [[ "$enabled" == "yes" ]] || return 0
cd "$CBDIR" cd "$CBDIR"
da build set "$option" yes da build set "$extension" yes
da build "$target" da build "$extension"
}
plugin_config_var() {
local plugin_name="$1"
local var_name
var_name="${plugin_name//-/_}"
var_name="PLUGIN_${var_name^^}"
printf '%s\n' "$var_name"
}
is_plugin_enabled() {
local plugin_name="$1"
local var_name
local enabled
var_name="$(plugin_config_var "$plugin_name")"
enabled="${!var_name:-1}"
[[ "$enabled" != "0" ]]
} }
install_local_plugin_archive() { install_local_plugin_archive() {
local archive="$1" local archive="$1"
local plugin_name local plugin_name
local plugin_config
local plugin_dir local plugin_dir
local install_script local install_script
plugin_name="$(basename "$archive" .tar.gz)" plugin_name="$(basename "$archive" .tar.gz)"
plugin_config="$(plugin_config_var "$plugin_name")"
if ! is_plugin_enabled "$plugin_name"; then
echo "$plugin_config=0 - pomijam instalacje pluginu $plugin_name"
return 0
fi
plugin_dir="$DADIR/plugins/$plugin_name" plugin_dir="$DADIR/plugins/$plugin_name"
echo "Instalacja pluginu $plugin_name" echo "Instalacja pluginu $plugin_name"
@@ -133,6 +167,20 @@ install_local_plugins() {
fi fi
} }
request_directadmin_certificate() {
if [[ "$HOSTNAME_SSL" == "0" ]]; then
echo "HOSTNAME_SSL=0 - pomijam certyfikat Let's Encrypt dla hostname DirectAdmin"
return 0
fi
echo "Instalacja certyfikatu Let's Encrypt dla hostname DirectAdmin"
if ! "$DADIR/scripts/letsencrypt.sh" server_cert; then
echo "Nie udalo sie wystawic certyfikatu DirectAdmin dla hostname - pomijam ten krok."
echo "Sprawdz hostname/servername w DirectAdmin oraz DNS i uruchom Let's Encrypt recznie po instalacji."
fi
}
update_daupdate_tools() { update_daupdate_tools() {
echo "update..." echo "update..."
wget "$HTLINK/daupdate.sh" -O /sbin/daupdate wget "$HTLINK/daupdate.sh" -O /sbin/daupdate
@@ -290,8 +338,7 @@ echo "Instalacja Security headers"
da build rewrite_confs da build rewrite_confs
cd $DAPOSTINSTALL_DIR cd $DAPOSTINSTALL_DIR
echo "Instalacja certyfikatu Let's Encrypt" request_directadmin_certificate
$DADIR/scripts/letsencrypt.sh request_single `hostname` 4096
echo -e "\e[96mMam wszystkie informacje - rozpoczynam konfiguracje\e[0m" echo -e "\e[96mMam wszystkie informacje - rozpoczynam konfiguracje\e[0m"
@@ -378,6 +425,7 @@ cd custombuild
da build update da build update
da build dovecot_conf da build dovecot_conf
da build exim_conf da build exim_conf
da build set roundcube yes
da build roundcube da build roundcube
echo "OneClick PhpMyAdmin" echo "OneClick PhpMyAdmin"
@@ -386,12 +434,14 @@ cd $DADIR/
systemctl restart directadmin systemctl restart directadmin
cd custombuild cd custombuild
da build update da build update
da build set phpmyadmin yes
da build phpmyadmin da build phpmyadmin
echo "PhpMyAdmin tylko z poziomu DirectAdmina" echo "PhpMyAdmin tylko z poziomu DirectAdmina"
cd $CBDIR cd $CBDIR
da build update da build update
da build set phpmyadmin yes
da build set phpmyadmin_public no da build set phpmyadmin_public no
da build phpmyadmin da build phpmyadmin
systemctl restart directadmin systemctl restart directadmin
@@ -424,11 +474,11 @@ if [[ "$imagick" == "yes" ]]; then
fi fi
echo "Instalacja rozszerzen PHP z CustomBuild" echo "Instalacja rozszerzen PHP z CustomBuild"
build_php_extension "$ioncube" "ioncube" "ioncube" build_php_extension "$ioncube" "php_ioncube"
build_php_extension "$zend" "zend" "zend" build_php_extension "$zend" "php_zend"
build_php_extension "$opcache" "opcache" "opcache" build_php_extension "$opcache" "php_opcache"
build_php_extension "$imap" "php_imap" "php_imap" build_php_extension "$imap" "php_imap"
build_php_extension "$imagick" "imagick" "imagick" build_php_extension "$imagick" "php_imagick"
echo "Instalacja Memcache" echo "Instalacja Memcache"
yum -y install memcached libmemcached yum -y install memcached libmemcached
@@ -445,11 +495,12 @@ cd $DAPOSTINSTALL_DIR
cd $CBDIR cd $CBDIR
touch custom/php_disable_functions touch custom/php_disable_functions
echo "exec,system,passthru,shell_exec,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname" > custom/php_disable_functions echo "exec,system,passthru,shell_exec,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname" > custom/php_disable_functions
da build set secure_php yes
da build secure_php da build secure_php
echo "Optymalizacja MySQL" echo "Optymalizacja MySQL"
cd $DAPOSTINSTALL_DIR cd $DAPOSTINSTALL_DIR
\cp -f my.cnf /etc/my.cnf bash "$DAPOSTINSTALL_DIR/my-cnf-gen.sh" --output /etc/my.cnf
systemctl restart mysqld systemctl restart mysqld
echo "Instalacja bezpiecznego DMARC" echo "Instalacja bezpiecznego DMARC"
@@ -458,14 +509,9 @@ cd $DADIR/data/templates/custom
cp ../dns_txt.conf . cp ../dns_txt.conf .
echo '_dmarc="v=DMARC1;p=quarantine;pct=100;sp=none;fo=0:d:s;aspf=s;adkim=r;"' >> dns_txt.conf echo '_dmarc="v=DMARC1;p=quarantine;pct=100;sp=none;fo=0:d:s;aspf=s;adkim=r;"' >> dns_txt.conf
echo "Dopuszczenie wszystkich metod HTTPD"
cd $CBDIR
da build set http_methods ALL
da build rewrite_confs
echo "Instalacja composera" echo "Instalacja composera"
cd $CBDIR cd $CBDIR
da build set composer yes
da build composer da build composer
cd $DAPOSTINSTALL_DIR cd $DAPOSTINSTALL_DIR
Executable
+274
View File
@@ -0,0 +1,274 @@
#!/usr/bin/env bash
set -euo pipefail
MARIADB_USAGE="${MARIADB_USAGE:-25}"
MIN_BUFFER_POOL_MB=256
MAX_CONNECTIONS_MIN=80
MAX_CONNECTIONS_MAX=300
usage() {
cat <<'EOF'
Usage:
my-cnf-gen.sh [--output PATH]
Generates a conservative MariaDB 10.6 my.cnf for DirectAdmin servers.
The InnoDB buffer pool is sized from MARIADB_USAGE percent of RAM so other DA services
such as web, exim, dovecot, redis and spam filtering keep enough memory.
EOF
}
read_mem_total_mb() {
local mem_bytes
if [[ -n "${MYSQL_GEN_MEM_MB:-}" ]]; then
printf '%s\n' "$MYSQL_GEN_MEM_MB"
return 0
fi
if [[ -r /proc/meminfo ]]; then
awk '/^MemTotal:/ { printf "%d\n", int($2 / 1024) }' /proc/meminfo
return 0
fi
mem_bytes="$(sysctl -n hw.memsize 2>/dev/null || true)"
if [[ -n "$mem_bytes" ]]; then
printf '%d\n' "$((mem_bytes / 1024 / 1024))"
return 0
fi
echo "Unable to detect total memory" >&2
exit 1
}
read_cpu_cores() {
local cores
cores=""
if [[ -n "${MYSQL_GEN_CPU_CORES:-}" ]]; then
printf '%s\n' "$MYSQL_GEN_CPU_CORES"
return 0
fi
if [[ -r /proc/cpuinfo ]]; then
cores="$(grep -c '^processor[[:space:]]*:' /proc/cpuinfo 2>/dev/null || true)"
fi
if [[ -z "$cores" || "$cores" -lt 1 ]]; then
cores="$(getconf _NPROCESSORS_ONLN 2>/dev/null || true)"
fi
if [[ -z "$cores" || "$cores" -lt 1 ]]; then
cores=1
fi
printf '%s\n' "$cores"
}
round_down_mb() {
local value_mb="$1"
local step_mb="$2"
local rounded
rounded=$((value_mb / step_mb * step_mb))
if (( rounded < step_mb )); then
rounded="$step_mb"
fi
printf '%s\n' "$rounded"
}
format_size() {
local value_mb="$1"
if (( value_mb >= 1024 && value_mb % 1024 == 0 )); then
printf '%sG\n' "$((value_mb / 1024))"
else
printf '%sM\n' "$value_mb"
fi
}
calc_buffer_pool_mb() {
local mem_mb="$1"
local pool_mb
pool_mb=$((mem_mb * MARIADB_USAGE / 100))
if (( pool_mb < MIN_BUFFER_POOL_MB )); then
pool_mb="$MIN_BUFFER_POOL_MB"
fi
round_down_mb "$pool_mb" 128
}
calc_buffer_pool_instances() {
local pool_mb="$1"
local cores="$2"
local instances=1
if (( pool_mb >= 8192 && cores >= 4 )); then
instances=4
elif (( pool_mb >= 4096 && cores >= 2 )); then
instances=2
fi
printf '%s\n' "$instances"
}
calc_max_connections() {
local mem_mb="$1"
local cores="$2"
local connections
connections=$((mem_mb / 128))
if (( connections < MAX_CONNECTIONS_MIN )); then
connections="$MAX_CONNECTIONS_MIN"
fi
if (( connections > MAX_CONNECTIONS_MAX )); then
connections="$MAX_CONNECTIONS_MAX"
fi
if (( cores <= 2 && connections > 120 )); then
connections=120
fi
printf '%s\n' "$connections"
}
calc_log_file_mb() {
local pool_mb="$1"
local log_mb
log_mb=$((pool_mb / 4))
if (( log_mb < 128 )); then
log_mb=128
elif (( log_mb > 1024 )); then
log_mb=1024
fi
round_down_mb "$log_mb" 128
}
generate_config() {
local mem_mb="$1"
local cores="$2"
local pool_mb="$3"
local pool_instances="$4"
local max_connections="$5"
local log_file_mb="$6"
local io_capacity="$7"
local io_capacity_max="$8"
cat <<EOF
# Generated by my-cnf-gen.sh for MariaDB 10.6 and DirectAdmin stack hosts.
# Detected RAM: ${mem_mb}M
# Detected CPU cores: ${cores}
# MariaDB memory budget: ${MARIADB_USAGE}% RAM
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld]
user=mysql
port=3306
socket=/var/lib/mysql/mysql.sock
pid-file=/var/lib/mysql/mysql.pid
datadir=/var/lib/mysql
local_infile=0
skip_name_resolve=1
symbolic_links=0
max_connect_errors=1000000
max_allowed_packet=64M
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
skip-character-set-client-handshake
default_storage_engine=InnoDB
myisam_recover_options=FORCE,BACKUP
key_buffer_size=32M
max_connections=${max_connections}
max_user_connections=50
thread_cache_size=64
table_open_cache=2048
table_definition_cache=1024
open_files_limit=65535
sort_buffer_size=512K
join_buffer_size=512K
read_buffer_size=256K
read_rnd_buffer_size=512K
tmp_table_size=32M
max_heap_table_size=32M
query_cache_type=0
query_cache_size=0
innodb_buffer_pool_size=$(format_size "$pool_mb")
innodb_buffer_pool_instances=${pool_instances}
innodb_log_file_size=$(format_size "$log_file_mb")
innodb_log_files_in_group=2
innodb_flush_log_at_trx_commit=1
innodb_flush_method=O_DIRECT
innodb_file_per_table=1
innodb_io_capacity=${io_capacity}
innodb_io_capacity_max=${io_capacity_max}
log_error=/var/lib/mysql/mysql-error.log
slow_query_log=0
slow_query_log_file=/var/lib/mysql/mysql-slow.log
long_query_time=2
log_queries_not_using_indexes=0
EOF
}
main() {
local output=""
local mem_mb
local cores
local pool_mb
local pool_instances
local max_connections
local log_file_mb
local io_capacity
local io_capacity_max
while [[ $# -gt 0 ]]; do
case "$1" in
--output)
shift
[[ $# -gt 0 ]] || { echo "Missing value for --output" >&2; exit 1; }
output="$1"
;;
--help|-h)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 1
;;
esac
shift
done
mem_mb="$(read_mem_total_mb)"
cores="$(read_cpu_cores)"
pool_mb="$(calc_buffer_pool_mb "$mem_mb")"
pool_instances="$(calc_buffer_pool_instances "$pool_mb" "$cores")"
max_connections="$(calc_max_connections "$mem_mb" "$cores")"
log_file_mb="$(calc_log_file_mb "$pool_mb")"
io_capacity=$((cores * 100))
if (( io_capacity < 200 )); then
io_capacity=200
elif (( io_capacity > 800 )); then
io_capacity=800
fi
io_capacity_max=$((io_capacity * 2))
if [[ -n "$output" ]]; then
generate_config "$mem_mb" "$cores" "$pool_mb" "$pool_instances" "$max_connections" "$log_file_mb" "$io_capacity" "$io_capacity_max" > "$output"
else
generate_config "$mem_mb" "$cores" "$pool_mb" "$pool_instances" "$max_connections" "$log_file_mb" "$io_capacity" "$io_capacity_max"
fi
}
main "$@"
+54 -49
View File
@@ -1,67 +1,72 @@
[mysql]
[client] [client]
port=3306 port=3306
socket=/var/lib/mysql/mysql.sock socket=/var/lib/mysql/mysql.sock
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld] [mysqld]
local-infile = 0 # MariaDB 10.6 baseline for DirectAdmin stack hosts.
character-set-server=utf8
collation-server=utf8_general_ci
sort_buffer_size=512K
skip-character-set-client-handshake
# GENERAL #
user=mysql user=mysql
default-storage-engine = InnoDB port=3306
socket=/var/lib/mysql/mysql.sock socket=/var/lib/mysql/mysql.sock
pid-file=/var/lib/mysql/mysql.pid pid-file=/var/lib/mysql/mysql.pid
datadir=/var/lib/mysql
#Odhasowac tylko i wylaczenie gdy w kodzie sa stosowane zapytania i niewlasciwej skladni, # Security and compatibility
#od nowszych wersji mysql jest wymuszneie prawidlowej, optymalnej skladni do wersji 10.1 nie byla sprawdzana local_infile=0
skip_name_resolve=1
symbolic_links=0
max_connect_errors=1000000
max_allowed_packet=64M
#sql_mode="" # Character set
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
skip-character-set-client-handshake
# MyISAM # # Storage engines
key-buffer-size = 128M default_storage_engine=InnoDB
myisam-recover-options = FORCE,BACKUP myisam_recover_options=FORCE,BACKUP
key_buffer_size=32M
# SAFETY # # Connection and table limits
max-allowed-packet = 16M max_connections=200
max-connect-errors = 1000000 max_user_connections=50
skip-name-resolve thread_cache_size=64
table_open_cache=2048
table_definition_cache=1024
open_files_limit=65535
# DATA STORAGE # # Per-connection buffers kept intentionally small for shared DA hosts
datadir = /var/lib/mysql/ sort_buffer_size=512K
join_buffer_size=512K
read_buffer_size=256K
read_rnd_buffer_size=512K
# CACHES AND LIMITS # # Temporary tables
tmp-table-size = 32M tmp_table_size=32M
max-heap-table-size = 32M max_heap_table_size=32M
query-cache-type = 1
query-cache-limit = 256K
query-cache-min-res-unit = 2k
query-cache-size = 80M
max-connections = 500
max-user-connections = 100
thread-cache-size = 16
open-files-limit = 65535
table-definition-cache = 4096
table-open-cache = 10240
# INNODB # # Query cache disabled for multi-core mixed workloads
innodb-log-files-in-group = 2 query_cache_type=0
innodb-log-file-size = 128M query_cache_size=0
innodb-flush-log-at-trx-commit = 1
innodb-buffer-pool-size = 1G # InnoDB
innodb-buffer-pool-instances = 1 innodb_buffer_pool_size=1G
innodb_buffer_pool_instances=1
innodb_log_file_size=256M
innodb_log_files_in_group=2
innodb_flush_log_at_trx_commit=1
innodb_flush_method=O_DIRECT innodb_flush_method=O_DIRECT
#moze opozniac dzialania jak create zalecane gdy duze bazy danych
innodb_file_per_table=1 innodb_file_per_table=1
innodb_file_format = barracuda innodb_io_capacity=200
innodb_io_capacity_max=400
# LOGGING # # Logging
log-error = /var/lib/mysql/mysql-error.log log_error=/var/lib/mysql/mysql-error.log
log-queries-not-using-indexes = 1 slow_query_log=0
slow-query-log = 0 slow_query_log_file=/var/lib/mysql/mysql-slow.log
slow-query-log-file = /var/lib/mysql/mysql-slow.log long_query_time=2
log_queries_not_using_indexes=0
+59 -6
View File
@@ -69,6 +69,7 @@ assert_plain_tar_archive_clean_for_linux_tar() {
assert_bash_syntax "$ROOT_DIR/dapostinstall.sh" assert_bash_syntax "$ROOT_DIR/dapostinstall.sh"
assert_bash_syntax "$ROOT_DIR/da_cli.sh" assert_bash_syntax "$ROOT_DIR/da_cli.sh"
assert_bash_syntax "$ROOT_DIR/daupdate.sh" assert_bash_syntax "$ROOT_DIR/daupdate.sh"
assert_bash_syntax "$ROOT_DIR/my-cnf-gen.sh"
php -l "$ROOT_DIR/lang_pl.php" >/dev/null || fail "lang_pl.php has invalid PHP syntax" php -l "$ROOT_DIR/lang_pl.php" >/dev/null || fail "lang_pl.php has invalid PHP syntax"
assert_archive_clean_for_linux_tar "$ROOT_DIR/spolszczenie_enhanced.tar.gz" assert_archive_clean_for_linux_tar "$ROOT_DIR/spolszczenie_enhanced.tar.gz"
@@ -102,13 +103,21 @@ assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^DEFAULT_NS1=dns3\.hitme\.net
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^DEFAULT_NS2=dns4\.hitme\.net\.pl$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^DEFAULT_NS2=dns4\.hitme\.net\.pl$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^SSH_PORT=10022$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^SSH_PORT=10022$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^REDIS_VERSION=8$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^REDIS_VERSION=8$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^HOSTNAME_SSL=1$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_ARCHIVE_DIR="\$DAPOSTINSTALL_DIR/plugins"$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_ARCHIVE_DIR="\$DAPOSTINSTALL_DIR/plugins"$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_BORG_RESTORE=1$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_DB_MANAGER=1$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_IMAPSYNC=1$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_REDIS_MANAGER=1$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^BRANDING_DIR="\$DAPOSTINSTALL_DIR/branding"$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^BRANDING_DIR="\$DAPOSTINSTALL_DIR/branding"$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^DA_TEMPLATES_ARCHIVE="\$BRANDING_DIR/da_templates\.tar"$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^DA_TEMPLATES_ARCHIVE="\$BRANDING_DIR/da_templates\.tar"$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^DA_BRANDING_ARCHIVE="\$BRANDING_DIR/da-branding-hitme\.tar\.gz"$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^DA_BRANDING_ARCHIVE="\$BRANDING_DIR/da-branding-hitme\.tar\.gz"$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^php1_release=' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^php1_release='
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^php2_release=' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^php2_release='
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^php9_release=' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^php9_release='
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build set "php1_mode" "php-fpm"'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'php\$?\{?idx\}?_mode'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'php[2-9]_mode'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^ioncube=yes$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^ioncube=yes$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^zend=yes$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^zend=yes$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^opcache=yes$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^opcache=yes$'
@@ -142,19 +151,29 @@ assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^configure_custombuild_php\(\
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'release_var="php\$\{idx\}_release"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'release_var="php\$\{idx\}_release"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'release="\$\{!release_var\}"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'release="\$\{!release_var\}"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build set "php\$\{idx\}_release" "\$release"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build set "php\$\{idx\}_release" "\$release"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build set "php\$\{idx\}_mode" "php-fpm"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build set "php1_mode" "php-fpm"'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'da build set "php\$\{idx\}_mode"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build php' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build php'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build rewrite_confs' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build rewrite_confs'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'eximconf_release' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'eximconf_release'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" '\./build' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" '\./build'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" '^[[:space:]]*\$CBDIR/build' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" '^[[:space:]]*\$CBDIR/build'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'http_methods'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build set composer yes'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build set phpmyadmin yes'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build set roundcube yes'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build set secure_php yes'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build set eximconf yes' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build set eximconf yes'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build exim_conf' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'da build exim_conf'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$ioncube" "ioncube" "ioncube"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$ioncube" "php_ioncube"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$zend" "zend" "zend"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$zend" "php_zend"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$opcache" "opcache" "opcache"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$opcache" "php_opcache"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$imap" "php_imap" "php_imap"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$imap" "php_imap"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$imagick" "imagick" "imagick"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$imagick" "php_imagick"'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$ioncube" "ioncube"'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$zend" "zend"'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$opcache" "opcache"'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$imagick" "imagick"'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'sed -i .*imagick=no' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'sed -i .*imagick=no'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'sed -i .*imap=no' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'sed -i .*imap=no'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'yum -y install redis redis-devel' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'yum -y install redis redis-devel'
@@ -173,11 +192,21 @@ assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'Podaj adres NS'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'Jaka skorke ustawic' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'Jaka skorke ustawic'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'Wybierz tryb instalacji' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'Wybierz tryb instalacji'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" "s/evolution/enhanced" assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" "s/evolution/enhanced"
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'request_directadmin_certificate\(\)'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '\[\[ "\$HOSTNAME_SSL" == "0" \]\]'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'HOSTNAME_SSL=0 - pomijam certyfikat'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'letsencrypt\.sh" server_cert'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'Nie udalo sie wystawic certyfikatu DirectAdmin'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'request_single "\$da_hostname" 4096'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'request_single `hostname`'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'Skorka evolution zostala ustawiona jako domyslna' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'Skorka evolution zostala ustawiona jako domyslna'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^is_plugin_enabled\(\) \{$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^install_local_plugin_archive\(\) \{$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^install_local_plugin_archive\(\) \{$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'local found=0' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'local found=0'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'for archive in "\$PLUGIN_ARCHIVE_DIR"/\*\.tar\.gz; do' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'for archive in "\$PLUGIN_ARCHIVE_DIR"/\*\.tar\.gz; do'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'found=1' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'found=1'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'if ! is_plugin_enabled "\$plugin_name"; then'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '\$plugin_config=0 - pomijam instalacje pluginu'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'Brak paczek pluginów w \$PLUGIN_ARCHIVE_DIR' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'Brak paczek pluginów w \$PLUGIN_ARCHIVE_DIR'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'plugin_name="\$\(basename "\$archive" \.tar\.gz\)"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'plugin_name="\$\(basename "\$archive" \.tar\.gz\)"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'mkdir -p "\$plugin_dir"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'mkdir -p "\$plugin_dir"'
@@ -194,6 +223,22 @@ assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'redis_migrate\.sh'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'redis_management\.tar\.gz' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'redis_management\.tar\.gz'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'plugins/redis_management' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'plugins/redis_management'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'tar -zxf imapsync\.tar\.gz' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'tar -zxf imapsync\.tar\.gz'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'bash "\$DAPOSTINSTALL_DIR/my-cnf-gen\.sh" --output /etc/my\.cnf'
assert_file_contains "$ROOT_DIR/my.cnf" 'character-set-server=utf8mb4'
assert_file_contains "$ROOT_DIR/my.cnf" 'collation-server=utf8mb4_unicode_ci'
assert_file_contains "$ROOT_DIR/my.cnf" 'query_cache_type=0'
assert_file_contains "$ROOT_DIR/my.cnf" 'query_cache_size=0'
assert_file_not_contains "$ROOT_DIR/my.cnf" 'query-cache-type'
assert_file_not_contains "$ROOT_DIR/my.cnf" 'query-cache-size'
assert_file_not_contains "$ROOT_DIR/my.cnf" 'innodb_file_format'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" 'MARIADB_USAGE="\$\{MARIADB_USAGE:-25\}"'
assert_file_not_contains "$ROOT_DIR/my-cnf-gen.sh" 'MARIADB_MEMORY_PERCENT'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" 'MYSQL_GEN_MEM_MB'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" 'MYSQL_GEN_CPU_CORES'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" '/proc/meminfo'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" '/proc/cpuinfo'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" 'innodb_buffer_pool_size'
assert_file_contains "$ROOT_DIR/my-cnf-gen.sh" 'MariaDB 10.6'
assert_file_contains "$ROOT_DIR/mail_powitalny.txt" '\{\{DA_HOSTNAME\}\}' assert_file_contains "$ROOT_DIR/mail_powitalny.txt" '\{\{DA_HOSTNAME\}\}'
assert_file_contains "$ROOT_DIR/mail_powitalny.txt" '\{\{DA_HASLO\}\}' assert_file_contains "$ROOT_DIR/mail_powitalny.txt" '\{\{DA_HASLO\}\}'
assert_file_contains "$ROOT_DIR/mail_powitalny.txt" '\{\{DA_PHP_LIST\}\}' assert_file_contains "$ROOT_DIR/mail_powitalny.txt" '\{\{DA_PHP_LIST\}\}'
@@ -210,6 +255,14 @@ source "$COMMON_SH"
tmp_dir="$(mktemp -d)" tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT trap 'rm -rf "$tmp_dir"' EXIT
generated_my_cnf="$tmp_dir/generated-my.cnf"
MYSQL_GEN_MEM_MB=8192 MYSQL_GEN_CPU_CORES=4 "$ROOT_DIR/my-cnf-gen.sh" --output "$generated_my_cnf"
grep -qx 'innodb_buffer_pool_size=2G' "$generated_my_cnf" || fail "generated my.cnf should allocate 25% of 8G to InnoDB"
grep -qx 'max_connections=80' "$generated_my_cnf" || fail "generated my.cnf should keep low-RAM max_connections conservative"
grep -qx 'query_cache_size=0' "$generated_my_cnf" || fail "generated my.cnf should disable query cache"
MARIADB_USAGE=50 MYSQL_GEN_MEM_MB=8192 MYSQL_GEN_CPU_CORES=4 "$ROOT_DIR/my-cnf-gen.sh" --output "$generated_my_cnf"
grep -qx 'innodb_buffer_pool_size=4G' "$generated_my_cnf" || fail "MARIADB_USAGE override should change InnoDB allocation"
kv_file="$tmp_dir/example.conf" kv_file="$tmp_dir/example.conf"
printf 'ns1=old.example\nother=value\n' > "$kv_file" printf 'ns1=old.example\nother=value\n' > "$kv_file"
set_key_value "$kv_file" "ns1" "dns3.hitme.net.pl" set_key_value "$kv_file" "ns1" "dns3.hitme.net.pl"