From 49b5c3ebd73966a31b2eb8de207a9d5482c0266c Mon Sep 17 00:00:00 2001 From: Ilia Ross <4426533+iliajie@users.noreply.github.com> Date: Mon, 27 Nov 2023 00:22:32 +0200 Subject: [PATCH] Fix modules support (#100) * Fix to remove openSUSE from default installer * Fix the message to mention time out of sync, as it can also cause download issue * Fix another download message * Add support for post-install modules properly * Fix missing module error message * 7.3.4 * Fix install script name and meta packages formatting in README.md --- README.md | 13 ++++--- opensuse.sh | 47 ------------------------- virtualmin-install.sh | 81 ++++++++++++------------------------------- 3 files changed, 28 insertions(+), 113 deletions(-) delete mode 100644 opensuse.sh diff --git a/README.md b/README.md index 511a657..992ad57 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The **Grade A** systems currently supported by install script are: Red Hat Enterprise Linux and derivatives - RHEL 8 and 9 on x86_64 - Alma and Rocky 8 and 9 on x86_64 - - CentOS 7 on x86_64 + - CentOS 7 on x86_64 (no longer recommended) Debian Linux and derivatives - Debian 10, 11 and 12 on i386 and amd64 @@ -32,15 +32,14 @@ The **Grade A** systems currently supported by install script are: The _Grade B_ systems currently supported by install script are: Red Hat Enterprise Linux and derivatives - - Fedora Server 38+ on x86_64 + - Fedora Server 38 and above on x86_64 - CentOS Stream 8 and 9 on x86_64 - Oracle Linux 8 and 9 on x86_64 - CloudLinux 8 and 9 on x86_64 - - Amazon Linux 2023+ on x86_64 - - openSUSE Server 15 on x86_64 + - Amazon Linux 2023 and above on x86_64 Debian Linux and derivatives - - Kali Linux Rolling 2023+ on x86_64 + - Kali Linux Rolling 2023 and above on x86_64 We strongly recommend you use the latest version of your preferred **Grade A** supported distribution. The latest release gets the most active testing and bug fixing. @@ -61,13 +60,13 @@ Please file tickets, either here or at [Virtualmin Forum](https://forum.virtualm # How to contribute -Wrap your head around how `install.sh` does its job (mostly by setting up package repositories and installed metapackages or `yum` groups). Ask questions if you're not sure what's going on. +Wrap your head around how `virtualmin-install.sh` does its job (mostly by setting up package repositories and installed _metapackages_ or _yum_-groups). Ask questions if you're not sure what's going on. Pick your favorite distro or OS, and start coding and packaging for it! I'm usually happy to devote time and resources to helping make Virtualmin work on other systems. I just don't have the time/resources to maintain more than the most popular server operating systems myself. # See also -These are the tools the shell script uses to actually perform the installation and configuration. It sets up package repositories, installs the yum groups or the metapackages, and then uses Virtualmin-Config to perform the initial configuration steps, like turning on services, making service configuration changes, etc. +These are the tools the shell script uses to actually perform the installation and configuration. It sets up package repositories, installs the _yum_-groups or the _metapackages_, and then uses Virtualmin-Config to perform the initial configuration steps, like turning on services, making service configuration changes, etc. [Virtualmin-Config: a post-modern post-installation configuration tool](https://github.com/virtualmin/Virtualmin-Config) diff --git a/opensuse.sh b/opensuse.sh deleted file mode 100644 index 98f97fe..0000000 --- a/opensuse.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -# shellcheck disable=SC2154 disable=SC2034 disable=SC2086 -# Copyright 2005-2023 Virtualmin, Inc. -# virtualmin-install.sh - openSUSE module v1.0.0 - -# Fix openSUSE pitfalls -opensuse_poststack() { - # Install Virtualmin Config package manually - # as it currently fails with false positive error - package_virtualmin_config=$(dnf download virtualmin-config) - package_virtualmin_config_name=$(echo "$package_virtualmin_config" | grep -o 'virtualmin-config[^ ]*.rpm') - rpm -U --nodeps --replacepkgs --replacefiles --quiet $package_virtualmin_config_name - # Create symlink to known @INC to where Virtualmin Config is actually is - ln -sf /usr/share/perl5/vendor_perl/Virtualmin /usr/lib/perl5/site_perl - # Remove downloaded package - rm -f $package_virtualmin_config_name - # Now check which packages are missing and install them manually using package manager - install_group_opts_loud=$(echo $install_group_opts | sed 's/ --quiet//g') - virtualmin_group_missing_cmd="$install_cmd $install_group_opts_loud $rhgroup" - virtualmin_group_missing_try=$(eval $virtualmin_group_missing_cmd 2>&1) - # Extract missing package list - virtualmin_group_missing=$(echo "$virtualmin_group_missing_try" | grep -o '"[^"]\+"' | tr -d '"' | tr '\n' ' ') - # PHP packages are actually named php8-* in openSUSE - virtualmin_group_missing=$(echo "$virtualmin_group_missing" | sed 's/php-/php8-/g') - # The package fail2ban-firewalld is named fail2ban in openSUSE - virtualmin_group_missing=$(echo "$virtualmin_group_missing" | sed 's/fail2ban-firewalld/fail2ban/g') - # The package mod_fcgid is named apache2-mod_fcgid in openSUSE - virtualmin_group_missing=$(echo "$virtualmin_group_missing" | sed 's/mod_fcgid/apache2-mod_fcgid/g') - # AppArmor should either be configured to allow /var/php-fpm for - # PHP-FPM sockets or disabled completely - systemctl stop apparmor.service - systemctl disable apparmor.service - systemctl mask apparmor.service - # Swap pre-installed posfix for postfix-bdb-lmdb - $install_cmd -y swap --allowerasing postfix postfix-bdb-lmdb - # Install missing packages that we extracted earlier - $install --skip-broken $virtualmin_group_missing cyrus-sasl-saslauthd - # There is no AWStats package in openSUSE - $install_cmd -y remove wbm-virtualmin-awstats - # Add allow_vendor_change=True to /etc/dnf/dnf.conf unless it's already there - grep -qxF 'allow_vendor_change=True' /etc/dnf/dnf.conf || echo "allow_vendor_change=True" >> /etc/dnf/dnf.conf -} -run_ok "opensuse_poststack" "Installing Virtualmin $vm_version missing stack packages" -# Don't show false positively skipped packages -noskippedpackagesforce=1 -# Fix to skip configuring AWStats as it's not available in openSUSE -virtualmin_config_system_excludes=" --exclude AWStats" diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 1d1e146..696b999 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -18,13 +18,12 @@ # License and version SERIAL=GPL KEY=GPL -VER=7.3.3 +VER=7.3.4 vm_version=7 # Server upgrade_virtualmin_host=software.virtualmin.com upgrade_virtualmin_host_lib="$upgrade_virtualmin_host/lib" -upgrade_virtualmin_host_mods="$upgrade_virtualmin_host_lib/mods" # Currently supported systems # https://www.virtualmin.com/os-support/ @@ -50,6 +49,7 @@ usage() { printf " --help|-h display this help and exit\\n" printf " --bundle|-b choose bundle to install (defaults to LAMP)\\n" printf " --minimal|-m install a smaller subset of packages for low-memory/low-resource systems\\n" + printf " --module|-o source a custom shell module during the post-installation phase\\n" printf " --unstable|-e enable support for Grade B systems (not recommended, see documentation)\\n" printf " --insecure-downloads|-i skip remote server SSL certificate check upon downloads (not recommended)\\n" printf " --no-package-updates|-x skip installing system package updates (not recommended)\\n" @@ -109,10 +109,6 @@ while [ "$1" != "" ]; do virtualmin_config_system_excludes="" virtualmin_stack_custom_packages="" ;; - # Later we can make modules fully pluggable, - # however it would require to rethink how OS - # detection and uninstallation works with - # those custom modules --module | -o) shift module_name=$1 @@ -306,7 +302,7 @@ download_slib() { pre_check_http_client $download "https://$upgrade_virtualmin_host_lib/slib.sh" >>"$log" 2>&1 if [ $? -ne 0 ]; then - echo "Error: Failed to download utility function library. Cannot continue. Check your network connection and DNS settings." + echo "Error: Failed to download utility function library. Cannot continue. Check your network connection and DNS settings, and verify that your system's time is accurately synchronized." exit 1 fi chmod +x slib.sh @@ -373,7 +369,7 @@ fi remove_virtualmin_release() { case "$os_type" in - rhel | fedora | centos | centos_stream | rocky | almalinux | ol | cloudlinux | amzn | opensuse-leap) + rhel | fedora | centos | centos_stream | rocky | almalinux | ol | cloudlinux | amzn ) rm -f /etc/yum.repos.d/virtualmin.repo rm -f /etc/pki/rpm-gpg/RPM-GPG-KEY-virtualmin* rm -f /etc/pki/rpm-gpg/RPM-GPG-KEY-webmin @@ -489,7 +485,7 @@ uninstall() { { # Detect the package manager case "$os_type" in - rhel | fedora | centos | centos_stream | rocky | almalinux | ol | cloudlinux | amzn | opensuse-leap) + rhel | fedora | centos | centos_stream | rocky | almalinux | ol | cloudlinux | amzn ) package_type=rpm if command -pv dnf 1>/dev/null 2>&1; then uninstall_cmd="dnf remove -y" @@ -582,14 +578,13 @@ install_msg() { EOF supported_all=$supported if [ -n "$unstable" ]; then - unstable_rhel="${YELLOW}- Fedora Server 38+ on x86_64\\n \ + unstable_rhel="${YELLOW}- Fedora Server 38 and above on x86_64\\n \ - CentOS Stream 8 and 9 on x86_64\\n \ - Oracle Linux 8 and 9 on x86_64\\n \ - CloudLinux 8 and 9 on x86_64\\n \ - - Amazon Linux 2023+ on x86_64\\n \ - - openSUSE Server 15 on x86_64\\n \ + - Amazon Linux 2023 and above on x86_64\\n \ ${NORMAL}" - unstable_deb="${YELLOW}- Kali Linux Rolling 2023+ on x86_64\\n \ + unstable_deb="${YELLOW}- Kali Linux Rolling 2023 and above on x86_64\\n \ ${NORMAL}" supported_all=$(echo "$supported_all" | sed "s/UNSTABLERHEL/$unstable_rhel/") supported_all=$(echo "$supported_all" | sed "s/UNSTABLEDEB/$unstable_deb/") @@ -633,15 +628,6 @@ os_unstable_pre_check() { Certain features may not work as intended or might be unavailable on this OS. EOF - if [ "$os_type" = "opensuse-leap" ]; then - cat <>"$log" 2>&1 - if [ $? -ne 0 ]; then - echo "Error: Failed to download embedded module ${module_name}.sh. Cannot continue. Check your network connection and DNS settings." - exit 1 - fi - chmod +x "$module_name" - # shellcheck disable=SC1090 - . "./$module_name" - fi - fi - fi - return 0 } @@ -1421,6 +1372,18 @@ if [ "$?" != "0" ]; then errors=$((errors + 1)) fi +# Initialize embedded module if any +if [ -n "$module_name" ]; then + # If module is available locally in the same directory use it + if [ -f "$pwd/${module_name}.sh" ]; then + chmod +x "$pwd/${module_name}.sh" + # shellcheck disable=SC1090 + . "$pwd/${module_name}.sh" + else + log_warning "Requested module with the filename $pwd/${module_name}.sh does not exist." + fi +fi + # Reap any clingy processes (like spinner forks) # get the parent pids (as those are the problem) allpids="$(ps -o pid= --ppid $$) $allpids"