diff --git a/README.md b/README.md index 69d4a4f..511a657 100644 --- a/README.md +++ b/README.md @@ -32,14 +32,15 @@ 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 - - Amazon Linux 2023 on x86_64 + - Fedora Server 38+ 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 Debian Linux and derivatives - - Kali Linux Rolling on x86_64 + - Kali Linux Rolling 2023+ 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. diff --git a/opensuse.sh b/opensuse.sh new file mode 100644 index 0000000..98f97fe --- /dev/null +++ b/opensuse.sh @@ -0,0 +1,47 @@ +#!/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 4aee0d3..dfeffbc 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -1,5 +1,5 @@ #!/bin/sh -# shellcheck disable=SC2059 disable=SC2181 disable=SC2154 disable=SC2317 disable=SC3043 disable=SC2086 disable=SC2039 disable=SC2034 +# shellcheck disable=SC2059 disable=SC2181 disable=SC2154 disable=SC2317 disable=SC3043 disable=SC2086 disable=SC2039 disable=SC2034 disable=SC2089 disable=SC2090 disable=SC1091 disable=SC1090 # virtualmin-install.sh # Copyright 2005-2023 Virtualmin, Inc. # Simple script to grab the virtualmin-release and virtualmin-base packages. @@ -18,27 +18,22 @@ # License and version SERIAL=GPL KEY=GPL -VER=7.1.2 +VER=7.2.0 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/ -# Store new log each time -log=/root/virtualmin-install.log -if [ -e "$log" ]; then - while true; do - logcnt=$((logcnt+1)) - logold="$log.$logcnt" - if [ ! -e "$logold" ]; then - mv $log $logold - break - fi - done -fi +# Save current working directory +pwd="$PWD" + +# Set log type +log_type="virtualmin-install" # Set defaults bundle='LAMP' # Other option is LEMP @@ -55,10 +50,9 @@ 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 " --unstable|-e enable support for Grade B systems (Fedora, CentOS Stream, Oracle, CloudLinux)\\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" - printf " --setup|-s setup Virtualmin software repositories and exit\\n" + printf " --setup|-s setup Virtualmin software repositories and exit\\n" printf " --hostname|-n set fully qualified hostname\\n" printf " --force|-f assume \"yes\" as answer to all prompts\\n" printf " --verbose|-v increase verbosity\\n" @@ -93,12 +87,6 @@ while [ "$1" != "" ]; do shift mode='minimal' ;; - --unstable | -e) - shift - unstable='unstable' - virtualmin_config_system_excludes="" - virtualmin_stack_custom_packages="" - ;; --insecure-downloads | -i) shift insecure_download_wget_flag=' --no-check-certificate' @@ -113,16 +101,15 @@ while [ "$1" != "" ]; do setup_only=1 mode='setup' unstable='unstable' - case "$1" in - force-latest) - shift - setup_only_force_latest=1 - ;; - *) - setup_only_force_latest=0 - ;; - esac - break + ;; + # 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 + shift ;; --hostname | -n) shift @@ -140,6 +127,7 @@ while [ "$1" != "" ]; do --uninstall | -u) shift mode="uninstall" + log_type="virtualmin-uninstall" ;; *) printf "Unrecognized option: $1\\n\\n" @@ -149,6 +137,19 @@ while [ "$1" != "" ]; do esac done +# Store new log each time +log="$pwd/$log_type.log" +if [ -e "$log" ]; then + while true; do + logcnt=$((logcnt+1)) + logold="$log.$logcnt" + if [ ! -e "$logold" ]; then + mv $log $logold + break + fi + done +fi + # If Pro user downloads GPL version of `install.sh` script # to fix repos check if there is an active license exists if [ -n "$setup_only" ]; then @@ -224,22 +225,29 @@ if [ -n "$TMPNOEXEC" ]; then exit 1 fi -if [ -z "$VMITMPDIR" ]; then - VMITMPDIR="$TMPDIR/.virtualmin-$$" - if [ -e "$VMITMPDIR" ]; then - rm -rf "$VMITMPDIR" +if [ -z "$VIRTUALMIN_INSTALL_TEMPDIR" ]; then + VIRTUALMIN_INSTALL_TEMPDIR="$TMPDIR/.virtualmin-$$" + if [ -e "$VIRTUALMIN_INSTALL_TEMPDIR" ]; then + rm -rf "$VIRTUALMIN_INSTALL_TEMPDIR" fi - mkdir "$VMITMPDIR" + mkdir "$VIRTUALMIN_INSTALL_TEMPDIR" fi +# Export temp directory for Virtualmin Config +export VIRTUALMIN_INSTALL_TEMPDIR + # "files" subdir for libs -mkdir "$VMITMPDIR/files" -srcdir="$VMITMPDIR/files" -if ! cd "$srcdir"; then - echo "Error: Failed to enter $srcdir temporary directory" - exit 1 -fi -export VMITMPDIR +mkdir "$VIRTUALMIN_INSTALL_TEMPDIR/files" +srcdir="$VIRTUALMIN_INSTALL_TEMPDIR/files" + +# Switch to temp directory or exit with error +goto_tmpdir() { + if ! cd "$srcdir" >>"$log" 2>&1; then + echo "Error: Failed to enter $srcdir temporary directory" + exit 1 + fi +} +goto_tmpdir pre_check_http_client() { # Check for wget or curl or fetch @@ -280,18 +288,22 @@ pre_check_http_client() { } download_slib() { - # We need HTTP client first - pre_check_http_client - + # If slib.sh is available locally in the same directory use it + if [ -f "$pwd/slib.sh" ]; then + chmod +x "$pwd/slib.sh" + . "$pwd/slib.sh" # Download the slib (source: http://github.com/virtualmin/slib) - $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." - exit 1 + else + # We need HTTP client first + 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." + exit 1 + fi + chmod +x slib.sh + . ./slib.sh fi - chmod +x slib.sh - # shellcheck disable=SC1091 - . ./slib.sh } # Utility function library @@ -302,6 +314,9 @@ download_slib # for production this block # minus its header ########################################## +# Get OS type +get_distro + # Check the serial number and key serial_ok "$SERIAL" "$KEY" # Setup slog @@ -325,20 +340,42 @@ log_fatal() { log_error "$1" } +# Test if grade B system +grade_b_system() { + case "$os_type" in + rhel | centos | rocky | almalinux | debian | ubuntu) + return 0 + ;; + esac + return 1 +} + +# Detect and enable Grade B system +grade_b_system +if [ $? -eq 1 ]; then + unstable='unstable' + virtualmin_config_system_excludes="" + virtualmin_stack_custom_packages="" +fi + remove_virtualmin_release() { case "$os_type" in - "fedora" | "centos" | "centos_stream" | "rhel" | "rocky" | "almalinux" | "ol" | "cloudlinux" | "amzn") + rhel | fedora | centos | centos_stream | rocky | almalinux | ol | cloudlinux | amzn | opensuse-leap) 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-virtualmin* rm -f /etc/pki/rpm-gpg/RPM-GPG-KEY-webmin ;; - "debian" | "ubuntu") - grep -v "virtualmin" /etc/apt/sources.list >"$VMITMPDIR"/sources.list - mv "$VMITMPDIR"/sources.list /etc/apt/sources.list + debian | ubuntu | kali) + grep -v "virtualmin" /etc/apt/sources.list >"$VIRTUALMIN_INSTALL_TEMPDIR"/sources.list + mv "$VIRTUALMIN_INSTALL_TEMPDIR"/sources.list /etc/apt/sources.list rm -f /etc/apt/sources.list.d/virtualmin.list rm -f /etc/apt/auth.conf.d/virtualmin.conf - rm -f /usr/share/keyrings/debian-virtualmin-* - rm -f /usr/share/keyrings/debian-webmin.gpg + rm -f /usr/share/keyrings/debian-virtualmin* + rm -f /usr/share/keyrings/debian-webmin + rm -f /usr/share/keyrings/ubuntu-virtualmin* + rm -f /usr/share/keyrings/ubuntu-webmin + rm -f /usr/share/keyrings/kali-virtualmin* + rm -f /usr/share/keyrings/kali-webmin ;; esac } @@ -348,9 +385,9 @@ fatal() { log_fatal "Fatal Error Occurred: $1" printf "${RED}Cannot continue installation.${NORMAL}\\n" remove_virtualmin_release - if [ -x "$VMITMPDIR" ]; then + if [ -x "$VIRTUALMIN_INSTALL_TEMPDIR" ]; then log_warning "Removing temporary directory and files." - rm -rf "$VMITMPDIR" + rm -rf "$VIRTUALMIN_INSTALL_TEMPDIR" fi log_fatal "If you are unsure of what went wrong, you may wish to review the log" log_fatal "in $log" @@ -402,76 +439,98 @@ is_installed() { } # This function performs a rough uninstallation of Virtualmin -# It is neither complete, nor correct, but it almost certainly won't break -# anything. It is primarily useful for cleaning up a botched install, so you -# can run the installer again. +# all related packages and configurations uninstall() { - # Very destructive, ask first. - echo - printf " ${REDBG}WARNING${NORMAL}\\n" - echo - echo " This operation is very destructive. It removes nearly all of the packages" - echo " installed by the Virtualmin installer. Never run this on a production system." - echo - printf " Continue? (y/n) " - if ! yesno; then - exit + log_debug "Initiating Virtualmin uninstallation procedure" + log_debug "Operating system name: $os_real" + log_debug "Operating system version: $os_version" + log_debug "Operating system type: $os_type" + log_debug "Operating system major: $os_major_version" + + if [ "$skipyesno" -ne 1 ]; then + echo + printf " ${REDBG}WARNING${NORMAL}\\n" + echo + echo " This operation is highly disruptive and cannot be undone. It removes all of" + echo " the packages and configuration files installed by the Virtualmin installer." + echo + echo " It must never be executed on a live production system." + echo + printf " ${RED}Uninstall?${NORMAL} (y/N) " + if ! yesno; then + exit + fi fi - # This is a crummy way to detect package manager...but going through - # half the installer just to get here is even crummier. - if command -pv rpm 1>/dev/null 2>&1; then - package_type=rpm - elif command -pv dpkg 1>/dev/null 2>&1; then - package_type=deb - fi + # Log to file and tell the user nicely + log_info "Started uninstallation log in $log" - case "$package_type" in - rpm) - yum groupremove -y --setopt="groupremove_leaf_only=true" "Virtualmin Core" - yum groupremove -y --setopt="groupremove_leaf_only=true" "Virtualmin LAMP Stack" - yum groupremove -y --setopt="groupremove_leaf_only=true" "Virtualmin LEMP Stack" - yum groupremove -y --setopt="groupremove_leaf_only=true" "Virtualmin LAMP Stack Minimal" - yum groupremove -y --setopt="groupremove_leaf_only=true" "Virtualmin LEMP Stack Minimal" - yum remove -y virtualmin-base - yum remove -y wbm-virtual-server wbm-virtualmin-htpasswd wbm-virtualmin-dav wbm-virtualmin-mailman wbm-virtualmin-awstats wbm-php-pear wbm-ruby-gems wbm-virtualmin-registrar wbm-virtualmin-init wbm-jailkit wbm-virtualmin-git wbm-virtualmin-slavedns wbm-virtual-server wbm-virtualmin-sqlite wbm-virtualmin-svn - yum remove -y wbt-virtual-server-mobile - yum remove -y virtualmin-config perl-Term-Spinner-Color - yum remove -y webmin usermin awstats - yum remove -y nginx - yum remove -y fail2ban - yum clean all - os_type="centos" - ;; - deb) - rm -rf /etc/fail2ban/jail.d/00-firewalld.conf - rm -f /etc/fail2ban/jail.local - apt-get remove --assume-yes --purge virtualmin-base virtualmin-core virtualmin-lamp-stack virtualmin-lemp-stack - apt-get remove --assume-yes --purge virtualmin-lamp-stack-minimal virtualmin-lemp-stack-minimal - apt-get remove --assume-yes --purge virtualmin-config libterm-spinner-color-perl - apt-get remove --assume-yes --purge webmin-virtual-server webmin-virtualmin-htpasswd webmin-virtualmin-git webmin-virtualmin-slavedns webmin-virtualmin-dav webmin-virtualmin-mailman webmin-virtualmin-awstats webmin-php-pear webmin-ruby-gems webmin-virtualmin-registrar webmin-virtualmin-init webmin-jailkit webmin-virtual-server webmin-virtualmin-sqlite webmin-virtualmin-svn - apt-get remove --assume-yes --purge webmin-virtual-server-mobile - apt-get remove --assume-yes --purge fail2ban - apt-get remove --assume-yes --purge apache2* - apt-get remove --assume-yes --purge nginx* - apt-get remove --assume-yes --purge webmin usermin - apt-get autoremove --assume-yes - os_type="debian" - apt-get clean - ;; - *) - echo "I don't know how to uninstall on this operating system." - ;; - esac - echo 'Removing Virtualmin repo configuration' - remove_virtualmin_release - virtualmin_license_file="/etc/virtualmin-license" - if [ -f "$virtualmin_license_file" ]; then - echo "Removing Virtualmin license" - rm "$virtualmin_license_file" - fi - echo "Done. There's probably quite a bit of related packages and such left behind" - echo "but all of the Virtualmin-specific packages have been removed." + # Always sleep just a bit in case the user changes their mind + sleep 1 + + # Go to the temp directory + goto_tmpdir + + # Uninstall packages + uninstall_packages() + { + # Detect the package manager + case "$os_type" in + rhel | fedora | centos | centos_stream | rocky | almalinux | ol | cloudlinux | amzn | opensuse-leap) + package_type=rpm + if command -pv dnf 1>/dev/null 2>&1; then + uninstall_cmd="dnf remove -y" + uninstall_cmd_group="dnf groupremove -y" + else + uninstall_cmd="yum remove -y" + uninstall_cmd_group="yum groupremove -y" + fi + ;; + debian | ubuntu | kali) + package_type=deb + uninstall_cmd="apt-get remove --assume-yes --purge" + ;; + esac + + case "$package_type" in + rpm) + $uninstall_cmd_group "Virtualmin Core" "Virtualmin LAMP Stack" "Virtualmin LEMP Stack" "Virtualmin LAMP Stack Minimal" "Virtualmin LEMP Stack Minimal" + $uninstall_cmd wbm-* wbt-* webmin* usermin* virtualmin* + os_type="rhel" + return 0 + ;; + deb) + $uninstall_cmd "virtualmin*" "webmin*" "usermin*" + apt-get autoremove --assume-yes + os_type="debian" + return 0 + ;; + *) + log_error "Unknown package manager, cannot uninstall" + return 1 + ;; + esac + } + + # Uninstall repos and helper command + uninstall_repos() + { + echo "Removing Virtualmin $vm_version repo configuration" + remove_virtualmin_release + virtualmin_license_file="/etc/virtualmin-license" + if [ -f "$virtualmin_license_file" ]; then + echo "Removing Virtualmin license" + rm "$virtualmin_license_file" + fi + + echo "Removing Virtualmin helper command" + rm "/usr/sbin/virtualmin" + echo "Virtualmin uninstallation complete." + } + + printf "${YELLOW}▣${NORMAL} Phase ${YELLOW}1${NORMAL} of ${GREEN}1${NORMAL}: Uninstall\\n" + run_ok "uninstall_packages" "Uninstalling Virtualmin $vm_version and all stack packages" + run_ok "uninstall_repos" "Uninstalling Virtualmin $vm_version release package" exit 0 } if [ "$mode" = "uninstall" ]; then @@ -510,13 +569,14 @@ install_msg() { EOF supported_all=$supported if [ -n "$unstable" ]; then - unstable_rhel="${YELLOW}- Fedora Server 38 on x86_64\\n \ - - Amazon Linux 2023 on x86_64\\n \ + unstable_rhel="${YELLOW}- Fedora Server 38+ 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 \ ${NORMAL}" - unstable_deb="${YELLOW}- Kali Linux Rolling on x86_64\\n \ + unstable_deb="${YELLOW}- Kali Linux Rolling 2023+ 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/") @@ -547,6 +607,35 @@ if [ "$skipyesno" -ne 1 ] && [ -z "$setup_only" ]; then install_msg fi +os_unstable_pre_check() { + if [ -n "$unstable" ]; then + cat </dev/null 2>&1; then - install="dnf -y install" - update="dnf -y update" install_cmd="dnf" - install_group="dnf -y --quiet --skip-broken group install --setopt=group_package_types=mandatory,default" - install_config_manager="dnf config-manager" + install="$install_cmd -y install" + update="$install_cmd -y update" + install_group_opts="-y --quiet --skip-broken group install --setopt=group_package_types=mandatory,default" + install_group="$install_cmd $install_group_opts" + install_config_manager="$install_cmd config-manager" # Do not use package manager when fixing repos if [ -z "$setup_only" ]; then run_ok "$install dnf-plugins-core" "Installing core plugins for package manager" fi else - install="/usr/bin/yum -y install" - update="/usr/bin/yum -y update" - install_cmd="/usr/bin/yum" + install_cmd="yum" + install="$install_cmd -y install" + update="$install_cmd -y update" if [ "$os_major_version" -ge 7 ]; then # Do not use package manager when fixing repos if [ -z "$setup_only" ]; then - run_ok "yum --quiet groups mark convert" "Updating groups metadata" + run_ok "$install_cmd --quiet groups mark convert" "Updating groups metadata" fi fi - install_group="yum -y --quiet --skip-broken groupinstall --setopt=group_package_types=mandatory,default" + install_group_opts="-y --quiet --skip-broken groupinstall --setopt=group_package_types=mandatory,default" + install_group="$install_cmd $install_group_opts" install_config_manager="yum-config-manager" fi @@ -985,8 +1071,8 @@ install_virtualmin_release() { fi ;; kali) - if [ -z "$unstable" ] && [ "$os_type" = "kali" ] ; then - printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer${unstable_suffix}\\n" + if [ "$os_major_version" -lt 2023 ] && [ "$os_type" = "kali" ] ; then + printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer.\\n" exit 1 fi ;; @@ -1037,6 +1123,14 @@ install_virtualmin_release() { fi # Remove any existing repo config, in case it's a reinstall remove_virtualmin_release + + # Set correct keys name for Debian vs derivatives + repoid_debian_like=debian + if [ -n "${os_type}" ]; then + repoid_debian_like="${os_type}" + fi + + # Setup repo file apt_auth_dir='/etc/apt/auth.conf.d' LOGINREAL=$LOGIN if [ -d "$apt_auth_dir" ]; then @@ -1046,16 +1140,17 @@ install_virtualmin_release() { fi fi for repo in $repos; do - printf "deb [signed-by=/usr/share/keyrings/debian-virtualmin-$vm_version.gpg] https://${LOGINREAL}$upgrade_virtualmin_host/vm/${vm_version}/${repopath}apt ${repo} main\\n" >/etc/apt/sources.list.d/virtualmin.list + printf "deb [signed-by=/usr/share/keyrings/$repoid_debian_like-virtualmin-$vm_version.gpg] https://${LOGINREAL}$upgrade_virtualmin_host/vm/${vm_version}/${repopath}apt ${repo} main\\n" >/etc/apt/sources.list.d/virtualmin.list done # Install our keys log_debug "Installing Webmin and Virtualmin package signing keys .." - download "https://$upgrade_virtualmin_host/lib/RPM-GPG-KEY-virtualmin-$vm_version" "Downloading Virtualmin $vm_version key" - run_ok "gpg --import RPM-GPG-KEY-virtualmin-$vm_version && cat RPM-GPG-KEY-virtualmin-$vm_version | gpg --dearmor > /usr/share/keyrings/debian-virtualmin-$vm_version.gpg" "Installing Virtualmin $vm_version key" - download "https://$upgrade_virtualmin_host/lib/RPM-GPG-KEY-webmin" "Downloading Webmin key" - run_ok "gpg --import RPM-GPG-KEY-webmin && cat RPM-GPG-KEY-webmin | gpg --dearmor > /usr/share/keyrings/debian-webmin.gpg" "Installing Webmin key" - + download "https://$upgrade_virtualmin_host_lib/RPM-GPG-KEY-virtualmin-$vm_version" "Downloading Virtualmin $vm_version key" + run_ok "gpg --import RPM-GPG-KEY-virtualmin-$vm_version && cat RPM-GPG-KEY-virtualmin-$vm_version | gpg --dearmor > /usr/share/keyrings/$repoid_debian_like-virtualmin-$vm_version.gpg" "Installing Virtualmin $vm_version key" + if [ "$vm6_repos" -eq 1 ]; then + download "https://$upgrade_virtualmin_host_lib/RPM-GPG-KEY-webmin" "Downloading Webmin key" + run_ok "gpg --import RPM-GPG-KEY-webmin && cat RPM-GPG-KEY-webmin | gpg --dearmor > /usr/share/keyrings/$repoid_debian_like-webmin.gpg" "Installing Webmin key" + fi run_ok "apt-get update" "Downloading repository metadata" # Make sure universe repos are available # XXX Test to make sure this run_ok syntax works as expected (with single quotes inside double) @@ -1213,6 +1308,33 @@ install_with_yum() { fatal "Installation failed: $rs" fi + # Initialize embedded modules + if [ -n "$unstable" ]; then + if [ -z "$module_name" ]; then + if [ "$os_type" = "opensuse-leap" ]; then + module_name="opensuse" + fi + fi + 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" + . "$pwd/${module_name}.sh" + # Download the module from the server + else + # We need HTTP client first + pre_check_http_client + $download "https://$upgrade_virtualmin_host_mods/${module_name}.sh" >>"$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" + . "./$module_name" + fi + fi + fi + return 0 } @@ -1255,7 +1377,7 @@ yum_check_skipped() { skippedpackagesnum=$((skippedpackagesnum+1)) fi done < "$log" - if [ "$skippedpackages" != "" ]; then + if [ -z "$noskippedpackagesforce" ] && [ "$skippedpackages" != "" ]; then if [ "$skippedpackagesnum" != 1 ]; then ts="s" fi @@ -1279,7 +1401,7 @@ fi # We want to make sure we're running our version of packages if we have # our own version. There's no good way to do this, but we'll -run_ok "$install_updates" "Installing Virtualmin $vm_version and all related packages updates" +run_ok "$install_updates" "Installing Virtualmin $vm_version related packages updates" if [ "$?" != "0" ]; then errorlist="${errorlist} ${YELLOW}◉${NORMAL} Installing updates returned an error.\\n" errors=$((errors + 1)) @@ -1304,8 +1426,8 @@ if [ "$mode" = "minimal" ]; then fi virtualmin-config-system --bundle "$bundle"$virtualmin_config_system_excludes # Log SSL request status, if available -if [ -f "$VMITMPDIR/virtualmin_ssl_host_status" ]; then - virtualmin_ssl_host_status=$(cat "$VMITMPDIR/virtualmin_ssl_host_status") +if [ -f "$VIRTUALMIN_INSTALL_TEMPDIR/virtualmin_ssl_host_status" ]; then + virtualmin_ssl_host_status=$(cat "$VIRTUALMIN_INSTALL_TEMPDIR/virtualmin_ssl_host_status") log_debug "$virtualmin_ssl_host_status" fi if [ "$?" != "0" ]; then @@ -1326,7 +1448,7 @@ disable_selinux() { # Changes that are specific to OS case "$os_type" in -"fedora" | "centos" | "centos_stream" | "rhel" | "rocky" | "almalinux" | "ol" | "cloudlinux") +rhel | fedora | centos | centos_stream | rocky | almalinux | ol | cloudlinux | amzn) disable_selinux ;; esac @@ -1338,17 +1460,17 @@ kill "$config_system_pid" 1>/dev/null 2>&1 tput cnorm 1>/dev/null 2>&1 # Was host default domain SSL request successful? -if [ -d "$VMITMPDIR/virtualmin_ssl_host_success" ]; then +if [ -d "$VIRTUALMIN_INSTALL_TEMPDIR/virtualmin_ssl_host_success" ]; then ssl_host_success=1 fi # Cleanup the tmp files printf "${GREEN}▣▣▣${NORMAL} Cleaning up\\n" -if [ "$VMITMPDIR" != "" ] && [ "$VMITMPDIR" != "/" ]; then - log_debug "Cleaning up temporary files in $VMITMPDIR." - find "$VMITMPDIR" -delete +if [ "$VIRTUALMIN_INSTALL_TEMPDIR" != "" ] && [ "$VIRTUALMIN_INSTALL_TEMPDIR" != "/" ]; then + log_debug "Cleaning up temporary files in $VIRTUALMIN_INSTALL_TEMPDIR." + find "$VIRTUALMIN_INSTALL_TEMPDIR" -delete else - log_error "Could not safely clean up temporary files because TMPDIR set to $VMITMPDIR." + log_error "Could not safely clean up temporary files because TMPDIR set to $VIRTUALMIN_INSTALL_TEMPDIR." fi if [ -n "$QUOTA_FAILED" ]; then