Install local DirectAdmin plugins

This commit is contained in:
Marek Miklewicz
2026-06-13 20:16:49 +02:00
parent 76818500b1
commit 0e04667160
5 changed files with 92 additions and 14 deletions
+53 -14
View File
@@ -14,7 +14,9 @@ LOG_FILE=/var/log/dapostinstall.log
HTLINK="https://ht.zenadmin.pl"
DEFAULT_NS1=dns3.hitme.net.pl
DEFAULT_NS2=dns4.hitme.net.pl
REDIS_VERSION=8
SETUP_TXT="$DADIR/conf/setup.txt"
PLUGIN_ARCHIVE_DIR="$DAPOSTINSTALL_DIR/plugins"
BRANDING_DIR="$DAPOSTINSTALL_DIR/branding"
DA_TEMPLATES_ARCHIVE="$BRANDING_DIR/da_templates.tar"
DA_BRANDING_ARCHIVE="$BRANDING_DIR/da-branding-hitme.tar.gz"
@@ -67,6 +69,53 @@ build_php_extension() {
da build "$target"
}
install_local_plugin_archive() {
local archive="$1"
local plugin_name
local plugin_dir
plugin_name="$(basename "$archive" .tar.gz)"
plugin_dir="$DADIR/plugins/$plugin_name"
echo "Instalacja pluginu $plugin_name"
rm -rf "$plugin_dir"
mkdir -p "$plugin_dir"
tar -zxf "$archive" -C "$plugin_dir"
if [[ -f "$plugin_dir/install.sh" ]]; then
chmod 755 "$plugin_dir/install.sh"
(
cd "$plugin_dir"
./install.sh
)
else
fail "Brak wykonywalnego install.sh w $plugin_dir"
fi
if [[ "$plugin_name" == "redis-manager" ]]; then
require_file "$DADIR/plugins/redis-manager/scripts/redis_migrate.sh"
chmod 755 "$DADIR/plugins/redis-manager/scripts/redis_migrate.sh"
"$DADIR/plugins/redis-manager/scripts/redis_migrate.sh" "$REDIS_VERSION"
fi
}
install_local_plugins() {
local archive
local found=0
shopt -s nullglob
for archive in "$PLUGIN_ARCHIVE_DIR"/*.tar.gz; do
found=1
install_local_plugin_archive "$archive"
done
shopt -u nullglob
if [[ "$found" -eq 0 ]]; then
fail "Brak paczek pluginów w $PLUGIN_ARCHIVE_DIR"
fi
}
update_daupdate_tools() {
echo "update..."
wget "$HTLINK/daupdate.sh" -O /sbin/daupdate
@@ -84,6 +133,7 @@ require_dir "$DADIR"
require_dir "$CBDIR"
require_file "$CBDIR/build"
require_file "$SETUP_TXT"
require_dir "$PLUGIN_ARCHIVE_DIR"
require_file "$DA_TEMPLATES_ARCHIVE"
require_file "$DA_BRANDING_ARCHIVE"
yum -y install epel-release
@@ -365,11 +415,10 @@ build_php_extension "$opcache" "opcache" "opcache"
build_php_extension "$imap" "php_imap" "php_imap"
build_php_extension "$imagick" "imagick" "imagick"
echo "Instalacja Memcache i redis"
echo "Instalacja Memcache"
yum -y install memcached libmemcached
systemctl enable memcached
systemctl restart memcached
yum -y install redis redis-devel
echo "Instalacja rozszerzen PECL od poralixa"
cd $DADIR/scripts/custom
@@ -383,12 +432,6 @@ 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
da build secure_php
# Poprawka redis dla AlmaLinux 9
if grep -q "AlmaLinux release 9" /etc/redhat-release; then
ln -s /etc/redis/redis.conf /etc/redis.conf
fi
echo "Optymalizacja MySQL"
cd $DAPOSTINSTALL_DIR
\cp -f my.cnf /etc/my.cnf
@@ -439,13 +482,9 @@ touch /etc/ssh/sshd_config_placebo
sed -i 's^/etc/ssh/sshd_config^/etc/ssh/sshd_config_placebo^g' $DADIR/conf/directadmin.conf
systemctl restart directadmin
echo "Instalacja REDISa"
cd $DADIR/scripts/custom
./php-extension.sh install redis
mkdir $DADIR/plugins/redis_management
echo "Instalacja pluginów DirectAdmin"
cd $DAPOSTINSTALL_DIR
tar -zxf redis_management.tar.gz -C $DADIR/plugins/redis_management
$DADIR/plugins/redis_management/scripts/install.sh
install_local_plugins
cd $DAPOSTINSTALL_DIR
echo "Instalacja IMAPsync"
Binary file not shown.
Binary file not shown.
Binary file not shown.
+39
View File
@@ -43,6 +43,13 @@ assert_archive_clean_for_linux_tar() {
fi
}
assert_gzip_tar_contains() {
local archive="$1"
local path="$2"
tar -tzf "$archive" | grep -qx "$path" || fail "$archive does not contain $path"
}
assert_plain_tar_archive_clean_for_linux_tar() {
local archive="$1"
local metadata_entries
@@ -69,6 +76,16 @@ assert_archive_clean_for_linux_tar "$ROOT_DIR/spolszczenie_enhanced.tar.gz"
[[ -f "$ROOT_DIR/branding/da-branding-hitme.tar.gz" ]] || fail "missing local DA branding archive"
assert_plain_tar_archive_clean_for_linux_tar "$ROOT_DIR/branding/da_templates.tar"
assert_archive_clean_for_linux_tar "$ROOT_DIR/branding/da-branding-hitme.tar.gz"
[[ -f "$ROOT_DIR/plugins/borg-restore.tar.gz" ]] || fail "missing borg-restore plugin archive"
[[ -f "$ROOT_DIR/plugins/db-manager.tar.gz" ]] || fail "missing db-manager plugin archive"
[[ -f "$ROOT_DIR/plugins/redis-manager.tar.gz" ]] || fail "missing redis-manager plugin archive"
assert_archive_clean_for_linux_tar "$ROOT_DIR/plugins/borg-restore.tar.gz"
assert_archive_clean_for_linux_tar "$ROOT_DIR/plugins/db-manager.tar.gz"
assert_archive_clean_for_linux_tar "$ROOT_DIR/plugins/redis-manager.tar.gz"
assert_gzip_tar_contains "$ROOT_DIR/plugins/borg-restore.tar.gz" './install.sh'
assert_gzip_tar_contains "$ROOT_DIR/plugins/db-manager.tar.gz" './install.sh'
assert_gzip_tar_contains "$ROOT_DIR/plugins/redis-manager.tar.gz" './install.sh'
assert_gzip_tar_contains "$ROOT_DIR/plugins/redis-manager.tar.gz" './scripts/redis_migrate.sh'
assert_file_contains "$ROOT_DIR/da_cli.sh" '^DEFAULTPACKAGE=NO-LIMIT$'
assert_file_not_contains "$ROOT_DIR/da_cli.sh" '^eparated list of IP addresses$'
@@ -79,6 +96,8 @@ assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'set_key_value "\$DADIR/conf/d
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'set_key_value "\$DADIR/conf/directadmin\.conf" "ns2"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^DEFAULT_NS1=dns3\.hitme\.net\.pl$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^DEFAULT_NS2=dns4\.hitme\.net\.pl$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^REDIS_VERSION=8$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_ARCHIVE_DIR="\$DAPOSTINSTALL_DIR/plugins"$'
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_BRANDING_ARCHIVE="\$BRANDING_DIR/da-branding-hitme\.tar\.gz"$'
@@ -96,6 +115,7 @@ assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" '/opt/daupdate\.sh update'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'require_file "\$SETUP_TXT"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'require_file "\$DA_TEMPLATES_ARCHIVE"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'require_file "\$DA_BRANDING_ARCHIVE"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'require_dir "\$PLUGIN_ARCHIVE_DIR"'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'https://cdn\.hitme\.pl/da_templates\.tar'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'https://cdn\.hitme\.pl/da_files/da-branding-hitme\.tar\.gz'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'tar -xf "\$DA_TEMPLATES_ARCHIVE" -C "\$templates_tmp"'
@@ -128,6 +148,9 @@ assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$imap"
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'build_php_extension "\$imagick" "imagick" "imagick"'
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" 'yum -y install redis redis-devel'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" '\./php-extension\.sh install redis'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'ln -s /etc/redis/redis\.conf /etc/redis\.conf'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" "sed -i 's/DA_.*mail_powitalny.txt"
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'mv mail_powitalny.txt /root'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'DA_PHP_LIST=\$\(get_php_release_list "\$DA_OPTIONSCONF"\)'
@@ -142,6 +165,22 @@ 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" "s/evolution/enhanced"
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'Skorka evolution zostala ustawiona jako domyslna'
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" '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" '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" 'mkdir -p "\$plugin_dir"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'tar -zxf "\$archive" -C "\$plugin_dir"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'chmod 755 "\$plugin_dir/install\.sh"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'cd "\$plugin_dir"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '\./install\.sh'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'chmod 755 "\$DADIR/plugins/redis-manager/scripts/redis_migrate\.sh"'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '"\$DADIR/plugins/redis-manager/scripts/redis_migrate\.sh" "\$REDIS_VERSION"'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'redis_install\.sh'
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_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_PHP_LIST\}\}'