diff --git a/branding/da-branding-hitme.tar.gz b/branding/da-branding-hitme.tar.gz new file mode 100644 index 0000000..9b266fb Binary files /dev/null and b/branding/da-branding-hitme.tar.gz differ diff --git a/branding/da_templates.tar b/branding/da_templates.tar new file mode 100644 index 0000000..a264df6 Binary files /dev/null and b/branding/da_templates.tar differ diff --git a/dapostinstall.sh b/dapostinstall.sh index fc03431..2c32ca7 100755 --- a/dapostinstall.sh +++ b/dapostinstall.sh @@ -15,6 +15,9 @@ HTLINK="https://ht.zenadmin.pl" DEFAULT_NS1=dns3.hitme.net.pl DEFAULT_NS2=dns4.hitme.net.pl SETUP_TXT="$DADIR/conf/setup.txt" +BRANDING_DIR="$DAPOSTINSTALL_DIR/branding" +DA_TEMPLATES_ARCHIVE="$BRANDING_DIR/da_templates.tar" +DA_BRANDING_ARCHIVE="$BRANDING_DIR/da-branding-hitme.tar.gz" # PHP versions and extensions managed through DirectAdmin CustomBuild. php1_release=8.3 @@ -81,6 +84,8 @@ require_dir "$DADIR" require_dir "$CBDIR" require_file "$CBDIR/build" require_file "$SETUP_TXT" +require_file "$DA_TEMPLATES_ARCHIVE" +require_file "$DA_BRANDING_ARCHIVE" yum -y install epel-release yum -y install htop wget rsync nano mc ncdu borgbackup screen net-tools htop libmemcached libmemcached-devel cp daupdate.sh /opt @@ -190,22 +195,23 @@ echo "Instalacja Modsecurity i reguĊ‚ek malware experts" daupdate antybots echo "Instaluje branding hitme dla skorki evolution i serwera www" + templates_tmp="$(mktemp -d)" + trap 'rm -rf "$templates_tmp"' EXIT cd $DAPOSTINSTALL_DIR tar -xvf skin_customizations.tar -C $DADIR/data/users/admin/ - cd $DAPOSTINSTALL_DIR - wget https://cdn.hitme.pl/da_templates.tar - tar -xf da_templates.tar - cp da_templates/*[1-9]* /home/admin/domains/default/ - cp da_templates/index.html /home/admin/domains/default/index.html - cp da_templates/suspended.shtml /home/admin/domains/suspended/index.html - cp da_templates/index-hitme.html /var/www/html/index.html + tar -xf "$DA_TEMPLATES_ARCHIVE" -C "$templates_tmp" + cp "$templates_tmp"/da_templates/*[1-9]* /home/admin/domains/default/ + cp "$templates_tmp"/da_templates/index.html /home/admin/domains/default/index.html + cp "$templates_tmp"/da_templates/suspended.shtml /home/admin/domains/suspended/index.html + if [[ -f "$templates_tmp"/da_templates/index-hitme.html ]]; then + cp "$templates_tmp"/da_templates/index-hitme.html /var/www/html/index.html + else + cp "$templates_tmp"/da_templates/index.html /var/www/html/index.html + fi cd $DAPOSTINSTALL_DIR echo "Login branging hitme" - cd / - wget https://cdn.hitme.pl/da_files/da-branding-hitme.tar.gz - tar xvzf da-branding-hitme.tar.gz - rm -rf da-branding-hitme.tar.gz + tar -xzf "$DA_BRANDING_ARCHIVE" -C / cd $DAPOSTINSTALL_DIR/login_branding cp admin/* $DADIR/data/admin/ cp -rfp users/admin/skin_customizations//evolution/* $DADIR/data/users/admin/skin_customizations/evolution diff --git a/tests/quality_checks.sh b/tests/quality_checks.sh index 8306d20..735a40c 100644 --- a/tests/quality_checks.sh +++ b/tests/quality_checks.sh @@ -43,12 +43,32 @@ assert_archive_clean_for_linux_tar() { fi } +assert_plain_tar_archive_clean_for_linux_tar() { + local archive="$1" + local metadata_entries + local xattr_entries + + metadata_entries="$(tar -tf "$archive" | grep -E '(^|/)\._|(^|/)\.DS_Store$|(^|/)__MACOSX(/|$)' || true)" + if [[ -n "$metadata_entries" ]]; then + fail "$archive contains macOS metadata files" + fi + + xattr_entries="$(tar -xOf "$archive" 2>/dev/null | strings | grep -E 'LIBARCHIVE\.xattr|SCHILY\.xattr|com\.apple' || true)" + if [[ -n "$xattr_entries" ]]; then + fail "$archive contains macOS extended attributes" + fi +} + assert_bash_syntax "$ROOT_DIR/dapostinstall.sh" assert_bash_syntax "$ROOT_DIR/da_cli.sh" assert_bash_syntax "$ROOT_DIR/daupdate.sh" 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" +[[ -f "$ROOT_DIR/branding/da_templates.tar" ]] || fail "missing local da_templates archive" +[[ -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" 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$' @@ -59,6 +79,9 @@ 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" '^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"$' 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" '^php9_release=' @@ -71,6 +94,13 @@ assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^SETUP_TXT="\$DADIR/conf/setu assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^update_daupdate_tools\(\) \{$' 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_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"' +assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'tar -xzf "\$DA_BRANDING_ARCHIVE" -C /' +assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'index-hitme\.html' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'DA_ADMINPASS=\$\(get_key_value "\$SETUP_TXT" "adminpass"\)' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'set_key_value "\$DADIR/conf/directadmin\.conf" "ns1" "\$DEFAULT_NS1"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'set_key_value "\$DADIR/conf/directadmin\.conf" "ns2" "\$DEFAULT_NS2"'