From 3b7f840e616e6c62fb0d6f61c4cdd6293a068433 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 00:11:22 +0300 Subject: [PATCH 01/30] Fix to ignore inessential warnings --- virtualmin-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 4aee0d3..e775910 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=SC2164 # virtualmin-install.sh # Copyright 2005-2023 Virtualmin, Inc. # Simple script to grab the virtualmin-release and virtualmin-base packages. From a62e89921300a1e9483cdc40c4329c6602fdf6fc Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 00:16:30 +0300 Subject: [PATCH 02/30] Fix to store install and uninstall logs separately --- virtualmin-install.sh | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index e775910..b98595c 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -27,18 +27,11 @@ upgrade_virtualmin_host=software.virtualmin.com # 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 @@ -140,6 +133,7 @@ while [ "$1" != "" ]; do --uninstall | -u) shift mode="uninstall" + log_type="virtualmin-uninstall" ;; *) printf "Unrecognized option: $1\\n\\n" @@ -149,6 +143,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 From 69807a74d12af83599ee6d0e0e096c9180aa0a39 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 00:29:21 +0300 Subject: [PATCH 03/30] Fix to always setup Virtualmin 7 repos unless CentOS 7 --- virtualmin-install.sh | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index b98595c..ba76060 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -51,7 +51,7 @@ usage() { 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" @@ -786,26 +786,13 @@ if [ "$(id -u)" -ne 0 ]; then fi if [ -n "$setup_only" ]; then - if [ "$setup_only_force_latest" -ne 1 ]; then - # If Virtualmin 6 is installed and a user needs to fix repos make, - # sure that we don't switch 6 to 7 to keep the same stack packages - reposfile="/etc/yum.repos.d/virtualmin.repo /etc/apt/sources.list.d/virtualmin.list /etc/apt/sources.list" - vm_prev_version_installed=$((vm_version - 1)) - for repofile in $reposfile; do - if [ -f "$repofile" ]; then - if grep -F -q "virtualmin-universal" "$repofile" || grep -F -q "/vm/$vm_prev_version_installed/" "$repofile"; then - - # Fix for Virtualmin 6 repos - if [ "$vm_prev_version_installed" = "6" ]; then - if [ "$SERIAL" != "GPL" ]; then - repopath="" - fi - vm_version=$vm_prev_version_installed - vm6_repos=1 - fi - fi - fi - done + # Force CentOS 7 to get older repos because of custom Apache + if [ "$os_type" = "centos" ] && [ "$os_major_version" -eq 7 ]; then + if [ "$SERIAL" != "GPL" ]; then + repopath="" + fi + vm_version=6 + vm6_repos=1 fi pre_check_perl pre_check_http_client @@ -1059,10 +1046,10 @@ install_virtualmin_release() { # 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" - + 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) From 344e0d76dee2f5fae7d69b23961337a45e5ee7d5 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 00:31:14 +0300 Subject: [PATCH 04/30] Fix to set correct key name for Debian vs derivatives --- virtualmin-install.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index ba76060..e8ce6c2 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -1031,6 +1031,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 @@ -1040,12 +1048,13 @@ 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/$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" From 6bacb79b4353cfca7a8e6033c2b8930d887edf87 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 00:33:09 +0300 Subject: [PATCH 05/30] Fix to drop obsolete option (repos set to Virtualmin unless CentOS 7) --- virtualmin-install.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index e8ce6c2..3be7613 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -106,16 +106,6 @@ 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 ;; --hostname | -n) shift From 67190b65eef3f9fec84b0cbf54875c5fb91c0090 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 00:35:07 +0300 Subject: [PATCH 06/30] Fix to rename Virtualmin install `tempdir` name --- virtualmin-install.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 3be7613..1a77191 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -221,22 +221,22 @@ 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 # "files" subdir for libs -mkdir "$VMITMPDIR/files" -srcdir="$VMITMPDIR/files" +mkdir "$VIRTUALMIN_INSTALL_TEMPDIR/files" +srcdir="$VIRTUALMIN_INSTALL_TEMPDIR/files" if ! cd "$srcdir"; then echo "Error: Failed to enter $srcdir temporary directory" exit 1 fi -export VMITMPDIR +export VIRTUALMIN_INSTALL_TEMPDIR pre_check_http_client() { # Check for wget or curl or fetch @@ -330,8 +330,8 @@ remove_virtualmin_release() { 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 + 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-* @@ -345,9 +345,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" @@ -1297,8 +1297,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 @@ -1331,17 +1331,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 From ef0f9eb6ad479f1de79dd79adbe3fb4d04ffb2ae Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 00:38:21 +0300 Subject: [PATCH 07/30] Fix to add ability to use `slib.sh` from local file (if available) For development purposes --- virtualmin-install.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 1a77191..4429ab9 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -277,18 +277,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 From ac15337be1799aa97a413b1ae86dd3c5a97bfc50 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 00:42:46 +0300 Subject: [PATCH 08/30] Add `hostnamectl --static` as backup option --- virtualmin-install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 4429ab9..4b843fb 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -813,6 +813,9 @@ log_debug "virtualmin-install.sh version: $VER" if [ -z "$setup_only" ]; then log_debug "Checking for fully qualified hostname .." name="$(hostname -f)" + if [ $? -ne 0 ]; then + name=$(hostnamectl --static) + fi if [ -n "$forcehostname" ]; then set_hostname "$forcehostname" elif ! is_fully_qualified "$name"; then From a1a3e072ef3236a363a56041a6645c5f403c35d5 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 00:43:28 +0300 Subject: [PATCH 09/30] Fix to improve the message sentence --- virtualmin-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 4b843fb..15a4d67 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -1279,7 +1279,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)) From 32e2fb0de9b93142aba4a126c4aa0620171f4e14 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 00:44:31 +0300 Subject: [PATCH 10/30] Fix to get distro info as soon as possible --- virtualmin-install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 15a4d67..96a7a68 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -303,6 +303,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 @@ -835,7 +838,6 @@ chmod 700 /etc/virtualmin-license cd .. # Populate some distro version globals -get_distro log_debug "Operating system name: $os_real" log_debug "Operating system version: $os_version" log_debug "Operating system type: $os_type" From 3be1d923691de9401d0e02875c7b8d8d25594fe5 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 01:04:27 +0300 Subject: [PATCH 11/30] Add improvements to uninstall process --- virtualmin-install.sh | 162 ++++++++++++++++++++++++------------------ 1 file changed, 91 insertions(+), 71 deletions(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 96a7a68..a8a9f50 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -331,18 +331,22 @@ log_fatal() { 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") + 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 } @@ -406,76 +410,92 @@ 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 + # Go to the temp directory + cd "$srcdir" - 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." + # 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 From 2eb68020b49b82100ccad9fff63f69a78c17a83d Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 01:08:25 +0300 Subject: [PATCH 12/30] Add unstable OS (Grade B) warning before installation --- virtualmin-install.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index a8a9f50..f6209ad 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -571,6 +571,35 @@ if [ "$skipyesno" -ne 1 ] && [ -z "$setup_only" ]; then install_msg fi +os_unstable_pre_check() { + if [ -n "$unstable" ]; then + cat < Date: Wed, 20 Sep 2023 01:09:17 +0300 Subject: [PATCH 13/30] Fix to move Amazon Linux to the bottom (for version order consistency) --- virtualmin-install.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index f6209ad..1b8df35 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -941,6 +941,12 @@ install_virtualmin_release() { exit 1 fi ;; + amzn) + if [ "$os_version" -lt 2023 ] || [ -z "$unstable" ] && [ "$os_type" = "amzn" ] ; then + printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by stable installer${unstable_suffix}\\n" + exit 1 + fi + ;; *) printf "${RED}This OS/version is not recognized! Cannot continue!${NORMAL}\\n" exit 1 From 5f7aca424e5e1a825b0b787c2c21dceadf94f779 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 01:25:31 +0300 Subject: [PATCH 14/30] Fix to abstract `dnf` and `yum` commands and opts --- virtualmin-install.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 1b8df35..67962b3 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -962,26 +962,28 @@ install_virtualmin_release() { fi package_type="rpm" if command -pv dnf 1>/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 From 41235fd4b69eadf9c5e539b5689cce3869a323f4 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 01:27:30 +0300 Subject: [PATCH 15/30] Fix distros list order for consistency ; don't use quotes --- virtualmin-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 67962b3..a1a2745 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -898,7 +898,7 @@ install_virtualmin_release() { # Grab virtualmin-release from the server log_debug "Configuring package manager for ${os_real} ${os_version} .." case "$os_type" in - rhel | centos | centos_stream | rocky | almalinux | ol | cloudlinux | amzn | fedora) + rhel | fedora | centos | centos_stream | rocky | almalinux | ol | cloudlinux | amzn | opensuse-leap) case "$os_type" in rhel | centos | centos_stream) if [ "$os_type" = "centos_stream" ]; then @@ -1386,7 +1386,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 From 32ce5cfa1fb9d2fc1adbbd5530f0ecd6f53be218 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 01:28:54 +0300 Subject: [PATCH 16/30] Fix to add a flag to hide skipped packages --- virtualmin-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index a1a2745..b216e26 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -1315,7 +1315,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 From acfc2efc846dee9e2b51097478aedf9b8d73da06 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 03:09:06 +0300 Subject: [PATCH 17/30] Add openSUSE support in a separate module --- opensuse.sh | 47 +++++++++++++++++++++++++++++++++++++++++++ virtualmin-install.sh | 46 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 opensuse.sh diff --git a/opensuse.sh b/opensuse.sh new file mode 100644 index 0000000..680ecbc --- /dev/null +++ b/opensuse.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# Copyright 2005-2023 Virtualmin, Inc. +# virtualmin-install.sh - openSUSE module + +# Fix openSUSE pitfalls +opensuse_poststack() { + # Install Virtualmin Config package manually + # as it currently fails with false positive error + echo "Hello im module $module_name -- $install_group_opts" + 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 b216e26..de126b7 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 disable=SC2089 disable=SC2090 disable=SC1091 disable=SC2164 +# shellcheck disable=SC2059 disable=SC2181 disable=SC2154 disable=SC2317 disable=SC3043 disable=SC2086 disable=SC2039 disable=SC2034 disable=SC2089 disable=SC2090 disable=SC1091 disable=SC2164 disable=SC1090 # virtualmin-install.sh # Copyright 2005-2023 Virtualmin, Inc. # Simple script to grab the virtualmin-release and virtualmin-base packages. @@ -23,6 +23,7 @@ vm_version=7 # Server upgrade_virtualmin_host=software.virtualmin.com +upgrade_virtualmin_host_mods="$upgrade_virtualmin_host/mods" # Currently supported systems # https://www.virtualmin.com/os-support/ @@ -107,6 +108,15 @@ while [ "$1" != "" ]; do mode='setup' unstable='unstable' ;; + # 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 forcehostname=$1 @@ -539,6 +549,7 @@ EOF - 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 \ + - openSUSE Server 15 on x86_64\\n \ ${NORMAL}" unstable_deb="${YELLOW}- Kali Linux Rolling on x86_64\\n \ ${NORMAL}" @@ -929,9 +940,9 @@ install_virtualmin_release() { exit 1 fi ;; - amzn) - if [ "$os_version" -lt 2023 ] || [ -z "$unstable" ] && [ "$os_type" = "amzn" ] ; then - printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by stable installer${unstable_suffix}\\n" + opensuse-leap) + if [ "$os_major_version" -lt 15 ] || [ -z "$unstable" ] && [ "$os_type" = "opensuse-leap" ] ; then + printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer${unstable_suffix}\\n" exit 1 fi ;; @@ -1273,6 +1284,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 } From ec9f07af404f23d7d70b4c635cede9a8f75827e7 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 03:25:17 +0300 Subject: [PATCH 18/30] Fix to show unstable warning only for Grade B systems --- virtualmin-install.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index de126b7..39940d5 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -339,6 +339,16 @@ 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 +} + remove_virtualmin_release() { case "$os_type" in rhel | fedora | centos | centos_stream | rocky | almalinux | ol | cloudlinux | amzn | opensuse-leap) @@ -663,7 +673,10 @@ EOF fi } if [ "$skipyesno" -ne 1 ] && [ -z "$setup_only" ]; then - os_unstable_pre_check + grade_b_system + if [ $? -eq 1 ]; then + os_unstable_pre_check + fi preconfigured_system_msg already_installed_msg fi From b168ebbe285a4f629437b82a00fdffde88cc3e5c Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 03:43:44 +0300 Subject: [PATCH 19/30] Fix to drop `--unstable` flag in favor of automatic detection --- virtualmin-install.sh | 54 ++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 39940d5..73f6d75 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -49,7 +49,6 @@ 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" @@ -87,12 +86,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' @@ -349,6 +342,14 @@ grade_b_system() { 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 rhel | fedora | centos | centos_stream | rocky | almalinux | ol | cloudlinux | amzn | opensuse-leap) @@ -554,14 +555,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/") @@ -918,7 +919,6 @@ log_debug "Operating system type: $os_type" log_debug "Operating system major: $os_major_version" install_virtualmin_release() { - unstable_suffix=" but it can be installed as Grade B system using ${YELLOW}--unstable${NORMAL} flag." # Grab virtualmin-release from the server log_debug "Configuring package manager for ${os_real} ${os_version} .." case "$os_type" in @@ -926,8 +926,8 @@ install_virtualmin_release() { case "$os_type" in rhel | centos | centos_stream) if [ "$os_type" = "centos_stream" ]; then - if [ "$os_major_version" -lt 8 ] || [ -z "$unstable" ]; then - printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer${unstable_suffix}\\n" + if [ "$os_major_version" -lt 8 ]; then + printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer.\\n" exit 1 fi else @@ -938,36 +938,32 @@ install_virtualmin_release() { fi ;; rocky | almalinux | ol) - if [ "$os_major_version" -lt 8 ] || [ -z "$unstable" ] && [ "$os_type" = "ol" ]; then - can_unstable_suffix="." - if [ "$os_type" = "ol" ]; then - can_unstable_suffix="$unstable_suffix" - fi - printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer${can_unstable_suffix}\\n" + if [ "$os_major_version" -lt 8 ]; then + printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer.\\n" exit 1 fi ;; cloudlinux) - if [ "$os_major_version" -lt 8 ] || [ -z "$unstable" ] && [ "$os_type" = "cloudlinux" ]; then - printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer${unstable_suffix}\\n" + if [ "$os_major_version" -lt 8 ] && [ "$os_type" = "cloudlinux" ]; then + printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer.\\n" exit 1 fi ;; opensuse-leap) - if [ "$os_major_version" -lt 15 ] || [ -z "$unstable" ] && [ "$os_type" = "opensuse-leap" ] ; then - printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer${unstable_suffix}\\n" + if [ "$os_major_version" -lt 15 ] && [ "$os_type" = "opensuse-leap" ] ; then + printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer.\\n" exit 1 fi ;; fedora) - if [ "$os_version" -lt 35 ] || [ -z "$unstable" ] && [ "$os_type" = "fedora" ] ; then - printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer${unstable_suffix}\\n" + if [ "$os_major_version" -lt 35 ] && [ "$os_type" = "fedora" ] ; then + printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer.\\n" exit 1 fi ;; amzn) - if [ "$os_version" -lt 2023 ] || [ -z "$unstable" ] && [ "$os_type" = "amzn" ] ; then - printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by stable installer${unstable_suffix}\\n" + if [ "$os_major_version" -lt 2023 ] && [ "$os_type" = "amzn" ] ; then + printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by stable installer.\\n" exit 1 fi ;; @@ -1060,8 +1056,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 ;; From 06bda95b78ec794c4cca503fcf2379849e742d78 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 13:42:42 +0300 Subject: [PATCH 20/30] Fix to remove debug line --- opensuse.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/opensuse.sh b/opensuse.sh index 680ecbc..f12c373 100644 --- a/opensuse.sh +++ b/opensuse.sh @@ -6,7 +6,6 @@ opensuse_poststack() { # Install Virtualmin Config package manually # as it currently fails with false positive error - echo "Hello im module $module_name -- $install_group_opts" 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 From 12e6ac3c67ddcc8565a8b094e38aa6f6bd3073e6 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 14:48:38 +0300 Subject: [PATCH 21/30] Fix to not to disable SC2164 --- virtualmin-install.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 73f6d75..74efce0 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 disable=SC2089 disable=SC2090 disable=SC1091 disable=SC2164 disable=SC1090 +# 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. @@ -235,11 +235,15 @@ fi # "files" subdir for libs mkdir "$VIRTUALMIN_INSTALL_TEMPDIR/files" srcdir="$VIRTUALMIN_INSTALL_TEMPDIR/files" -if ! cd "$srcdir"; then - echo "Error: Failed to enter $srcdir temporary directory" - exit 1 -fi -export VIRTUALMIN_INSTALL_TEMPDIR + +# 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 @@ -455,7 +459,7 @@ uninstall() { fi # Go to the temp directory - cd "$srcdir" + goto_tmpdir # Uninstall packages uninstall_packages() From 8356560926bc78ba85fe1a86be7d7b2e358499a6 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 14:49:19 +0300 Subject: [PATCH 22/30] Fix to disable shell check for embedded module --- opensuse.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/opensuse.sh b/opensuse.sh index f12c373..8dbf1c2 100644 --- a/opensuse.sh +++ b/opensuse.sh @@ -1,6 +1,7 @@ #!/bin/sh # Copyright 2005-2023 Virtualmin, Inc. # virtualmin-install.sh - openSUSE module +# shellcheck disable=SC2154 disable=SC2034 disable=SC2086 # Fix openSUSE pitfalls opensuse_poststack() { From 50d2c7c741765cbf028cc1edb5599fd8d7e07f75 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 14:50:40 +0300 Subject: [PATCH 23/30] Fix to place exported variable after the block it was defined --- virtualmin-install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 74efce0..5766641 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -232,6 +232,9 @@ if [ -z "$VIRTUALMIN_INSTALL_TEMPDIR" ]; then mkdir "$VIRTUALMIN_INSTALL_TEMPDIR" fi +# Export temp directory for Virtualmin Config +export VIRTUALMIN_INSTALL_TEMPDIR + # "files" subdir for libs mkdir "$VIRTUALMIN_INSTALL_TEMPDIR/files" srcdir="$VIRTUALMIN_INSTALL_TEMPDIR/files" From 08fa9c6eb3e1f2081824d07500a7b18039b99cc9 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 14:53:05 +0300 Subject: [PATCH 24/30] Version 7.2.0 bump --- virtualmin-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 5766641..2efaa85 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -18,7 +18,7 @@ # License and version SERIAL=GPL KEY=GPL -VER=7.1.2 +VER=7.2.0 vm_version=7 # Server From bb53ff3c708856d3e360cb4ea6a26642f23e1a36 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 15:15:27 +0300 Subject: [PATCH 25/30] Fix to always force Virtualmin 6 repos for CentOS 7 --- virtualmin-install.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 2efaa85..6858d22 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -864,15 +864,16 @@ if [ "$(id -u)" -ne 0 ]; then fi fi -if [ -n "$setup_only" ]; then - # Force CentOS 7 to get older repos because of custom Apache - if [ "$os_type" = "centos" ] && [ "$os_major_version" -eq 7 ]; then - if [ "$SERIAL" != "GPL" ]; then - repopath="" - fi - vm_version=6 - vm6_repos=1 +# Force CentOS 7 to get older repos because of custom Apache +if [ "$os_type" = "centos" ] && [ "$os_major_version" -eq 7 ]; then + if [ "$SERIAL" != "GPL" ]; then + repopath="" fi + vm_version=6 + vm6_repos=1 +fi + +if [ -n "$setup_only" ]; then pre_check_perl pre_check_http_client pre_check_gpg From e6d079fb258563283079444a3c2d013828c729aa Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 19:46:03 +0300 Subject: [PATCH 26/30] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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. From 9c969dc7df5dd76f43445182a75a1995a78108c8 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 21:07:30 +0300 Subject: [PATCH 27/30] Fix for openSUSE module have version too --- opensuse.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opensuse.sh b/opensuse.sh index 8dbf1c2..98f97fe 100644 --- a/opensuse.sh +++ b/opensuse.sh @@ -1,7 +1,7 @@ #!/bin/sh -# Copyright 2005-2023 Virtualmin, Inc. -# virtualmin-install.sh - openSUSE module # 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() { From 65280993ea901591b9fa16a5df2e480958d5ed7f Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 21:11:36 +0300 Subject: [PATCH 28/30] Fix modules URL --- virtualmin-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 6858d22..34f08bb 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -23,7 +23,7 @@ vm_version=7 # Server upgrade_virtualmin_host=software.virtualmin.com -upgrade_virtualmin_host_mods="$upgrade_virtualmin_host/mods" +upgrade_virtualmin_host_mods="$upgrade_virtualmin_host/lib/mods" # Currently supported systems # https://www.virtualmin.com/os-support/ From 488c31717b3ae50edae3778d3e180b4a79ef34c7 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 20 Sep 2023 21:17:35 +0300 Subject: [PATCH 29/30] Fix to abstract lib URL --- virtualmin-install.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index 34f08bb..a45b28b 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -23,7 +23,8 @@ vm_version=7 # Server upgrade_virtualmin_host=software.virtualmin.com -upgrade_virtualmin_host_mods="$upgrade_virtualmin_host/lib/mods" +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/ @@ -295,7 +296,7 @@ download_slib() { else # We need HTTP client first pre_check_http_client - $download "https://$upgrade_virtualmin_host/lib/slib.sh" >>"$log" 2>&1 + $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 @@ -1138,10 +1139,10 @@ install_virtualmin_release() { # 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" + 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" + 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" From 85bc56bd1c9e692a37ced64b80fcb58a47ed374e Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Thu, 21 Sep 2023 01:37:05 +0300 Subject: [PATCH 30/30] Fix to add log to file message --- virtualmin-install.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/virtualmin-install.sh b/virtualmin-install.sh index a45b28b..dfeffbc 100644 --- a/virtualmin-install.sh +++ b/virtualmin-install.sh @@ -462,6 +462,12 @@ uninstall() { fi fi + # Log to file and tell the user nicely + log_info "Started uninstallation log in $log" + + # Always sleep just a bit in case the user changes their mind + sleep 1 + # Go to the temp directory goto_tmpdir