├── .travis.yml ├── t ├── shellcheck.t ├── checkbashisms.t └── usage.t ├── modules ├── virtualmin-install-modules.sh ├── README.md └── virtualmin-install-module-s3-scheduled-backups.sh ├── .github └── workflows │ └── virtualmin.dev+virtualmin-install.yml ├── README.md ├── LICENSE └── virtualmin-install.sh /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: jammy 2 | before_install: 3 | - sudo apt-get update -qq 4 | - sudo apt-get install -qq perl shellcheck devscripts 5 | script: prove 6 | -------------------------------------------------------------------------------- /t/shellcheck.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | use strict; 3 | use warnings; 4 | use 5.010; 5 | 6 | use Test::Simple tests => 1; 7 | 8 | ok( system('shellcheck virtualmin-install.sh') == 0 ); 9 | 10 | -------------------------------------------------------------------------------- /t/checkbashisms.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | use strict; 3 | use warnings; 4 | use 5.010; 5 | 6 | use Test::Simple tests => 1; 7 | 8 | ok( system('checkbashisms virtualmin-install.sh') == 0 ); 9 | 10 | -------------------------------------------------------------------------------- /t/usage.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | use strict; 3 | use warnings; 4 | use 5.010; 5 | 6 | use Test::Simple tests => 3; 7 | 8 | my @usage = `sh virtualmin-install.sh --help`; 9 | ok( grep { /^Usage:/ } @usage ); 10 | 11 | @usage = `sh virtualmin-install.sh -h`; 12 | ok( grep { /^Usage:/ } @usage ); 13 | 14 | @usage = `sh virtualmin-install.sh --invalid-option`; 15 | ok( grep { /^Usage:/ } @usage ); 16 | -------------------------------------------------------------------------------- /modules/virtualmin-install-modules.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2005-2024 Virtualmin 4 | # Simple script to call individual Virtualmin install modules 5 | 6 | # Set the path 7 | pwd="${pwd:-.}" 8 | 9 | # Source individual Virtualmin install modules 10 | # shellcheck disable=SC1091 11 | # shellcheck source=virtualmin-install-module-s3-scheduled-backups.sh 12 | if [ -f "$pwd/virtualmin-install-module-s3-scheduled-backups.source" ]; then 13 | . "$pwd/virtualmin-install-module-s3-scheduled-backups.source" 14 | fi 15 | . "$pwd/virtualmin-install-module-s3-scheduled-backups.sh" 16 | -------------------------------------------------------------------------------- /modules/README.md: -------------------------------------------------------------------------------- 1 | ## Virtualmin Install Modules 2 | 3 | This directory contains modules to run in Virtualmin post-installation process 4 | to configure specific tasks. 5 | 6 | ### Script Details 7 | 8 | #### virtualmin-install-modules.sh 9 | 10 | Main script to orchestrate different scripts in the setup process. This script 11 | sources the individual configuration scripts. 12 | 13 | #### virtualmin-install-module-s3-scheduled-backups.sh 14 | 15 | Script to configure AWS S3 and Virtualmin scheduled backups. This script 16 | configures AWS S3 and Virtualmin scheduled backups with given S3 bucket details. 17 | 18 | ##### Script Parameters 19 | Parameters can be set as environment variables or sourced from a file named 20 | `virtualmin-install-module-s3-scheduled-backups.source`, placed in the same 21 | directory as the script before running the installation script. 22 | 23 | Required parameters are: 24 | 25 | - `S3KEY`: S3 access key 26 | - `S3SEC`: S3 secret key 27 | - `S3RGN`: S3 region 28 | 29 | Optional parameters are: 30 | 31 | - `S3END`: S3 endpoint (for compatibility with other S3-compatible services) 32 | - `S3NAM`: S3 bucket name 33 | 34 | ### Example Usage 35 | 36 | ```bash 37 | export S3KEY 38 | export S3SEC 39 | export S3RGN 40 | virtualmin-install.sh --bundle LAMP --module virtualmin-install-module-s3-scheduled-backups 41 | ``` 42 | -------------------------------------------------------------------------------- /.github/workflows/virtualmin.dev+virtualmin-install.yml: -------------------------------------------------------------------------------- 1 | name: "virtualmin.dev: virtualmin/virtualmin-install" 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | release: 8 | types: 9 | - prereleased 10 | - released 11 | 12 | env: 13 | GH_REPO: ${{ github.repository }} 14 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 15 | 16 | IS_RELEASE: ${{ github.event_name == 'release' }} 17 | IS_PRERELEASE: ${{ github.event.release.prerelease || false }} 18 | 19 | BUILD_DEPS: "curl" 20 | BUILD_BOOTSTRAP: "https://raw.githubusercontent.com/webmin/webmin-ci-cd/main/build/bootstrap.bash" 21 | 22 | jobs: 23 | build-amd64: 24 | runs-on: ubuntu-latest 25 | if: ${{ !contains(github.event.head_commit.message, '[no-build]') }} 26 | env: 27 | TZ: Europe/Nicosia 28 | steps: 29 | - name: Checkout code 30 | uses: actions/checkout@v4 31 | 32 | - uses: awalsh128/cache-apt-pkgs-action@latest 33 | with: 34 | packages: ${{ env.BUILD_DEPS }} 35 | version: 1.0 36 | 37 | - name: Fetch dependencies 38 | run: curl -O ${{ env.BUILD_BOOTSTRAP }} 39 | 40 | - name: Set timezone 41 | run: sudo timedatectl set-timezone ${{ env.TZ }} 42 | 43 | - name: Upload file 44 | env: 45 | CLOUD__IP_ADDR: ${{ secrets.DEV_IP_ADDR }} 46 | CLOUD__IP_KNOWN_HOSTS: ${{ secrets.DEV_IP_KNOWN_HOSTS }} 47 | CLOUD__UPLOAD_SSH_USER: ${{ secrets.DEV_UPLOAD_SSH_USER }} 48 | CLOUD__UPLOAD_SSH_DIR: ${{ env.IS_RELEASE == 'true' && secrets.PRERELEASE_UPLOAD_SSH_DIR || secrets.DEV_UPLOAD_SSH_DIR }} 49 | CLOUD__SSH_PRV_KEY: ${{ secrets.DEV_SSH_PRV_KEY }} 50 | run: |- 51 | 52 | # Fail on error 53 | set -euo pipefail 54 | 55 | # Bootstrap build 56 | source bootstrap.bash \ 57 | $([[ "$IS_RELEASE" == "true" ]] && echo "--release" || echo "--testing") \ 58 | $([[ "$IS_PRERELEASE" == "true" ]] && echo "--prerelease") 59 | 60 | # Get package version 61 | pkg_version=$(get_remote_git_tag_version "$GH_REPO" "$GH_TOKEN" "$IS_RELEASE") 62 | 63 | # Prepare build 64 | virtualmin_install_versioned="virtualmin-install-$pkg_version.sh" 65 | cp -p virtualmin-install.sh "$virtualmin_install_versioned" 66 | 67 | # Delete previous versions and upload new files 68 | upload_list=("virtualmin-install.sh" "$virtualmin_install_versioned") 69 | delete_list=("$CLOUD_UPLOAD_SSH_DIR virtualmin-install * *sh") 70 | cloud_upload upload_list delete_list 71 | cloud_sync_remote_repos 72 | -------------------------------------------------------------------------------- /modules/virtualmin-install-module-s3-scheduled-backups.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2005-2024 Virtualmin 4 | # Simple script to configure Virtualmin S3 scheduled backups 5 | 6 | S3NAM=${S3NAM:-'Default S3 Backup Server'} 7 | # Environment variables must be set prior 8 | S3KEY=${S3KEY} 9 | S3SEC=${S3SEC} 10 | S3RGN=${S3RGN} 11 | S3END=${S3END} 12 | 13 | if [ -z "$S3KEY" ] || [ -z "$S3SEC" ] || [ -z "$S3RGN" ]; then 14 | log_debug "Virtualmin S3 module: Failed to install '$S3NAM' as the required 'S3KEY', 'S3SEC', and 'S3RGN' environment variables are missing" 15 | else 16 | # Fixed variables 17 | ACCOUNT_ID='171977777700000' 18 | BACKUP_ID='171977777700007' 19 | CRON_ID='1719777777000770' 20 | HOSTNAME=$(hostname) 21 | 22 | # Create /root/.aws/config 23 | mkdir -p /root/.aws 24 | cat </root/.aws/config 25 | [${ACCOUNT_ID}] 26 | region = ${S3RGN} 27 | EOL 28 | 29 | # Create /root/.aws/credentials 30 | cat </root/.aws/credentials 31 | [${ACCOUNT_ID}] 32 | aws_access_key_id = ${S3KEY} 33 | aws_secret_access_key = ${S3SEC} 34 | region = ${S3RGN} 35 | EOL 36 | 37 | # Create /etc/webmin/virtual-server/s3accounts/${ACCOUNT_ID} 38 | mkdir -p /etc/webmin/virtual-server/s3accounts 39 | cat </etc/webmin/virtual-server/s3accounts/${ACCOUNT_ID} 40 | id=${ACCOUNT_ID} 41 | secret=${S3SEC} 42 | location=${S3RGN} 43 | access=${S3KEY} 44 | desc=${S3NAM} 45 | EOL 46 | 47 | # Add the endpoint if set 48 | if [ -n "$S3END" ]; then 49 | echo "endpoint=${S3END}" >>/etc/webmin/virtual-server/s3accounts/${ACCOUNT_ID} 50 | fi 51 | 52 | # Create /etc/webmin/virtual-server/backups/${BACKUP_ID} 53 | mkdir -p /etc/webmin/virtual-server/backups 54 | cat </etc/webmin/virtual-server/backups/${BACKUP_ID} 55 | mkdir=1 56 | email_doms= 57 | plan= 58 | desc= 59 | before= 60 | features= 61 | doms= 62 | id=${BACKUP_ID} 63 | exclude= 64 | fmt=2 65 | virtualmin= 66 | compression= 67 | file=/etc/webmin/virtual-server/backups/${BACKUP_ID} 68 | onebyone=1 69 | special= 70 | errors=0 71 | feature_all=1 72 | days=* 73 | include= 74 | purge= 75 | email=root 76 | mins=0 77 | after= 78 | parent=1 79 | enabled=2 80 | weekdays=* 81 | email_err=1 82 | all=1 83 | months=* 84 | key= 85 | increment=0 86 | strftime=1 87 | kill=0 88 | dest=s3://${ACCOUNT_ID}@${HOSTNAME}/backup-%Y-%m-%d-%H-%M 89 | interval= 90 | ownrestore=0 91 | hours=0,4,8,12,16,20 92 | backup_opts_dir=dirnohomes=0,dirnologs=0 93 | EOL 94 | 95 | # Create /etc/webmin/virtual-server/backup.pl with 755 permissions 96 | cat <<'EOL' >/etc/webmin/virtual-server/backup.pl 97 | #!/usr/bin/perl 98 | open(CONF, ") { 100 | $root = $1 if (/^root=(.*)/); 101 | } 102 | close(CONF); 103 | $root || die "No root= line found in /etc/webmin/miniserv.conf"; 104 | $ENV{'PERLLIB'} = "$root"; 105 | $ENV{'WEBMIN_CONFIG'} = "/etc/webmin"; 106 | $ENV{'WEBMIN_VAR'} = "/var/webmin"; 107 | delete($ENV{'MINISERV_CONFIG'}); 108 | chdir("$root/virtual-server"); 109 | exec("$root/virtual-server/backup.pl", @ARGV) || die "Failed to run $root/virtual-server/backup.pl : $!"; 110 | EOL 111 | chmod 755 /etc/webmin/virtual-server/backup.pl 112 | 113 | # Create /etc/webmin/webmincron/crons/${CRON_ID}.cron 114 | mkdir -p /etc/webmin/webmincron/crons 115 | cat </etc/webmin/webmincron/crons/${CRON_ID}.cron 116 | arg0=backup.pl 117 | months=* 118 | active=1 119 | special= 120 | interval= 121 | func=run_cron_script 122 | hours=0,4,8,12,16,20 123 | days=* 124 | mins=0 125 | user=root 126 | arg1=--id ${BACKUP_ID} 127 | id=${CRON_ID} 128 | module=virtual-server 129 | weekdays=* 130 | EOL 131 | log_debug "Virtualmin S3 module: '$S3NAM' was successfully installed." 132 | fi 133 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.com/virtualmin/virtualmin-install.svg?branch=master)](https://app.travis-ci.com/github/virtualmin/virtualmin-install) 2 | 3 | # virtualmin-install 4 | Shell script to perform a Virtualmin GPL or Professional installation 5 | 6 | If you just want to install Virtualmin, go here and follow the instructions: [Virtualmin.com](https://www.virtualmin.com/download). 7 | 8 | This repo is for people who want to read the source, contribute, help make the installer support other distros or operating systems, or make a customized installer. 9 | 10 | # How it Works 11 | The script relies on our software repositories on _software.virtualmin.com_ in order to function. You'll need internet access. 12 | 13 | It sets up or downloads the software repository configuration file for your OS (`yum/dnf` on RHEL (Alma/Rocky/Oracle/CentOS/Fedora) or 14 | `apt-get` on Debian/Ubuntu), and runs the necessary commands to download and install all of the stuff needed for a 15 | Virtualmin web hosting system. This is includes OS-standard packages or MySQL or MariaDB, Postfix, Dovecot, procmail, 16 | Mailman, PHP, Python, Ruby, SpamAssassin, ClamAV, BIND, and many others. When no OS-standard package is available or 17 | the standard package needs tweaks, we provide it in our repository and fetch it from there. 18 | 19 | ## Supported Operating Systems 20 | 21 | The **Grade A** systems currently supported by install script are: 22 | 23 | Red Hat Enterprise Linux and derivatives 24 | - Alma and Rocky 8, 9 and 10 on x86_64 and aarch64 25 | - RHEL 8, 9 and 10 on x86_64 and aarch64 26 | 27 | Debian Linux and derivatives 28 | - Debian 11, 12 and 13 on i386, amd64 and arm64 29 | - Ubuntu 20.04, 22.04 and 24.04 on i386, amd64 and arm64 30 | 31 | The _Grade B_ systems currently supported by install script are: 32 | 33 | Red Hat Enterprise Linux and derivatives 34 | - Fedora Server 42 and above on x86_64 and aarch64 35 | - CentOS Stream 8, 9 and 10 on x86_64 and aarch64 36 | - Oracle Linux 8, 9 and 10 on x86_64 and aarch64 37 | - Amazon Linux 2023 and above on x86_64 and aarch64 38 | - CloudLinux 8 and 9 on x86_64 39 | - openEuler 24.03 and above on x86_64 and aarch64 40 | 41 | Debian Linux and derivatives 42 | - Kali Linux Rolling 2025 and above on x86_64 43 | - Ubuntu interim (non-LTS) on i386, amd64 and arm64 44 | 45 | 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. 46 | 47 | # How to run it 48 | 49 | > Never run the install script on anything other than a **freshly installed OS**. It is for installation, _not upgrading_! 50 | 51 | ## Upstream Version 52 | 53 | Download it to your server, and run it as _`root`_ (yes, it has to run as _`root`_, this is systems management software). 54 | 55 | # wget -O virtualmin-install.sh https://raw.githubusercontent.com/virtualmin/virtualmin-install/master/virtualmin-install.sh 56 | # /bin/sh virtualmin-install.sh 57 | 58 | Note that if you have Virtualmin Professional, the process is a little different (or you have to edit the script to add your serial number and key to the `SERIAL` and `KEY` variables on lines 19 and 20). You can retrieve your license information from the [My Account ⇾ Software Licenses](https://www.virtualmin.com/account/software-licenses/) page at Virtualmin website. If you don't have Pro but want to get it, visit [Virtualmin Shop](https://www.virtualmin.com/product-category/virtualmin). 59 | 60 | Please file tickets, either here or at [Virtualmin Forum](https://forum.virtualmin.com), about bugs you find. 61 | 62 | # How to use it in your own project 63 | 64 | The Virtualmin install script is highly customizable and includes various hooks that can be inserted at any stage of the installation process. If you're integrating the script into your own project, you can use these hooks to inject custom code, add new phases, or control the text displayed to the user throughout the installation. 65 | 66 | ## Usage example for your project in a wrapper script 67 |
68 | Detailed description of hooks 69 | 70 | ```sh 71 | hook__usage() { 72 | # If defined, it will override the default usage message 73 | : 74 | } 75 | 76 | hook__parse_args() { 77 | # If defined, it will override the default argument parsing, and will not 78 | # parse default arguments if this hook is defined, relying on the custom 79 | # code to parse the arguments and set default values 80 | : 81 | } 82 | 83 | hook__show_version() { 84 | # If defined, it will override the installer default version 85 | : 86 | } 87 | 88 | hook__install_msg() { 89 | # If defined, it will override the default welcome message 90 | : 91 | } 92 | 93 | pre_hook__install_msg() { 94 | # If defined, it will inject a message before the default welcome message 95 | : 96 | } 97 | 98 | post_hook__install_msg() { 99 | # If defined, it will inject a message after the default welcome message 100 | : 101 | } 102 | 103 | hook__os_unstable_pre_check() { 104 | # If defined, it will override the default pre-check message for unstable OS 105 | : 106 | } 107 | 108 | pre_hook__os_unstable_pre_check() { 109 | # If defined, it will inject a message before the default pre-check 110 | # message for unstable OS 111 | : 112 | } 113 | 114 | post_hook__os_unstable_pre_check() { 115 | # If defined, it will inject a message after the default pre-check 116 | # message for unstable OS 117 | : 118 | } 119 | 120 | hook__preconfigured_system_msg() { 121 | # If defined, it will override the default system message about 122 | # pre-installed software 123 | : 124 | } 125 | 126 | pre_hook__preconfigured_system_msg() { 127 | # If defined, it will inject a message before the default system 128 | # message about pre-installed software 129 | : 130 | } 131 | 132 | post_hook__preconfigured_system_msg() { 133 | # If defined, it will inject a message after the default system 134 | # message about pre-installed software 135 | : 136 | } 137 | 138 | hook__already_installed_msg() { 139 | # If defined, it will override the default message about already 140 | # installed Virtualmin 141 | : 142 | } 143 | 144 | pre_hook__already_installed_msg() { 145 | # If defined, it will inject a message before the default message 146 | # about already installed Virtualmin 147 | : 148 | } 149 | 150 | post_hook__already_installed_msg() { 151 | # If defined, it will inject a message after the default message 152 | # about already installed Virtualmin 153 | : 154 | } 155 | 156 | hook__already_installed_block() { 157 | # If defined, it will override the default block message about 158 | # installed Virtualmin 159 | : 160 | } 161 | 162 | pre_hook__already_installed_block() { 163 | # If defined, it will inject a message before the default block message 164 | # about already installed Virtualmin 165 | : 166 | } 167 | 168 | post_hook__already_installed_block() { 169 | # If defined, it will inject a message after the default block message 170 | # about already installed Virtualmin 171 | : 172 | } 173 | 174 | hook__phases_all_pre() { 175 | # If defined, it will run before all phases 176 | : 177 | } 178 | 179 | hook__phase1_pre() { 180 | # If defined, it will run before the default phase 1 181 | : 182 | } 183 | 184 | hook__phase1_post() { 185 | # If defined, it will run after the default phase 1 186 | : 187 | } 188 | 189 | hook__phase2_pre() { 190 | # If defined, it will run before the default phase 2 191 | : 192 | } 193 | 194 | hook__phase2_post() { 195 | # If defined, it will run after the default phase 2 196 | : 197 | } 198 | 199 | hook__phase3_pre() { 200 | # If defined, it will run before the default phase 3 201 | : 202 | } 203 | 204 | hook__phase3_post() { 205 | # If defined, it will run after the default phase 3 206 | : 207 | } 208 | 209 | hook__phase4_pre() { 210 | # If defined, it will run before the default phase 4 211 | : 212 | } 213 | 214 | hook__phase4_post() { 215 | # If defined, it will run after the default phase 4 216 | : 217 | } 218 | 219 | hook__phases_all_post() { 220 | # If defined, it will run after all phases 221 | : 222 | } 223 | 224 | hook__modules_pre() { 225 | # If defined, it will run before the embedded modules installation phase 226 | : 227 | } 228 | 229 | hook__modules_post() { 230 | # If defined, it will run after the embedded modules installation phase 231 | : 232 | } 233 | 234 | hook__clean_pre() { 235 | # If defined, it will run before the cleanup phase 236 | : 237 | } 238 | 239 | hook__clean_post() { 240 | # If defined, it will run after the cleanup phase 241 | : 242 | } 243 | 244 | hook__post_install_message() { 245 | # If defined, it will override the default post-install message 246 | : 247 | } 248 | 249 | pre_hook__post_install_message() { 250 | # If defined, it will inject a message before the default post-install message 251 | : 252 | } 253 | 254 | post_hook__post_install_message() { 255 | # If defined, it will inject a message after the default post-install message 256 | : 257 | } 258 | 259 | hook__phases_pre() { 260 | # If defined, it will run before the custom phases start 261 | : 262 | } 263 | 264 | hook__phases_post() { 265 | # If defined, it will run after the custom phases end 266 | : 267 | } 268 | 269 | # Override the default log file name 270 | install_log_file_name=combined-install.log 271 | export install_log_file_name 272 | 273 | # If defined, it will override the default number of 274 | # phases for the use in custom phases (default is 4) 275 | phases_total=6 276 | export phases_total 277 | 278 | # If defined, it will run after the default phases to add additional 279 | # stages and their commands with descriptions separated by tabs 280 | hooks__phases=' 281 | 5 Extra Installation command-1 Command 1 description 282 | 5 Extra Installation command-2 Command 2 description 283 | 5 Extra Installation command-3 Command 3 description 284 | 6 Extra Configuration config-command-1 Config Command 1 description 285 | 6 Extra Configuration config-command-2 Config Command 2 description 286 | ' 287 | export hooks__phases 288 | ``` 289 |
290 | 291 | \* A fully working third-party script example using hooks can be found [here](https://gitlab.com/wikisuite/wikisuite-packages/-/raw/main/wikisuite-installer.bash). 292 | 293 | # How to contribute 294 | 295 | 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. 296 | 297 | 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. 298 | 299 | # See also 300 | 301 | 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. 302 | 303 | [Virtualmin-Config: a post-modern post-installation configuration tool](https://github.com/virtualmin/Virtualmin-Config) 304 | 305 | [virtualmin-yum-groups: Package groups for CentOS and Fedora](https://github.com/virtualmin/virtualmin-yum-groups) 306 | 307 | [virtualmin-lamp-stack-ubu: Metapackage for the LAMP stack on Ubuntu](https://github.com/virtualmin/virtualmin-lamp-stack-ubu) 308 | 309 | [virtualmin-core-deb: Metapackage for the Virtualmin core packages](https://github.com/virtualmin/virtualmin-core-deb) 310 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /virtualmin-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # shellcheck disable=SC2059 disable=SC2181 disable=SC2154 disable=SC2317 disable=SC2034 disable=SC2329 3 | # virtualmin-install.sh 4 | # Copyright 2005-2026 Virtualmin 5 | # Simple script to install Virtualmin on a supported OS 6 | 7 | # Different installation guides are available at: 8 | # https://www.virtualmin.com/docs/installation/guides 9 | 10 | # License and version 11 | SERIAL=GPL 12 | KEY=GPL 13 | VER=8.0.0 14 | vm_version=8 15 | 16 | # Server 17 | download_virtualmin_host="${download_virtualmin_host:-download.virtualmin.com}" 18 | download_virtualmin_host_lib="$download_virtualmin_host" 19 | download_virtualmin_host_dev="${download_virtualmin_host_dev:-software.virtualmin.dev}" 20 | download_virtualmin_host_rc="${download_virtualmin_host_rc:-rc.software.virtualmin.dev}" 21 | download_webmin_host="${download_webmin_host:-download.webmin.com}" 22 | download_webmin_host_dev="${download_webmin_host_dev:-download.webmin.dev}" 23 | download_webmin_host_rc="${download_webmin_host_rc:-rc.download.webmin.dev}" 24 | 25 | # Save current working directory 26 | pwd="$PWD" 27 | 28 | # License file 29 | virtualmin_license_file="/etc/virtualmin-license" 30 | 31 | # Script name 32 | if [ "$0" = "--" ] || [ -z "$0" ]; then 33 | script_name="virtualmin-install.sh" 34 | else 35 | script_name=$(basename -- "$0") 36 | fi 37 | 38 | # Set log type 39 | log_file_name="${install_log_file_name:-virtualmin-install}" 40 | 41 | # Set defaults 42 | branch='stable' 43 | bundle='LAMP' # Other option is LEMP 44 | mode="${mode:-full}" # Other option is mini 45 | skipyesno=0 46 | 47 | usage() { 48 | # shellcheck disable=SC2046 49 | echo 50 | printf "Usage: %s [options]\\n" "$(basename "$0")" 51 | echo 52 | echo " If called without arguments, installs Virtualmin with default options." 53 | echo 54 | printf " --bundle|-b bundle to install (default: LAMP)\\n" 55 | printf " --type|-t install type (default: full)\\n" 56 | echo 57 | printf " --branch|-B \\n" 58 | printf " install branch (default: stable)\\n" 59 | printf " --os-grade|-g operating system support grade (default: A)\\n" 60 | echo 61 | printf " --module|-o load custom module in post-install phase\\n" 62 | echo 63 | printf " --hostname|-n force hostname during install\\n" 64 | printf " --no-package-updates|-x skip package updates during install\\n" 65 | echo 66 | printf " --setup|-s reconfigure repos without installing\\n" 67 | printf " --connect|-C test connectivity without installing\\n" 68 | echo 69 | printf " --insecure-downloads|-i skip SSL certificate check for downloads\\n" 70 | echo 71 | printf " --uninstall|-u remove all packages and dependencies\\n" 72 | echo 73 | printf " --force|-f|--yes|-y assume \"yes\" to all prompts\\n" 74 | printf " --force-reinstall|-fr force complete reinstall (not recommended)\\n" 75 | printf " --no-banner|-nb suppress installation messages and warnings\\n" 76 | printf " --verbose|-v enable verbose mode\\n" 77 | printf " --version|-V show installer version\\n" 78 | printf " --help|-h show this help\\n" 79 | echo 80 | } 81 | 82 | # Bind hooks 83 | bind_hook() { 84 | hook="$1" 85 | shift 86 | pre_hook="pre_hook__$hook" 87 | post_hook="post_hook__$hook" 88 | # Do we want to completely override the original function? 89 | if command -v "hook__$hook" > /dev/null 2>&1; then 90 | "hook__$hook" "$@" 91 | # Or do we want to run the original function wrapped by third-party functions? 92 | else 93 | if command -v "$pre_hook" > /dev/null 2>&1; then 94 | "$pre_hook" "$@" 95 | fi 96 | if command -v "$hook" > /dev/null 2>&1; then 97 | "$hook" "$@" 98 | fi 99 | if command -v "$post_hook" > /dev/null 2>&1; then 100 | "$post_hook" "$@" 101 | fi 102 | fi 103 | } 104 | 105 | test_connection() { 106 | input="$1" 107 | ip_version="$2" 108 | ip_version_nice=$(echo "$ip_version" | sed 's/ip/IP/') 109 | timeout=5 110 | http_protocol="http" 111 | http_protocol_nice=$(echo "$http_protocol" | tr '[:lower:]' '[:upper:]') 112 | 113 | # Setup colors for messages 114 | GREEN="" BLACK="" RED="" RESET="" BOLD="" GRBG="" REDBG="" 115 | if command -pv 'tput' > /dev/null; then 116 | GREEN=$(tput setaf 2) 117 | BLACK=$(tput setaf 0) 118 | RED=$(tput setaf 1) 119 | RESET=$(tput sgr0) 120 | BOLD=$(tput bold) 121 | GRBG=$(tput setab 22; tput setaf 10) 122 | REDBG=$(tput setab 52; tput setaf 9) 123 | fi 124 | 125 | # Extract the domain from the input 126 | domain=$(echo "$input" | awk -F[/:] '{print $4}') 127 | [ -z "$domain" ] && domain="$input" 128 | 129 | # Validate parameters 130 | if [ -z "$domain" ] || [ -z "$ip_version" ]; then 131 | echo "${RED}[ERROR] ${RESET} Domain and IP version are required" >&2 132 | return 1 133 | fi 134 | 135 | # Setup protocol-specific flags 136 | case "$ip_version" in 137 | ipv4) 138 | if ! getent ahostsv4 "$domain" >/dev/null 2>&1; then 139 | echo "${RED}[ERROR] ${RESET} ${BOLD}$domain${RESET} — cannot find IPv4 address" >&2 140 | return 1 141 | fi 142 | ping_cmd="ping -c 1 -W $timeout $domain" 143 | http_cmd="curl -sS --ipv4 --max-time $timeout --head $http_protocol://$domain \ 144 | || wget --spider -4 -T $timeout $http_protocol://$domain" 145 | ;; 146 | ipv6) 147 | if ! getent ahostsv6 "$domain" >/dev/null 2>&1; then 148 | echo "${RED}[ERROR] ${RESET} ${BOLD}$domain${RESET} — cannot find IPv6 address" >&2 149 | return 1 150 | fi 151 | ping_cmd="ping6 -c 1 -W $timeout $domain" 152 | http_cmd="curl -sS --ipv6 --max-time $timeout --head $http_protocol://$domain \ 153 | || wget --spider -6 -T $timeout $http_protocol://$domain" 154 | ;; 155 | esac 156 | 157 | # Try ping first 158 | if eval "$ping_cmd" >/dev/null 2>&1; then 159 | echo "${GREEN}[SUCCESS]${RESET} ${GRBG}[$ip_version_nice]${RESET} ${GRBG}[ICMP]${RESET} ${BOLD}$domain${RESET}" 160 | else 161 | echo "${RED}[ERROR] ${RESET} ${REDBG}[$ip_version_nice]${RESET} ${REDBG}[ICMP]${RESET} ${BOLD}$domain${RESET}" 162 | fi 163 | 164 | # HTTP test as well 165 | if command -v 'curl' > /dev/null || command -v 'wget' > /dev/null; then 166 | if eval "$http_cmd" >/dev/null 2>&1; then 167 | echo "${GREEN}[SUCCESS]${RESET} ${GRBG}[$ip_version_nice]${RESET} ${GRBG}[$http_protocol_nice]${RESET} ${BOLD}$domain${RESET}" 168 | return 0 169 | else 170 | echo "${RED}[ERROR] ${RESET} ${REDBG}[$ip_version_nice]${RESET} ${REDBG}[$http_protocol_nice]${RESET} ${BOLD}$domain${RESET}" 171 | return 1 172 | fi 173 | fi 174 | } 175 | 176 | # Default function to parse arguments 177 | parse_args() { 178 | while [ "$1" != "" ]; do 179 | case $1 in 180 | --help | -h) 181 | bind_hook "usage" 182 | exit 0 183 | ;; 184 | --bundle | -b) 185 | shift 186 | case "$1" in 187 | LAMP) 188 | shift 189 | bundle='LAMP' 190 | ;; 191 | LEMP) 192 | shift 193 | bundle='LEMP' 194 | ;; 195 | *) 196 | printf "Unknown bundle: $1\\n" 197 | bind_hook "usage" 198 | exit 1 199 | ;; 200 | esac 201 | ;; 202 | --minimal | -m) 203 | shift 204 | mode='mini' 205 | ;; 206 | --type | -t) 207 | shift 208 | case "$1" in 209 | full) 210 | shift 211 | mode='full' 212 | ;; 213 | mini) 214 | shift 215 | mode='mini' 216 | ;; 217 | *) 218 | printf "Unknown type: $1\\n" 219 | bind_hook "usage" 220 | exit 1 221 | ;; 222 | esac 223 | ;; 224 | --branch | -B) 225 | shift 226 | case "$1" in 227 | unstable|testing|development|devel|dev|nightly|bleeding-edge|cutting-edge) 228 | shift 229 | branch='unstable' 230 | ;; 231 | prerelease|pre-release|rc|release-candidate) 232 | shift 233 | branch='prerelease' 234 | ;; 235 | stable|production|release) 236 | shift 237 | branch='stable' 238 | ;; 239 | *) 240 | printf "Unknown branch: $1\\n" 241 | bind_hook "usage" 242 | exit 1 243 | ;; 244 | esac 245 | ;; 246 | --insecure-downloads | -i) 247 | shift 248 | insecure_download_wget_flag=' --no-check-certificate' 249 | insecure_download_curl_flag=' -k' 250 | ;; 251 | --no-package-updates | -x) 252 | shift 253 | noupdates=1 254 | ;; 255 | --setup | -s) 256 | shift 257 | setup_only=1 258 | mode='setup' 259 | unstable='unstable' 260 | log_file_name="${setup_log_file_name:-virtualmin-repos-setup}" 261 | ;; 262 | --connect | -C) 263 | shift 264 | if [ -z "$1" ] || [ "${1#-}" != "$1" ]; then 265 | test_connection_type="ipv4 ipv6" 266 | else 267 | if [ "$1" != "ipv4" ] && [ "$1" != "ipv6" ]; then 268 | printf "Invalid protocol: $1\\n" 269 | bind_hook "usage" 270 | exit 1 271 | fi 272 | test_connection_type="$1" 273 | shift 274 | fi 275 | ;; 276 | --os-grade | -g) 277 | shift 278 | case "$1" in 279 | A|a) 280 | shift 281 | ;; 282 | B|b) 283 | shift 284 | unstable='unstable' 285 | virtualmin_config_system_excludes="" 286 | virtualmin_stack_custom_packages="" 287 | ;; 288 | *) 289 | printf "Unknown OS grade: $1\\n" 290 | bind_hook "usage" 291 | exit 1 292 | ;; 293 | esac 294 | ;; 295 | --unstable | -e) 296 | shift 297 | unstable='unstable' 298 | virtualmin_config_system_excludes="" 299 | virtualmin_stack_custom_packages="" 300 | ;; 301 | --module | -o) 302 | shift 303 | module_name=$1 304 | shift 305 | ;; 306 | --hostname | -n) 307 | shift 308 | forcehostname=$1 309 | shift 310 | ;; 311 | --force | -f | --yes | -y) 312 | shift 313 | skipyesno=1 314 | ;; 315 | --force-reinstall | -fr) 316 | shift 317 | forcereinstall=1 318 | ;; 319 | --no-banner | -nb) 320 | shift 321 | skipbanner=1 322 | ;; 323 | --verbose | -v) 324 | shift 325 | VERBOSE=1 326 | ;; 327 | --version | -V) 328 | shift 329 | showversion=1 330 | ;; 331 | --uninstall | -u) 332 | shift 333 | mode="uninstall" 334 | log_file_name="${uninstall_log_file_name:-virtualmin-uninstall}" 335 | ;; 336 | *) 337 | printf "Unrecognized option: $1\\n" 338 | bind_hook "usage" 339 | exit 1 340 | ;; 341 | esac 342 | done 343 | } 344 | 345 | # Hook arguments 346 | bind_hook "parse_args" "$@" 347 | 348 | # Default function to show installer version 349 | show_version() { 350 | echo "$VER" 351 | exit 0 352 | } 353 | 354 | # Hook version 355 | if [ -n "$showversion" ]; then 356 | bind_hook "show_version" 357 | fi 358 | 359 | # Update variables based on branch 360 | if [ "$branch" = 'unstable' ]; then 361 | download_virtualmin_host_lib="$download_virtualmin_host_dev" 362 | elif [ "$branch" = 'prerelease' ]; then 363 | download_virtualmin_host_lib="$download_virtualmin_host_rc" 364 | fi 365 | 366 | # If connectivity test is requested 367 | if [ -n "$test_connection_type" ]; then 368 | for test_type in $test_connection_type; do 369 | if [ "$branch" = "unstable" ]; then 370 | test_connection "$download_webmin_host_dev" "$test_type" 371 | test_connection "$download_virtualmin_host_dev" "$test_type" 372 | elif [ "$branch" = "prerelease" ]; then 373 | test_connection "$download_webmin_host_rc" "$test_type" 374 | test_connection "$download_virtualmin_host_rc" "$test_type" 375 | else 376 | test_connection "$download_webmin_host" "$test_type" 377 | test_connection "$download_virtualmin_host" "$test_type" 378 | fi 379 | done 380 | exit 0 381 | fi 382 | 383 | # Force setup mode, if script name is `setup-repos.sh` as it 384 | # is used by Virtualmin API, to make sure users won't run an 385 | # actual install script under any circumstances 386 | if [ "$script_name" = "setup-repos.sh" ]; then 387 | setup_only=1 388 | mode='setup' 389 | unstable='unstable' 390 | fi 391 | 392 | # Store new log each time 393 | logpath=${log_dir_path:-"$pwd"} 394 | log="$logpath/$log_file_name.log" 395 | if [ -e "$log" ]; then 396 | while true; do 397 | logcnt=$((logcnt+1)) 398 | logold="$log.$logcnt" 399 | if [ ! -e "$logold" ]; then 400 | mv "$log" "$logold" 401 | break 402 | fi 403 | done 404 | fi 405 | 406 | # If Pro user downloads GPL version of `install.sh` script 407 | # to fix repos check if there is an active license exists 408 | if [ -n "$setup_only" ]; then 409 | if [ "$SERIAL" = "GPL" ] && [ "$KEY" = "GPL" ] && [ -f "$virtualmin_license_file" ]; then 410 | virtualmin_license_existing_serial="$(grep 'SerialNumber=' "$virtualmin_license_file" | sed 's/SerialNumber=//')" 411 | virtualmin_license_existing_key="$(grep 'LicenseKey=' "$virtualmin_license_file" | sed 's/LicenseKey=//')" 412 | if [ -n "$virtualmin_license_existing_serial" ] && [ -n "$virtualmin_license_existing_key" ]; then 413 | SERIAL="$virtualmin_license_existing_serial" 414 | KEY="$virtualmin_license_existing_key" 415 | fi 416 | fi 417 | fi 418 | 419 | arch="$(uname -m)" 420 | if [ "$arch" = "i686" ]; then 421 | arch="i386" 422 | fi 423 | if [ "$SERIAL" = "GPL" ]; then 424 | PRODUCT="GPL" 425 | else 426 | PRODUCT="Professional" 427 | fi 428 | 429 | # Virtualmin-provided packages 430 | vmgroup="'Virtualmin Core'" 431 | vmgroupid="virtualmincore" 432 | vmgrouptext="Virtualmin $vm_version provided packages" 433 | debvmpackages="virtualmin-core" 434 | deps= 435 | 436 | if [ "$mode" = 'full' ]; then 437 | if [ "$bundle" = 'LAMP' ]; then 438 | rhgroup="'Virtualmin LAMP Stack'" 439 | rhgroupid="virtualmin-lamp" 440 | rhgrouptext="Virtualmin $vm_version LAMP stack" 441 | debdeps="virtualmin-lamp-stack" 442 | ubudeps="virtualmin-lamp-stack" 443 | elif [ "$bundle" = 'LEMP' ]; then 444 | rhgroup="'Virtualmin LEMP Stack'" 445 | rhgroupid="virtualmin-lemp" 446 | rhgrouptext="Virtualmin $vm_version LEMP stack" 447 | debdeps="virtualmin-lemp-stack" 448 | ubudeps="virtualmin-lemp-stack" 449 | fi 450 | elif [ "$mode" = 'mini' ]; then 451 | if [ "$bundle" = 'LAMP' ]; then 452 | rhgroup="'Virtualmin LAMP Stack Minimal'" 453 | rhgroupid="virtualmin-lamp-minimal" 454 | rhgrouptext="Virtualmin $vm_version LAMP stack mini" 455 | debdeps="virtualmin-lamp-stack-minimal" 456 | ubudeps="virtualmin-lamp-stack-minimal" 457 | elif [ "$bundle" = 'LEMP' ]; then 458 | rhgroup="'Virtualmin LEMP Stack Minimal'" 459 | rhgroupid="virtualmin-lemp-minimal" 460 | rhgrouptext="Virtualmin $vm_version LEMP stack mini'" 461 | debdeps="virtualmin-lemp-stack-minimal" 462 | ubudeps="virtualmin-lemp-stack-minimal" 463 | fi 464 | fi 465 | 466 | # Find temp directory 467 | if [ -z "$TMPDIR" ]; then 468 | TMPDIR=/tmp 469 | fi 470 | 471 | # Check whether $TMPDIR is mounted noexec (everything will fail, if so) 472 | # XXX: This check is imperfect. If $TMPDIR is a full path, but the parent dir 473 | # is mounted noexec, this won't catch it. 474 | TMPNOEXEC="$(grep "$TMPDIR" /etc/mtab | grep noexec)" 475 | if [ -n "$TMPNOEXEC" ]; then 476 | echo "Error: $TMPDIR directory is mounted noexec. Cannot continue." 477 | exit 1 478 | fi 479 | 480 | if [ -z "$VIRTUALMIN_INSTALL_TEMPDIR" ]; then 481 | VIRTUALMIN_INSTALL_TEMPDIR="$TMPDIR/.virtualmin-$$" 482 | if [ -e "$VIRTUALMIN_INSTALL_TEMPDIR" ]; then 483 | rm -rf "$VIRTUALMIN_INSTALL_TEMPDIR" 484 | fi 485 | mkdir "$VIRTUALMIN_INSTALL_TEMPDIR" 486 | fi 487 | 488 | # Export temp directory for Virtualmin Config 489 | export VIRTUALMIN_INSTALL_TEMPDIR 490 | 491 | # "files" subdir for libs 492 | mkdir "$VIRTUALMIN_INSTALL_TEMPDIR/files" 493 | srcdir="$VIRTUALMIN_INSTALL_TEMPDIR/files" 494 | 495 | # Switch to temp directory or exit with error 496 | goto_tmpdir() { 497 | if ! cd "$srcdir" >>"$log" 2>&1; then 498 | echo "Error: Failed to enter $srcdir temporary directory" 499 | exit 1 500 | fi 501 | } 502 | goto_tmpdir 503 | 504 | pre_check_http_client() { 505 | # Check for wget or curl or fetch 506 | printf "Checking for HTTP client .." >>"$log" 507 | while true; do 508 | if [ -x "/usr/bin/wget" ]; then 509 | download="/usr/bin/wget -nv$insecure_download_wget_flag" 510 | break 511 | elif [ -x "/usr/bin/curl" ]; then 512 | download="/usr/bin/curl -f$insecure_download_curl_flag -s -L -O" 513 | break 514 | elif [ -x "/usr/bin/fetch" ]; then 515 | download="/usr/bin/fetch" 516 | break 517 | elif [ "$wget_attempted" = 1 ]; then 518 | printf " error: No HTTP client available. The installation of a download command has failed. Cannot continue.\\n" >>"$log" 519 | return 1 520 | fi 521 | 522 | # Made it here without finding a downloader, so try to install one 523 | wget_attempted=1 524 | if [ -x /usr/bin/dnf ]; then 525 | dnf -y install wget >>"$log" 526 | elif [ -x /usr/bin/yum ]; then 527 | yum -y install wget >>"$log" 528 | elif [ -x /usr/bin/apt-get ]; then 529 | apt-get update >>/dev/null 530 | apt-get -y -q install wget >>"$log" 531 | fi 532 | done 533 | if [ -z "$download" ]; then 534 | printf " not found\\n" >>"$log" 535 | return 1 536 | else 537 | printf " found %s\\n" "$download" >>"$log" 538 | return 0; 539 | fi 540 | } 541 | 542 | download_slib() { 543 | # If slib.sh is available locally in the same directory use it 544 | if [ -f "$pwd/slib.sh" ]; then 545 | chmod +x "$pwd/slib.sh" 546 | # shellcheck disable=SC1091 547 | . "$pwd/slib.sh" 548 | # Download the slib (source: http://github.com/virtualmin/slib) 549 | else 550 | # We need HTTP client first 551 | pre_check_http_client 552 | $download "https://$download_virtualmin_host_lib/slib.sh" >>"$log" 2>&1 553 | if [ $? -ne 0 ]; then 554 | 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." 555 | exit 1 556 | fi 557 | chmod +x slib.sh 558 | # shellcheck disable=SC1091 559 | . ./slib.sh 560 | fi 561 | } 562 | 563 | # Check if already installed successfully 564 | already_installed_block() { 565 | log_error "Your system already has a successful Virtualmin installation deployed." 566 | log_error "Re-installation is neither possible nor necessary. This script must be" 567 | log_error "run on a freshly installed supported operating system. It is not meant" 568 | log_error "for package updates or license changes. For further assistance, please" 569 | log_error "visit the Virtualmin Community forum." 570 | exit 100 571 | } 572 | 573 | # Utility function library 574 | ########################################## 575 | download_slib # for production this block 576 | # can be replaces with the 577 | # content of slib.sh file, 578 | # minus its header 579 | ########################################## 580 | 581 | # Get OS type 582 | get_distro 583 | 584 | # Check the serial number and key 585 | serial_ok "$SERIAL" "$KEY" 586 | # Setup slog 587 | LOG_PATH="$log" 588 | # Setup run_ok 589 | RUN_LOG="$log" 590 | # Exit on any failure during shell stage 591 | RUN_ERRORS_FATAL=1 592 | 593 | # Console output level; ignore debug level messages. 594 | if [ "$VERBOSE" = "1" ]; then 595 | LOG_LEVEL_STDOUT="DEBUG" 596 | else 597 | LOG_LEVEL_STDOUT="INFO" 598 | fi 599 | # Log file output level; catch literally everything. 600 | LOG_LEVEL_LOG="DEBUG" 601 | 602 | # If already installed successfully, do not allow running again 603 | if [ -f "/etc/webmin/virtual-server/installed-auto" ] && 604 | [ -z "$setup_only" ] && [ -z "$forcereinstall" ] && 605 | [ "$mode" != "uninstall" ]; then 606 | bind_hook "already_installed_block" 607 | fi 608 | if [ -n "$setup_only" ]; then 609 | log_info "Setup log is written to $LOG_PATH" 610 | elif [ "$mode" = "uninstall" ]; then 611 | log_info "Uninstallation log is written to $LOG_PATH" 612 | else 613 | log_info "Installation log is written to $LOG_PATH" 614 | fi 615 | log_debug "LOG_ERRORS_FATAL=$RUN_ERRORS_FATAL" 616 | log_debug "LOG_LEVEL_STDOUT=$LOG_LEVEL_STDOUT" 617 | log_debug "LOG_LEVEL_LOG=$LOG_LEVEL_LOG" 618 | 619 | # log_fatal calls log_error 620 | log_fatal() { 621 | log_error "$1" 622 | } 623 | 624 | # Write chosen branch to file for future reference 625 | write_virtualmin_branch() { 626 | branch_dir=/etc/webmin/virtual-server 627 | branch_file="$branch_dir/branch" 628 | 629 | # If directory doesn't exist, do nothing 630 | [ -d "$branch_dir" ] || return 0 631 | 632 | # Write current $branch value 633 | printf '%s\n' "$branch" >"$branch_file" 2>/dev/null || : 634 | # Write major version 635 | printf '%s\n' "$vm_version" >>"$branch_file" 2>/dev/null || : 636 | } 637 | 638 | # Configure Virtualmin repositories (stable, prerelease, or unstable) and keep 639 | # matching Webmin repositories in sync. 640 | manage_virtualmin_branch_repos() { 641 | del_cmd="" found_type="" reinstalling=0 642 | found_both=0 found_unstable=0 found_prerelease=0 643 | 644 | # Set paths based on package type 645 | case "$package_type" in 646 | deb) 647 | repo_dir="/etc/apt/sources.list.d" 648 | auth_dir="/etc/apt/auth.conf.d" 649 | repo_ext="list" 650 | ;; 651 | rpm) 652 | repo_dir="/etc/yum.repos.d" 653 | repo_ext="repo" 654 | ;; 655 | *) 656 | return 1 657 | ;; 658 | esac 659 | 660 | # Remove existing unstable, prerelease or stable repos if found 661 | for repo in virtualmin-unstable virtualmin-prerelease virtualmin-stable virtualmin \ 662 | webmin-unstable webmin-prerelease webmin-stable webmin; do 663 | repo_file="${repo_dir}/${repo}.${repo_ext}" 664 | if [ -f "$repo_file" ]; then 665 | del_cmd="${del_cmd:+$del_cmd && }rm -f $repo_file" 666 | case "$repo" in 667 | *unstable*) 668 | found_unstable=1 669 | found_type="unstable" 670 | ;; 671 | *prerelease*) 672 | found_prerelease=1 673 | found_type="prerelease" 674 | ;; 675 | *) 676 | found_stable=1 677 | found_type="stable" 678 | ;; 679 | esac 680 | fi 681 | 682 | # Auth file check for deb 683 | if [ "$package_type" = "deb" ]; then 684 | case "$repo" in 685 | virtualmin*) 686 | auth_file="${auth_dir}/${repo}.conf" 687 | [ -f "$auth_file" ] && del_cmd="${del_cmd:+$del_cmd && }rm -f $auth_file" 688 | ;; 689 | esac 690 | fi 691 | done 692 | 693 | # Execute removal if exists 694 | if [ -n "$del_cmd" ]; then 695 | if [ "$found_unstable" -eq 1 ] && [ "$found_prerelease" -eq 1 ]; then 696 | msg="Uninstalling Virtualmin $vm_version unstable and prerelease repositories" 697 | found_both=1 698 | elif [ "$found_unstable" -eq 1 ]; then 699 | msg="Uninstalling Virtualmin $vm_version unstable repository" 700 | elif [ "$found_prerelease" -eq 1 ]; then 701 | msg="Uninstalling Virtualmin $vm_version prerelease repository" 702 | elif [ "$found_stable" -eq 1 ]; then 703 | msg="Uninstalling Virtualmin $vm_version stable repository" 704 | fi 705 | 706 | # If removing only, update metadata 707 | if [ -z "$branch" ]; then 708 | del_cmd="$del_cmd && $update" 709 | fi 710 | 711 | # Remove any existing repo configs and keys first 712 | remove_virtualmin_release 713 | 714 | # Remove silently if reinstalling 715 | if [ -n "$branch" ] && [ "$found_both" -eq 0 ] && [ "$found_type" = "$branch" ]; then 716 | eval "$del_cmd" 717 | reinstalling=1 718 | else 719 | run_ok "$del_cmd" "$msg" 720 | fi 721 | fi 722 | 723 | # Save branch name 724 | write_virtualmin_branch 725 | 726 | # Configure repo based on requested branch 727 | if [ "$reinstalling" -eq 1 ]; then 728 | install_pre_msg="Reinstalling Virtualmin $vm_version" 729 | else 730 | install_pre_msg="Installing Virtualmin $vm_version" 731 | fi 732 | case "$branch" in 733 | unstable) 734 | down_cmd="$download https://$download_virtualmin_host_dev/install" 735 | cmd="$down_cmd && sh install webmin unstable && \ 736 | sh install virtualmin unstable" 737 | msg="$install_pre_msg unstable repository" 738 | ;; 739 | prerelease) 740 | down_cmd="$download https://$download_virtualmin_host_rc/install" 741 | cmd="$down_cmd && sh install webmin prerelease && \ 742 | sh install virtualmin prerelease" 743 | msg="$install_pre_msg prerelease repository" 744 | ;; 745 | stable) 746 | down_cmd="$download https://$download_virtualmin_host/install" 747 | cmd="$down_cmd && sh install virtualmin stable" 748 | msg="$install_pre_msg stable repository" 749 | ;; 750 | *) 751 | return 1 752 | ;; 753 | esac 754 | run_ok "$cmd" "$msg" 755 | } 756 | 757 | # Test if grade B system 758 | grade_b_system() { 759 | case "$os_type" in 760 | rhel | centos | rocky | almalinux | debian) 761 | return 1 762 | ;; 763 | ubuntu) 764 | case "$os_version" in 765 | *\.10|*[13579].04) # non-LTS versions are unstable 766 | return 0 767 | ;; 768 | *) 769 | return 1 770 | ;; 771 | esac 772 | ;; 773 | *) 774 | return 0 775 | ;; 776 | esac 777 | } 778 | 779 | if grade_b_system && [ "$unstable" != 'unstable' ]; then 780 | log_error "Unsupported operating system detected. You may be able to install with" 781 | log_error "${BOLD}--unstable${NORMAL} flag, but this is not recommended. Consult the installation" 782 | log_error "documentation." 783 | exit 1 784 | fi 785 | 786 | remove_virtualmin_release() { 787 | # Directories where Virtualmin and Webmin config or keys may live 788 | for d in \ 789 | /etc/apt/sources.list.d \ 790 | /etc/apt/auth.conf.d \ 791 | /usr/share/keyrings \ 792 | /etc/apt/keyrings \ 793 | /etc/pki/rpm-gpg \ 794 | /etc/yum.repos.d 795 | do 796 | [ -d "$d" ] || continue 797 | 798 | case "$d" in 799 | /etc/yum.repos.d) 800 | # Repo files 801 | patterns="virtualmin* webmin*" 802 | ;; 803 | /etc/pki/rpm-gpg) 804 | # RPM GPG keys and/or any style keys 805 | patterns="RPM-GPG-KEY-virtualmin* RPM-GPG-KEY-webmin* *-virtualmin* *-webmin*" 806 | ;; 807 | *) 808 | # APT dirs / keyring dirs, etc. 809 | patterns="virtualmin* webmin* *-virtualmin* *-webmin*" 810 | ;; 811 | esac 812 | 813 | for p in $patterns; do 814 | # shellcheck disable=SC2086 815 | rm -f "$d"/$p 2>/dev/null || : 816 | done 817 | done 818 | 819 | # Clean APT main sources file if it exists 820 | if [ -f /etc/apt/sources.list ]; then 821 | tmp="${VIRTUALMIN_INSTALL_TEMPDIR:-/tmp}/sources.list.$$" 822 | grep -vi "virtualmin\|webmin" /etc/apt/sources.list >"$tmp" || : 823 | mv "$tmp" /etc/apt/sources.list 824 | fi 825 | } 826 | 827 | fatal() { 828 | echo 829 | log_fatal "Fatal Error Occurred: $1" 830 | printf "${RED}Cannot continue installation.${NORMAL}\\n" 831 | remove_virtualmin_release 832 | if [ -x "$VIRTUALMIN_INSTALL_TEMPDIR" ]; then 833 | log_warning "Removing temporary directory and files." 834 | rm -rf "$VIRTUALMIN_INSTALL_TEMPDIR" 835 | fi 836 | log_fatal "If you are unsure of what went wrong, you may wish to review the log" 837 | log_fatal "in $log" 838 | exit 1 839 | } 840 | 841 | success() { 842 | log_success "$1 Succeeded." 843 | } 844 | 845 | # Function to find out if some services were pre-installed 846 | is_preconfigured() { 847 | preconfigured="" 848 | if named -v 1>/dev/null 2>&1; then 849 | preconfigured="${preconfigured}${YELLOW}${BOLD}BIND${NORMAL} " 850 | fi 851 | if apachectl -v 1>/dev/null 2>&1; then 852 | preconfigured="${preconfigured}${YELLOW}${BOLD}Apache${NORMAL} " 853 | fi 854 | if nginx -v 1>/dev/null 2>&1; then 855 | preconfigured="${preconfigured}${YELLOW}${BOLD}Nginx${NORMAL} " 856 | fi 857 | if command -pv mariadb 1>/dev/null 2>&1; then 858 | preconfigured="${preconfigured}${YELLOW}${BOLD}MariaDB${NORMAL} " 859 | fi 860 | if postconf mail_version 1>/dev/null 2>&1; then 861 | preconfigured="${preconfigured}${YELLOW}${BOLD}Postfix${NORMAL} " 862 | fi 863 | if php -v 1>/dev/null 2>&1; then 864 | preconfigured="${preconfigured}${YELLOW}${BOLD}PHP${NORMAL} " 865 | fi 866 | preconfigured=$(echo "$preconfigured" | sed 's/ /, /g' | sed 's/, $/ /') 867 | echo "$preconfigured" 868 | } 869 | 870 | # Function to find out if Virtualmin is already installed, so we can get 871 | # rid of some of the warning message. Nobody reads it, and frequently 872 | # folks run the install script on a production system; either to attempt 873 | # to upgrade, or to "fix" something. That's never the right thing. 874 | is_installed() { 875 | if [ -f "$virtualmin_license_file" ]; then 876 | # looks like it's been installed before 877 | return 0 878 | fi 879 | # XXX Probably not installed? Maybe we should remove license on uninstall, too. 880 | return 1 881 | } 882 | 883 | # This function performs a rough uninstallation of Virtualmin 884 | # all related packages and configurations 885 | uninstall() { 886 | log_debug "Initiating Virtualmin uninstallation procedure" 887 | log_debug "Operating system name: $os_real" 888 | log_debug "Operating system version: $os_version" 889 | log_debug "Operating system type: $os_type" 890 | log_debug "Operating system major: $os_major_version" 891 | 892 | if [ "$skipyesno" -ne 1 ]; then 893 | echo 894 | printf " ${REDBG}${BLACK}${BOLD} WARNING ${NORMAL}\\n" 895 | echo 896 | echo " This operation is highly disruptive and cannot be undone. It removes all of" 897 | echo " the packages and configuration files installed by the Virtualmin installer!" 898 | echo 899 | echo " It must never be executed on a live production system!" 900 | echo 901 | printf " ${RED}Uninstall?${NORMAL} (y/N) " 902 | if ! yesno; then 903 | exit 904 | fi 905 | fi 906 | 907 | # Always sleep just a bit in case the user changes their mind 908 | sleep 3 909 | 910 | # Go to the temp directory 911 | goto_tmpdir 912 | 913 | # Uninstall packages 914 | uninstall_packages() 915 | { 916 | # Detect the package manager 917 | case "$os_type" in 918 | rhel | fedora | centos | centos_stream | rocky | almalinux | openEuler | ol | cloudlinux | amzn ) 919 | package_type=rpm 920 | if command -pv dnf 1>/dev/null 2>&1; then 921 | uninstall_cmd="dnf remove -y" 922 | uninstall_cmd_group="dnf groupremove -y" 923 | update="dnf clean all ; dnf makecache" 924 | else 925 | uninstall_cmd="yum remove -y" 926 | uninstall_cmd_group="yum groupremove -y" 927 | update="yum clean all ; yum makecache" 928 | fi 929 | ;; 930 | debian | ubuntu | kali) 931 | package_type=deb 932 | uninstall_cmd="apt-get remove --assume-yes --purge" 933 | update="apt-get clean ; apt-get update" 934 | ;; 935 | esac 936 | 937 | case "$package_type" in 938 | rpm) 939 | $uninstall_cmd_group "Virtualmin Core" "Virtualmin LAMP Stack" "Virtualmin LEMP Stack" "Virtualmin LAMP Stack Minimal" "Virtualmin LEMP Stack Minimal" 940 | $uninstall_cmd wbm-* wbt-* webmin* usermin* virtualmin* 941 | os_type="rhel" 942 | return 0 943 | ;; 944 | deb) 945 | $uninstall_cmd "virtualmin*" "webmin*" "usermin*" 946 | uninstall_cmd_auto="apt-get autoremove --assume-yes" 947 | $uninstall_cmd_auto 948 | os_type="debian" 949 | return 0 950 | ;; 951 | *) 952 | log_error "Unknown package manager, cannot uninstall" 953 | return 1 954 | ;; 955 | esac 956 | } 957 | 958 | # Uninstall repos and helper command 959 | uninstall_repos() 960 | { 961 | if [ -f "$virtualmin_license_file" ]; then 962 | log_debug "Removing Virtualmin license" 963 | rm -f "$virtualmin_license_file" 2>/dev/null || : 964 | fi 965 | 966 | log_debug "Removing Virtualmin helper command" 967 | rm -f "/usr/sbin/virtualmin" 2>/dev/null || : 968 | 969 | remove_virtualmin_release 970 | 971 | log_debug "Virtualmin uninstallation complete" 972 | } 973 | 974 | phase_number=${phase_number:-1} 975 | phases_total=${phases_total:-1} 976 | uninstall_phase_description=${uninstall_phase_description:-"Uninstall"} 977 | echo 978 | phase "$uninstall_phase_description" "$phase_number" 979 | run_ok "uninstall_packages" "Uninstalling Virtualmin $vm_version and all stack packages" 980 | run_ok "uninstall_repos" "Uninstalling Virtualmin $vm_version configuration and license" 981 | manage_virtualmin_branch_repos 982 | } 983 | 984 | # Phase control 985 | phase() { 986 | phases_total="${phases_total:-4}" 987 | phase_description="$1" 988 | phase_number="$2" 989 | # Print completed phases (green) 990 | printf "${GREEN}" 991 | for i in $(seq 1 $(( phase_number - 1 ))); do 992 | printf "▣" 993 | done 994 | # Print current phase (yellow) 995 | printf "${YELLOW}▣" 996 | # Print remaining phases (cyan) 997 | for i in $(seq $(( phase_number + 1 )) "$phases_total"); do 998 | printf "${CYAN}◻" 999 | done 1000 | log_debug "Phase ${phase_number} of ${phases_total}: ${phase_description}" 1001 | printf "${NORMAL} Phase ${YELLOW}${phase_number}${NORMAL} of ${GREEN}${phases_total}${NORMAL}: ${phase_description}\\n" 1002 | } 1003 | 1004 | if [ "$mode" = "uninstall" ]; then 1005 | bind_hook "uninstall" 1006 | exit 0 1007 | fi 1008 | 1009 | # Calculate disk space requirements (this is a guess, for now) 1010 | if [ "$mode" != 'full' ]; then 1011 | disk_space_required=1 1012 | else 1013 | disk_space_required=2 1014 | fi 1015 | 1016 | # Message to display in interactive mode 1017 | install_msg() { 1018 | supported=" ${CYANBG}${BLACK}${BOLD}Red Hat Enterprise Linux and derivatives${NORMAL}${CYAN} 1019 | - Alma and Rocky 8, 9 and 10 on x86_64 and aarch64 1020 | - RHEL 8, 9 and 10 on x86_64 and aarch64 1021 | UNSTABLERHEL${NORMAL} 1022 | ${CYANBG}${BLACK}${BOLD}Debian Linux and derivatives${NORMAL}${CYAN} 1023 | - Debian 11, 12 and 13 on i386, amd64 and arm64 1024 | - Ubuntu 20.04, 22.04 and 24.04 on i386, amd64 and arm64${NORMAL} 1025 | UNSTABLEDEB${NORMAL}" 1026 | 1027 | cat </dev/null || echo 0) 1037 | # Check if screen height can fit the message entirely 1038 | if { [ "$screen_height" -gt 0 ] && 1039 | [ "$screen_height" -lt 33 ]; } || 1040 | [ "$screen_height" -eq 0 ]; then 1041 | printf " Continue? (y/n) " 1042 | if ! yesno; then 1043 | exit 1044 | fi 1045 | echo 1046 | fi 1047 | cat </dev/null 1273 | if [ "$?" != 0 ]; then 1274 | log_warning "There is no localhost entry in /etc/hosts. This is required, so one will be added." 1275 | run_ok "echo 127.0.0.1 localhost >> /etc/hosts" "Editing /etc/hosts" 1276 | if [ "$?" -ne 0 ]; then 1277 | log_error "Failed to configure a localhost entry in /etc/hosts." 1278 | log_error "This may cause problems, but we'll try to continue." 1279 | fi 1280 | fi 1281 | fi 1282 | 1283 | pre_check_system_time() { 1284 | # Check if current time 1285 | # is not older than 1286 | # Wed Dec 01 2022 1287 | printf "Syncing system time ..\\n" >>"$log" 1288 | TIMEBASE=1669888800 1289 | TIME=$(date +%s) 1290 | if [ "$TIME" -lt "$TIMEBASE" ]; then 1291 | 1292 | # Try to sync time automatically first 1293 | if systemctl restart chronyd 1>/dev/null 2>&1; then 1294 | sleep 30 1295 | elif systemctl restart systemd-timesyncd 1>/dev/null 2>&1; then 1296 | sleep 30 1297 | fi 1298 | 1299 | # Check again after all 1300 | TIME=$(date +%s) 1301 | if [ "$TIME" -lt "$TIMEBASE" ]; then 1302 | printf ".. failed to automatically sync system time; it should be corrected manually to continue\\n" >>"$log" 1303 | return 1; 1304 | fi 1305 | # Graceful sync 1306 | else 1307 | if systemctl restart chronyd 1>/dev/null 2>&1; then 1308 | sleep 10 1309 | elif systemctl restart systemd-timesyncd 1>/dev/null 2>&1; then 1310 | sleep 10 1311 | fi 1312 | fi 1313 | printf ".. done\\n" >>"$log" 1314 | return 0 1315 | } 1316 | 1317 | pre_check_ca_certificates() { 1318 | printf "Checking for an update for a set of CA certificates ..\\n" >>"$log" 1319 | if [ -x /usr/bin/dnf ]; then 1320 | dnf -y update ca-certificates >>"$log" 2>&1 1321 | elif [ -x /usr/bin/yum ]; then 1322 | yum -y update ca-certificates >>"$log" 2>&1 1323 | elif [ -x /usr/bin/apt-get ]; then 1324 | apt-get -y install ca-certificates >>"$log" 2>&1 1325 | fi 1326 | res=$? 1327 | printf ".. done\\n" >>"$log" 1328 | return "$res" 1329 | } 1330 | 1331 | pre_check_perl() { 1332 | printf "Checking for Perl .." >>"$log" 1333 | # loop until we've got a Perl or until we can't try any more 1334 | while true; do 1335 | perl="$(command -pv perl 2>/dev/null)" 1336 | if [ -z "$perl" ]; then 1337 | if [ -x /usr/bin/perl ]; then 1338 | perl=/usr/bin/perl 1339 | break 1340 | elif [ -x /usr/local/bin/perl ]; then 1341 | perl=/usr/local/bin/perl 1342 | break 1343 | elif [ -x /opt/csw/bin/perl ]; then 1344 | perl=/opt/csw/bin/perl 1345 | break 1346 | elif [ "$perl_attempted" = 1 ]; then 1347 | printf ".. Perl could not be installed. Cannot continue\\n" >>"$log" 1348 | return 1 1349 | fi 1350 | # couldn't find Perl, so we need to try to install it 1351 | if [ -x /usr/bin/dnf ]; then 1352 | dnf -y install perl >>"$log" 2>&1 1353 | elif [ -x /usr/bin/yum ]; then 1354 | yum -y install perl >>"$log" 2>&1 1355 | elif [ -x /usr/bin/apt-get ]; then 1356 | apt-get update >>"$log" 2>&1 1357 | apt-get -q -y install perl >>"$log" 2>&1 1358 | fi 1359 | perl_attempted=1 1360 | # Loop. Next loop should either break or exit. 1361 | else 1362 | break 1363 | fi 1364 | done 1365 | printf ".. found Perl at $perl\\n" >>"$log" 1366 | return 0 1367 | } 1368 | 1369 | pre_check_gpg() { 1370 | if [ -x /usr/bin/apt-get ]; then 1371 | printf "Checking for GPG .." >>"$log" 1372 | if [ ! -x /usr/bin/gpg ]; then 1373 | printf " not found, attempting to install .." >>"$log" 1374 | apt-get update >>/dev/null 1375 | apt-get -y -q install gnupg >>"$log" 1376 | printf " finished : $?\\n" >>"$log" 1377 | else 1378 | printf " found GPG command\\n" >>"$log" 1379 | fi 1380 | fi 1381 | } 1382 | 1383 | pre_check_all() { 1384 | 1385 | if [ -z "$setup_only" ]; then 1386 | # Check system time 1387 | run_ok pre_check_system_time "Checking system time" 1388 | 1389 | # Make sure Perl is installed 1390 | run_ok pre_check_perl "Checking Perl installation" 1391 | 1392 | # Update CA certificates package 1393 | run_ok pre_check_ca_certificates "Checking CA certificates package" 1394 | else 1395 | # Make sure Perl is installed 1396 | run_ok pre_check_perl "Checking Perl installation" 1397 | fi 1398 | 1399 | # Checking for HTTP client 1400 | run_ok pre_check_http_client "Checking HTTP client" 1401 | 1402 | # Check for gpg, debian 10 doesn't install by default!? 1403 | run_ok pre_check_gpg "Checking GPG package" 1404 | } 1405 | 1406 | # download() 1407 | # Use $download to download the provided filename or exit with an error. 1408 | download() { 1409 | # XXX Check this to make sure run_ok is doing the right thing. 1410 | # Especially make sure failure gets logged right. 1411 | # awk magic prints the filename, rather than whole URL 1412 | export download_file 1413 | download_file=$(echo "$1" | awk -F/ '{print $NF}') 1414 | run_ok "$download $1" "$2" 1415 | if [ $? -ne 0 ]; then 1416 | fatal "Failed to download Virtualmin release package. Cannot continue. Check your network connection and DNS settings, and verify that your system's time is accurately synchronized." 1417 | else 1418 | return 0 1419 | fi 1420 | } 1421 | 1422 | # Only root can run this 1423 | if [ "$(id -u)" -ne 0 ]; then 1424 | uname -a | grep -i CYGWIN >/dev/null 1425 | if [ "$?" != "0" ]; then 1426 | fatal "${RED}Fatal:${NORMAL} The Virtualmin install script must be run as root" 1427 | fi 1428 | fi 1429 | 1430 | bind_hook "phases_all_pre" 1431 | 1432 | if [ -n "$setup_only" ]; then 1433 | pre_check_perl 1434 | pre_check_http_client 1435 | pre_check_gpg 1436 | log_info "Started Virtualmin $vm_version $PRODUCT software repositories setup" 1437 | else 1438 | echo 1439 | phase "Check" 1 1440 | bind_hook "phase1_pre" 1441 | pre_check_all 1442 | bind_hook "phase1_post" 1443 | echo 1444 | 1445 | phase "Setup" 2 1446 | bind_hook "phase2_pre" 1447 | fi 1448 | 1449 | # Print out some details that we gather before logging existed 1450 | log_debug "Install mode: $mode" 1451 | log_debug "Product: Virtualmin $PRODUCT" 1452 | log_debug "virtualmin-install.sh version: $VER" 1453 | 1454 | # Check for a fully qualified hostname unless setting up repos or doing a 1455 | # minimal install 1456 | if [ -z "$setup_only" ] && [ "$mode" != "mini" ]; then 1457 | log_debug "Checking for fully qualified hostname .." 1458 | name="$(hostname -f)" 1459 | if [ $? -ne 0 ]; then 1460 | name=$(hostnamectl --static) 1461 | fi 1462 | if [ -n "$forcehostname" ]; then 1463 | set_hostname "$forcehostname" 1464 | elif ! is_fully_qualified "$name"; then 1465 | set_hostname 1466 | else 1467 | # Hostname is already FQDN, yet still set it 1468 | # again to make sure to have it updated everywhere 1469 | set_hostname "$name" 1470 | fi 1471 | fi 1472 | 1473 | # Insert the serial number and password into license file 1474 | log_debug "Installing serial number and license key into '$virtualmin_license_file'" 1475 | echo "SerialNumber=$SERIAL" > "$virtualmin_license_file" 1476 | echo "LicenseKey=$KEY" >> "$virtualmin_license_file" 1477 | chmod 700 "$virtualmin_license_file" 1478 | cd .. 1479 | 1480 | # Populate some distro version globals 1481 | log_debug "Operating system name: $os_real" 1482 | log_debug "Operating system version: $os_version" 1483 | log_debug "Operating system type: $os_type" 1484 | log_debug "Operating system major: $os_major_version" 1485 | 1486 | preconfigure_virtualmin_release() { 1487 | # Grab virtualmin-release from the server 1488 | log_debug "Configuring package manager for ${os_real} ${os_version} .." 1489 | 1490 | # EL-based systems handling 1491 | case "$os_type" in 1492 | rhel | fedora | centos | centos_stream | rocky | almalinux | openEuler | ol | cloudlinux | amzn ) 1493 | case "$os_type" in 1494 | rhel | centos | centos_stream) 1495 | if [ "$os_type" = "centos_stream" ]; then 1496 | if [ "$os_major_version" -lt 8 ]; then 1497 | printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer.\\n" 1498 | exit 1 1499 | fi 1500 | else 1501 | if [ "$os_major_version" -lt 7 ]; then 1502 | printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer.\\n" 1503 | exit 1 1504 | fi 1505 | fi 1506 | ;; 1507 | rocky | almalinux | openEuler | ol) 1508 | if [ "$os_major_version" -lt 8 ]; then 1509 | printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer.\\n" 1510 | exit 1 1511 | fi 1512 | ;; 1513 | cloudlinux) 1514 | if [ "$os_major_version" -lt 8 ] && [ "$os_type" = "cloudlinux" ]; then 1515 | printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer.\\n" 1516 | exit 1 1517 | fi 1518 | ;; 1519 | fedora) 1520 | if [ "$os_major_version" -lt 35 ] && [ "$os_type" = "fedora" ] ; then 1521 | printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer.\\n" 1522 | exit 1 1523 | fi 1524 | ;; 1525 | amzn) 1526 | if [ "$os_major_version" -lt 2023 ] && [ "$os_type" = "amzn" ] ; then 1527 | printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer.\\n" 1528 | exit 1 1529 | fi 1530 | ;; 1531 | *) 1532 | printf "${RED}This OS/version is not recognized! Cannot continue!${NORMAL}\\n" 1533 | exit 1 1534 | ;; 1535 | esac 1536 | if [ -x /usr/sbin/setenforce ]; then 1537 | log_debug "Disabling SELinux during installation .." 1538 | if /usr/sbin/setenforce 0 1>/dev/null 2>&1; then 1539 | log_debug " setenforce 0 succeeded" 1540 | else 1541 | log_debug " setenforce 0 failed: $?" 1542 | fi 1543 | fi 1544 | package_type="rpm" 1545 | allow_skip_broken=" --skip-broken" 1546 | if [ "$unstable" != 'unstable' ]; then 1547 | allow_skip_broken="" 1548 | fi 1549 | if command -pv dnf 1>/dev/null 2>&1; then 1550 | install_cmd="dnf" 1551 | install="$install_cmd -y install" 1552 | upgrade="$install_cmd -y update" 1553 | update="$install_cmd clean all ; $install_cmd makecache" 1554 | install_group_opts="-y --quiet group install --setopt=group_package_types=mandatory,default$allow_skip_broken" 1555 | install_group="$install_cmd $install_group_opts" 1556 | install_config_manager="$install_cmd config-manager" 1557 | # Do not use package manager when fixing repos 1558 | if [ -z "$setup_only" ]; then 1559 | run_ok "$install dnf-plugins-core" "Installing core plugins for package manager" 1560 | fi 1561 | else 1562 | install_cmd="yum" 1563 | install="$install_cmd -y install" 1564 | upgrade="$install_cmd -y update" 1565 | update="$install_cmd clean all ; $install_cmd makecache" 1566 | if [ "$os_major_version" -ge 7 ]; then 1567 | # Do not use package manager when fixing repos 1568 | if [ -z "$setup_only" ]; then 1569 | run_ok "$install_cmd --quiet groups mark convert" "Updating groups metadata" 1570 | fi 1571 | fi 1572 | install_group_opts="-y --quiet$allow_skip_broken groupinstall --setopt=group_package_types=mandatory,default" 1573 | install_group="$install_cmd $install_group_opts" 1574 | install_config_manager="yum-config-manager" 1575 | fi 1576 | 1577 | # Remove any existing obsolete package release 1578 | if [ -x "/usr/bin/rpm" ]; then 1579 | rpm_release_files="$(rpm -qal virtualmin*release)" 1580 | rpm_release_files=$(echo "$rpm_release_files" | tr '\n' ' ') 1581 | if [ -n "$rpm_release_files" ]; then 1582 | for rpm_release_file in $rpm_release_files; do 1583 | rm -f "$rpm_release_file" 1584 | done 1585 | fi 1586 | fi 1587 | rpm -e --nodeps --quiet "$(rpm -qa virtualmin*release 2>/dev/null)" >> "$RUN_LOG" 2>&1 1588 | 1589 | # Repo setup is done by "manage_virtualmin_branch_repos" using a unified 1590 | # logic 1591 | ;; 1592 | 1593 | # Debian-based systems handling 1594 | debian | ubuntu | kali) 1595 | case "$os_type" in 1596 | ubuntu) 1597 | case "$os_version:$unstable" in 1598 | 18.04:*|20.04:*|22.04:*|24.04:*|*\.10:unstable|*[13579].04:unstable) 1599 | : ;; # Do nothing for supported or allowed unstable versions 1600 | *) 1601 | printf "${RED}${os_real} ${os_version} is not supported by this installer.${NORMAL}\\n" 1602 | exit 1 1603 | ;; 1604 | esac 1605 | ;; 1606 | debian) 1607 | if [ "$os_major_version" -lt 10 ]; then 1608 | printf "${RED}${os_real} ${os_version} is not supported by this installer.${NORMAL}\\n" 1609 | exit 1 1610 | fi 1611 | ;; 1612 | kali) 1613 | if [ "$os_major_version" -lt 2023 ] && [ "$os_type" = "kali" ] ; then 1614 | printf "${RED}${os_real} ${os_version}${NORMAL} is not supported by this installer.\\n" 1615 | exit 1 1616 | fi 1617 | ;; 1618 | esac 1619 | package_type="deb" 1620 | if [ "$os_type" = "ubuntu" ]; then 1621 | deps="$ubudeps" 1622 | repos="virtualmin" 1623 | else 1624 | deps="$debdeps" 1625 | repos="virtualmin" 1626 | fi 1627 | 1628 | # Make sure universe repos are available 1629 | if [ "$os_type" = "ubuntu" ]; then 1630 | if [ -x "/bin/add-apt-repository" ] || [ -x "/usr/bin/add-apt-repository" ]; then 1631 | run_ok "add-apt-repository -y universe" \ 1632 | "Enabling universe repositories, if not already available" 1633 | elif [ -f /etc/apt/sources.list ]; then 1634 | run_ok "sed -ie '/backports/b; s/#*[ ]*deb \\(.*\\) universe$/deb \\1 universe/' /etc/apt/sources.list" \ 1635 | "Enabling universe repositories, if not already available" 1636 | fi 1637 | fi 1638 | 1639 | # Is this still enabled by default on Debian/Ubuntu systems? 1640 | if [ -f /etc/apt/sources.list ]; then 1641 | run_ok "sed -ie 's/^deb cdrom:/#deb cdrom:/' /etc/apt/sources.list" "Disabling cdrom: repositories" 1642 | fi 1643 | install="DEBIAN_FRONTEND='noninteractive' /usr/bin/apt-get --quiet --assume-yes --install-recommends -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o Dpkg::Pre-Install-Pkgs::='/usr/sbin/dpkg-preconfigure --apt' install" 1644 | upgrade="DEBIAN_FRONTEND='noninteractive' /usr/bin/apt-get --quiet --assume-yes --install-recommends -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o Dpkg::Pre-Install-Pkgs::='/usr/sbin/dpkg-preconfigure --apt' upgrade" 1645 | update="/usr/bin/apt-get clean ; /usr/bin/apt-get update" 1646 | run_ok "apt-get clean" "Cleaning up software repo metadata" 1647 | if [ -f /etc/apt/sources.list ]; then 1648 | sed -i "s/\\(deb[[:space:]]file.*\\)/#\\1/" /etc/apt/sources.list 1649 | fi 1650 | 1651 | # Repo setup is done by "manage_virtualmin_branch_repos" using a unified 1652 | # logic 1653 | ;; 1654 | *) 1655 | log_error " Your OS is not currently supported by this installer. Nevertheless, you" 1656 | log_error " should still be able to run Virtualmin on your system by following the" 1657 | log_error " manual installation process." 1658 | exit 1 1659 | ;; 1660 | esac 1661 | 1662 | return 0 1663 | } 1664 | 1665 | # Setup repos only 1666 | if [ -n "$setup_only" ]; then 1667 | if preconfigure_virtualmin_release; then 1668 | manage_virtualmin_branch_repos 1669 | log_success "Virtualmin repository is configured successfully." 1670 | else 1671 | log_error "Errors occurred during setup of Virtualmin software repositories. You may find more" 1672 | log_error "information in ${RUN_LOG}." 1673 | fi 1674 | exit $? 1675 | fi 1676 | 1677 | # Install Functions 1678 | install_with_apt() { 1679 | # Install system package upgrades, if any 1680 | if [ -z "$noupdates" ]; then 1681 | run_ok "$upgrade" "Checking and installing system package updates" 1682 | fi 1683 | 1684 | # Silently purge packages that may cause issues upon installation 1685 | /usr/bin/apt-get --quiet --assume-yes purge ufw >> "$RUN_LOG" 2>&1 1686 | 1687 | # Install Webmin/Usermin first, because it needs to be already done 1688 | # for the deps. Then install Virtualmin Core and then Stack packages 1689 | # Do it all in one go for the nicer UI 1690 | run_ok "$install webmin && $install $debvmpackages && $install $deps" "Installing Virtualmin $vm_version and all related packages" 1691 | if [ $? -ne 0 ]; then 1692 | log_warning "apt-get seems to have failed. Are you sure your OS and version is supported?" 1693 | log_warning "https://www.virtualmin.com/os-support" 1694 | fatal "Installation failed: $?" 1695 | fi 1696 | 1697 | # Make sure the time is set properly 1698 | /usr/sbin/ntpdate-debian >> "$RUN_LOG" 2>&1 1699 | 1700 | return 0 1701 | } 1702 | 1703 | install_with_yum() { 1704 | # Enable CodeReady and EPEL on RHEL 8+ 1705 | if [ "$os_major_version" -ge 8 ] && [ "$os_type" = "rhel" ]; then 1706 | # Important Perl packages are now hidden in CodeReady repo 1707 | run_ok "$install_config_manager --set-enabled codeready-builder-for-rhel-$os_major_version-$arch-rpms" "Enabling Red Hat CodeReady package repository" 1708 | # Install EPEL 1709 | download "https://dl.fedoraproject.org/pub/epel/epel-release-latest-$os_major_version.noarch.rpm" >>"$log" 2>&1 1710 | run_ok "rpm -U --replacepkgs --quiet epel-release-latest-$os_major_version.noarch.rpm" "Installing EPEL $os_major_version release package" 1711 | # Install EPEL on RHEL 7 1712 | elif [ "$os_major_version" -eq 7 ] && [ "$os_type" = "rhel" ]; then 1713 | download "https://dl.fedoraproject.org/pub/epel/epel-release-latest-$os_major_version.noarch.rpm" >>"$log" 2>&1 1714 | run_ok "rpm -U --replacepkgs --quiet epel-release-latest-$os_major_version.noarch.rpm" "Installing EPEL $os_major_version release package" 1715 | # Install EPEL on CentOS/Alma/Rocky 1716 | elif [ "$os_type" = "centos" ] || [ "$os_type" = "centos_stream" ] || [ "$os_type" = "rocky" ] || [ "$os_type" = "almalinux" ]; then 1717 | run_ok "$install epel-release" "Installing EPEL $os_major_version release package" 1718 | # CloudLinux EPEL 1719 | elif [ "$os_type" = "cloudlinux" ]; then 1720 | # Install EPEL on CloudLinux 1721 | download "https://dl.fedoraproject.org/pub/epel/epel-release-latest-$os_major_version.noarch.rpm" >>"$log" 2>&1 1722 | run_ok "rpm -U --replacepkgs --quiet epel-release-latest-$os_major_version.noarch.rpm" "Installing EPEL $os_major_version release package" 1723 | # Install EPEL on Oracle 7+ 1724 | elif [ "$os_type" = "ol" ]; then 1725 | run_ok "$install oracle-epel-release-el$os_major_version" "Installing EPEL release package" 1726 | # Installation on Amazon Linux 1727 | elif [ "$os_type" = "amzn" ]; then 1728 | # Set for installation packages whichever available on Amazon Linux as they 1729 | # go with different name, e.g. mariadb105-server instead of mariadb-server 1730 | virtualmin_stack_custom_packages="mariadb*-server" 1731 | # Exclude from config what's not available on Amazon Linux 1732 | virtualmin_config_system_excludes=" --exclude AWStats --exclude Etckeeper --exclude Fail2banFirewalld --exclude ProFTPd" 1733 | fi 1734 | 1735 | # Important Perl packages are now hidden in PowerTools repo 1736 | if [ "$os_major_version" -ge 8 ] && [ "$os_type" = "centos" ] || [ "$os_type" = "centos_stream" ] || [ "$os_type" = "rocky" ] || [ "$os_type" = "almalinux" ] || [ "$os_type" = "cloudlinux" ]; then 1737 | # Detect CRB/PowerTools repo name 1738 | if [ "$os_major_version" -ge 9 ]; then 1739 | extra_packages=$(dnf repolist all | grep "^crb") 1740 | if [ -n "$extra_packages" ]; then 1741 | extra_packages="crb" 1742 | extra_packages_name="CRB" 1743 | fi 1744 | else 1745 | extra_packages=$(dnf repolist all | grep "^powertools") 1746 | extra_packages_name="PowerTools" 1747 | if [ -n "$extra_packages" ]; then 1748 | extra_packages="powertools" 1749 | else 1750 | extra_packages="PowerTools" 1751 | fi 1752 | fi 1753 | 1754 | run_ok "$install_config_manager --set-enabled $extra_packages" "Enabling $extra_packages_name package repository" 1755 | fi 1756 | 1757 | 1758 | # Important Perl packages are hidden in ol8_codeready_builder repo in Oracle 1759 | if [ "$os_major_version" -ge 8 ] && [ "$os_type" = "ol" ]; then 1760 | run_ok "$install_config_manager --set-enabled ol${os_major_version}_codeready_builder" "Enabling Oracle Linux $os_major_version CodeReady Builder" 1761 | fi 1762 | 1763 | # XXX This is so stupid. Why does yum insists on extra commands? 1764 | if [ "$os_major_version" -eq 7 ]; then 1765 | run_ok "yum --quiet groups mark install $rhgroup" "Marking $rhgrouptext for install" 1766 | run_ok "yum --quiet groups mark install $vmgroup" "Marking $vmgrouptext for install" 1767 | fi 1768 | 1769 | # Clear cache 1770 | run_ok "$install_cmd clean all" "Cleaning up software repo metadata" 1771 | 1772 | # Upgrade system packages first 1773 | if [ -z "$noupdates" ]; then 1774 | run_ok "$upgrade" "Checking and installing system package updates" 1775 | fi 1776 | 1777 | # Install custom stack packages 1778 | if [ -n "$virtualmin_stack_custom_packages" ]; then 1779 | run_ok "$install $virtualmin_stack_custom_packages" "Installing missing stack packages" 1780 | fi 1781 | 1782 | # Install core and stack 1783 | run_ok "$install_group $rhgroupid" "Installing dependencies and system packages" 1784 | run_ok "$install_group $vmgroupid" "Installing Virtualmin $vm_version and all related packages" 1785 | rs=$? 1786 | if [ $? -ne 0 ]; then 1787 | fatal "Installation failed: $rs" 1788 | fi 1789 | 1790 | return 0 1791 | } 1792 | 1793 | install_virtualmin() { 1794 | case "$package_type" in 1795 | rpm) 1796 | install_with_yum 1797 | ;; 1798 | deb) 1799 | install_with_apt 1800 | ;; 1801 | *) 1802 | install_with_tar 1803 | ;; 1804 | esac 1805 | rs=$? 1806 | if [ $? -eq 0 ]; then 1807 | return 0 1808 | else 1809 | return "$rs" 1810 | fi 1811 | } 1812 | 1813 | yum_check_skipped() { 1814 | loginstalled=0 1815 | logskipped=0 1816 | skippedpackages="" 1817 | skippedpackagesnum=0 1818 | while IFS= read -r line 1819 | do 1820 | if [ "$line" = "Installed:" ]; then 1821 | loginstalled=1 1822 | elif [ "$line" = "" ]; then 1823 | loginstalled=0 1824 | logskipped=0 1825 | elif [ "$line" = "Skipped:" ] && [ "$loginstalled" = 1 ]; then 1826 | logskipped=1 1827 | elif [ "$logskipped" = 1 ]; then 1828 | skippedpackages="$skippedpackages$line" 1829 | skippedpackagesnum=$((skippedpackagesnum+1)) 1830 | fi 1831 | done < "$log" 1832 | if [ -z "$noskippedpackagesforce" ] && [ "$skippedpackages" != "" ]; then 1833 | if [ "$skippedpackagesnum" != 1 ]; then 1834 | ts="s" 1835 | fi 1836 | skippedpackages=$(echo "$skippedpackages" | tr -s ' ') 1837 | log_warning "Skipped package${ts}:${skippedpackages}" 1838 | fi 1839 | } 1840 | 1841 | # virtualmin-release only exists for one platform...but it's as good a function 1842 | # name as any, I guess. Should just be "setup_repositories" or something. 1843 | errors=$((0)) 1844 | preconfigure_virtualmin_release 1845 | manage_virtualmin_branch_repos 1846 | bind_hook "phase2_post" 1847 | echo 1848 | phase "Installation" 3 1849 | bind_hook "phase3_pre" 1850 | install_virtualmin 1851 | if [ "$?" != "0" ]; then 1852 | errorlist="${errorlist} ${YELLOW}◉${NORMAL} Package installation returned an error.\\n" 1853 | errors=$((errors + 1)) 1854 | fi 1855 | 1856 | bind_hook "phase3_post" 1857 | 1858 | # Initialize embedded module if any 1859 | if [ -n "$module_name" ]; then 1860 | bind_hook "modules_pre" 1861 | # If module is available locally in the same directory use it 1862 | if [ -f "$pwd/${module_name}.sh" ]; then 1863 | chmod +x "$pwd/${module_name}.sh" 1864 | # shellcheck disable=SC1090 1865 | . "$pwd/${module_name}.sh" 1866 | else 1867 | log_warning "Requested module with the filename $pwd/${module_name}.sh does not exist." 1868 | fi 1869 | bind_hook "modules_post" 1870 | fi 1871 | 1872 | # Reap any clingy processes (like spinner forks) 1873 | # get the parent pids (as those are the problem) 1874 | allpids="$(ps -o pid= --ppid $$) $allpids" 1875 | for pid in $allpids; do 1876 | kill "$pid" 1>/dev/null 2>&1 1877 | done 1878 | 1879 | # Final step is configuration. Wait here for a moment, hopefully letting any 1880 | # apt processes disappear before we start, as they're huge and memory is a 1881 | # problem. XXX This is hacky. I'm not sure what's really causing random fails. 1882 | sleep 1 1883 | echo 1884 | phase "Configuration" 4 1885 | bind_hook "phase4_pre" 1886 | if [ "$mode" = "mini" ]; then 1887 | bundle="Mini${bundle}" 1888 | fi 1889 | # shellcheck disable=SC2086 1890 | virtualmin-config-system --bundle "$bundle" $virtualmin_config_system_excludes --log "$log" 1891 | if [ "$?" != "0" ]; then 1892 | errorlist="${errorlist} ${YELLOW}◉${NORMAL} Postinstall configuration returned an error.\\n" 1893 | errors=$((errors + 1)) 1894 | fi 1895 | sleep 1 1896 | # Do we still need to kill stuck spinners? 1897 | kill $! 1>/dev/null 2>&1 1898 | 1899 | # Log SSL request status, if available 1900 | if [ -f "$VIRTUALMIN_INSTALL_TEMPDIR/virtualmin_ssl_host_status" ]; then 1901 | virtualmin_ssl_host_status=$(cat "$VIRTUALMIN_INSTALL_TEMPDIR/virtualmin_ssl_host_status") 1902 | log_debug "$virtualmin_ssl_host_status" 1903 | fi 1904 | 1905 | # Functions that are used in the OS specific modifications section 1906 | disable_selinux() { 1907 | seconfigfiles="/etc/selinux/config /etc/sysconfig/selinux" 1908 | for i in $seconfigfiles; do 1909 | if [ -e "$i" ]; then 1910 | perl -pi -e 's/^SELINUX=.*/SELINUX=disabled/' "$i" 1911 | fi 1912 | done 1913 | } 1914 | 1915 | # Changes that are specific to OS 1916 | case "$os_type" in 1917 | rhel | fedora | centos | centos_stream | rocky | almalinux | openEuler | ol | cloudlinux | amzn) 1918 | disable_selinux 1919 | ;; 1920 | esac 1921 | 1922 | bind_hook "phase4_post" 1923 | 1924 | # Process additional phases if set in third-party functions 1925 | if [ -n "$hooks__phases" ]; then 1926 | # Trim leading and trailing whitespace 1927 | trim() { 1928 | echo "$1" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' 1929 | } 1930 | bind_hook "phases_pre" 1931 | unset current_phase 1932 | phases_error_occurred=0 1933 | printf '%s\n' "$hooks__phases" | sed '/^$/d' > hooks__phases_tmp 1934 | while IFS= read -r line; do 1935 | # Split the line into components 1936 | phase_number=$(trim "${line%% *}") 1937 | rest="${line#* }" 1938 | phase_name=$(trim "${rest%% *}") 1939 | rest="${rest#* }" 1940 | command=$(trim "${rest%% *}") 1941 | description=$(trim "${rest#* }") 1942 | # If it's a new phase, display phase progress 1943 | if [ "$phase_number" != "$current_phase" ]; then 1944 | echo 1945 | phase "$phase_name" "$phase_number" 1946 | current_phase="$phase_number" 1947 | fi 1948 | # Run the command 1949 | if ! run_ok "$command" "$description"; then 1950 | phases_error_occurred=1 1951 | break 1952 | fi 1953 | done < hooks__phases_tmp 1954 | # Exit if an error occurred 1955 | if [ "$phases_error_occurred" -eq 1 ]; then 1956 | exit 1 1957 | fi 1958 | bind_hook "phases_post" 1959 | fi 1960 | 1961 | bind_hook "phases_all_post" 1962 | 1963 | # Was LE SSL for hostname request successful? 1964 | if [ -d "$VIRTUALMIN_INSTALL_TEMPDIR/virtualmin_ssl_host_success" ]; then 1965 | ssl_host_success=1 1966 | fi 1967 | 1968 | # Cleanup the tmp files 1969 | bind_hook "clean_pre" 1970 | printf "${GREEN}▣▣▣${NORMAL} Cleaning up\\n" 1971 | if [ "$VIRTUALMIN_INSTALL_TEMPDIR" != "" ] && [ "$VIRTUALMIN_INSTALL_TEMPDIR" != "/" ]; then 1972 | log_debug "Cleaning up temporary files in $VIRTUALMIN_INSTALL_TEMPDIR." 1973 | find "$VIRTUALMIN_INSTALL_TEMPDIR" -delete 1974 | else 1975 | log_error "Could not safely clean up temporary files because TMPDIR set to $VIRTUALMIN_INSTALL_TEMPDIR." 1976 | fi 1977 | 1978 | if [ -n "$QUOTA_FAILED" ]; then 1979 | log_warning "Quotas were not configurable. A reboot may be required. Or, if this is" 1980 | log_warning "a VM, configuration may be required at the host level." 1981 | fi 1982 | bind_hook "clean_post" 1983 | echo 1984 | if [ $errors -eq "0" ]; then 1985 | hostname=$(hostname -f) 1986 | detect_ip 1987 | if [ "$package_type" = "rpm" ]; then 1988 | yum_check_skipped 1989 | fi 1990 | bind_hook "post_install_message" 1991 | TIME=$(date +%s) 1992 | echo "$VER=$TIME" > "/etc/webmin/virtual-server/installed" 1993 | echo "$VER=$TIME" > "/etc/webmin/virtual-server/installed-auto" 1994 | write_virtualmin_branch 1995 | else 1996 | log_warning "The following errors occurred during installation:" 1997 | echo 1998 | printf "${errorlist}" 1999 | fi 2000 | 2001 | exit 0 2002 | --------------------------------------------------------------------------------