diff --git a/ispc3-ai.sh b/ispc3-ai.sh index 01222274ba267366f558c0cb00775b6a238235f8..0164f4486ab7064c773f4013a96a5289dd5425ad 100755 --- a/ispc3-ai.sh +++ b/ispc3-ai.sh @@ -10,6 +10,11 @@ WGET=$(which wget) ; PHP=$(which php) ; APT=$(which apt-get) ; +use_git=false; +if [ -d .git ]; then + use_git=true; +fi + if [ "$APT" = "" ] ; then echo "It seems you are using a distribution that has no apt-get available. This is not supported."; exit 1 ; @@ -37,29 +42,34 @@ if [ "$PHP" = "" ] ; then exit 1; fi -if [ "$CURL" != "" ] ; then - $CURL -s -o /tmp/ispconfig-ai.tar.gz "https://www.ispconfig.org/downloads/ispconfig-ai.tar.gz" >/dev/null 2>&1 -else - $WGET -q -O /tmp/ispconfig-ai.tar.gz "https://www.ispconfig.org/downloads/ispconfig-ai.tar.gz" >/dev/null 2>&1 -fi +INSTALL_DIR="."; +if [ "$use_git" = false ] ; then -if [ ! -f "/tmp/ispconfig-ai.tar.gz" ] ; then - echo "Failed downloading Autoinstaller" ; - exit 1; -fi + if [ "$CURL" != "" ] ; then + $CURL -s -o /tmp/ispconfig-ai.tar.gz "https://www.ispconfig.org/downloads/ispconfig-ai.tar.gz" >/dev/null 2>&1 + else + $WGET -q -O /tmp/ispconfig-ai.tar.gz "https://www.ispconfig.org/downloads/ispconfig-ai.tar.gz" >/dev/null 2>&1 + fi + + if [ ! -f "/tmp/ispconfig-ai.tar.gz" ] ; then + echo "Failed downloading Autoinstaller" ; + exit 1; + fi -rm -rf /tmp/ispconfig-ai ; -mkdir /tmp/ispconfig-ai ; -tar -C /tmp/ispconfig-ai/ -xzf /tmp/ispconfig-ai.tar.gz || (echo "Failed extracting Autoinstaller" ; exit 1) -rm -f /tmp/ispconfig-ai.tar.gz ; -cd /tmp/ispconfig-ai ; + rm -rf /tmp/ispconfig-ai ; + mkdir /tmp/ispconfig-ai ; + tar -C /tmp/ispconfig-ai/ -xzf /tmp/ispconfig-ai.tar.gz || (echo "Failed extracting Autoinstaller" ; exit 1) + rm -f /tmp/ispconfig-ai.tar.gz ; + cd /tmp/ispconfig-ai ; + INSTALL_DIR="/tmp/ispconfig-ai"; +fi TTY=$(ps ax | grep "^[ ]*"$$ | head -n 1 | awk '{ print $2 }' 2>/dev/null); if [ "$TTY" != "" ] ; then - ${PHP} -q /tmp/ispconfig-ai/ispconfig.ai.php $@ < /dev/${TTY} ; + ${PHP} -q "$INSTALL_DIR/ispconfig.ai.php" $@ < /dev/${TTY} ; else echo "It seems you are not using a TTY. Please add --i-know-what-i-am-doing to the arguments."; - ${PHP} -q /tmp/ispconfig-ai/ispconfig.ai.php $@ ; + ${PHP} -q "$INSTALL_DIR/ispconfig.ai.php" $@ ; fi cd ${CURDIR} ; diff --git a/lib/class.ISPConfig.inc.php b/lib/class.ISPConfig.inc.php index da8ca79a29d2544138dbb31df5b6424840ed4a31..77a3a56c50634c20da31ad246ea9a41285617e1a 100644 --- a/lib/class.ISPConfig.inc.php +++ b/lib/class.ISPConfig.inc.php @@ -174,10 +174,30 @@ class ISPConfig { } public static function wantsPHP() { + // If a new version is added, the getApacheModulesToDisable function should be updated to disable the latest version (this part could be improved) + $available_php_versions = array( + '5.6', + '7.0', + '7.1', + '7.2', + '7.3', + '7.4', + '8.0' + ); if(isset($_GET['use-php']) && $_GET['use-php']) { - return $_GET['use-php']; + if ($_GET['use-php'] === 'system') { + return $_GET['use-php']; + } else { + $use_php = explode(',',$_GET['use-php']); + $php_versions = array_intersect($use_php, $available_php_versions); + if(!empty($php_versions)) { + return $php_versions; + } else { + return false; + } + } } else { - return false; + return $available_php_versions; } } @@ -224,9 +244,9 @@ Possible arguments are: --use-nginx ->Use nginx webserver instead of apache2 --use-amavis ->Use amavis instead of rspamd for mail filtering --use-unbound ->Use unbound instead of bind9 for local resolving. Only allowed if --no-dns is set. - --use-php ->Use specific PHP version instead of installing multiple PHP, e.g. --use-php=7.3 (5.6, 7.0, 7.1, 7.2 and 7.3 available). + --use-php ->Use specific PHP versions, comma separated, instead of installing multiple PHP, e.g. --use-php=7.4,8.0 (5.6, 7.0, 7.1, 7.2, 7.3, 7.4 and 8.0 available). ->--use-php=system disables the sury repository and just installs the system\'s default PHP version. - ->CURRENTLY ONLY EITHER --use-php=system OR OMITTING THE ARGUMENT (use all versions) IS SUPPORTED! + ->ommiting the argument (use all versions) --use-ftp-ports ->This option sets the passive port range for pure-ftpd. You have to specify the port range separated by hyphen, e. g. --use-ftp-ports=40110-40210. ->If not provided the passive port range will not be configured. --no-web ->Do not use ISPConfig on this server to manage webserver setting and don\'t install nginx/apache or pureftpd. This will also prevent installing an ISPConfig UI and implies --no-roundcube as well as --no-pma @@ -281,7 +301,7 @@ Possible arguments are: } elseif(isset($_GET['lang']) && !in_array($_GET['lang'], array('de', 'en'), true)) { self::printHelp(); exit; - } elseif(isset($_GET['use-php']) && $_GET['use-php'] !== 'system') {//!in_array($_GET['use-php'], array('5.6', '7.0', '7.1', '7.2', '7.3', 'system'), true)) { + } elseif(isset($_GET['use-php']) && !self::wantsPHP()) { self::printHelp(); exit; } elseif(isset($_GET['use-ftp-ports']) && (!preg_match('/^([1-9][0-9]+)-([1-9][0-9]+)$/', $_GET['use-ftp-ports'], $pmatch) || intval($pmatch[1]) >= intval($pmatch[2]))) { diff --git a/lib/os/class.ISPConfigDebian10OS.inc.php b/lib/os/class.ISPConfigDebian10OS.inc.php index 2c0d4a3a4634f0ffe29b06dfde43a13600fcbcba..b5439d8bc63a14491ca2ea83158b2815836810dc 100644 --- a/lib/os/class.ISPConfigDebian10OS.inc.php +++ b/lib/os/class.ISPConfigDebian10OS.inc.php @@ -49,7 +49,7 @@ class ISPConfigDebian10OS extends ISPConfigDebianOS { } protected function setDefaultPHP() { - ISPConfigLog::info('Settings default system php version.', true); + ISPConfigLog::info('Setting default system php version.', true); $cmd = 'update-alternatives --set php /usr/bin/php7.3'; $result = $this->exec($cmd); if($result === false) { @@ -57,7 +57,12 @@ class ISPConfigDebian10OS extends ISPConfigDebianOS { } if(ISPConfig::shallInstall('web')) { - $cmd = 'update-alternatives --set php-cgi /usr/bin/php-cgi7.3 ; update-alternatives --set php-fpm.sock /run/php/php7.3-fpm.sock'; + // When --use-php-system is used, there is no alternative for php-fpm.sock. + if(ISPConfig::wantsPHP() === 'system') { + $cmd = 'update-alternatives --set php-cgi /usr/bin/php-cgi7.3'; + } else { + $cmd = 'update-alternatives --set php-cgi /usr/bin/php-cgi7.3 ; update-alternatives --set php-fpm.sock /run/php/php7.3-fpm.sock'; + } $result = $this->exec($cmd); if($result === false) { throw new ISPConfigOSException('Command ' . $cmd . ' failed.'); diff --git a/lib/os/class.ISPConfigDebianOS.inc.php b/lib/os/class.ISPConfigDebianOS.inc.php index 65b9031c5f8d318983d101c3b71589668b1c4f31..8284f914ddd09fb67e9ca319f1ced12b2b507ebe 100644 --- a/lib/os/class.ISPConfigDebianOS.inc.php +++ b/lib/os/class.ISPConfigDebianOS.inc.php @@ -102,8 +102,13 @@ class ISPConfigDebianOS extends ISPConfigBaseOS { 'resolvconf', 'clamav', 'clamav-daemon', + 'clamav-docs', + 'zip', 'unzip', 'bzip2', + 'xz-utils', + 'lzip', + 'rar', 'arj', 'nomarch', 'lzop', @@ -111,15 +116,12 @@ class ISPConfigDebianOS extends ISPConfigBaseOS { 'apt-listchanges', 'libnet-ldap-perl', 'libauthen-sasl-perl', - 'clamav-docs', 'daemon', 'libio-string-perl', 'libio-socket-ssl-perl', 'libnet-ident-perl', - 'zip', 'libnet-dns-perl', - 'libdbd-mysql-perl', - 'dnsutils' + 'libdbd-mysql-perl' ); if(ISPConfig::shallInstall('local-dns')) { @@ -157,14 +159,22 @@ class ISPConfigDebianOS extends ISPConfigBaseOS { return $packages; } + protected function getApacheModulesToDisable() { + $modules = array( + 'mpm_prefork' + ); + + return $modules; + } + protected function getApacheModulesToEnable() { - $modules = array('suexec', 'rewrite', 'ssl', 'actions', 'include', 'dav_fs', 'dav', 'auth_digest', 'cgi', 'headers', 'proxy_fcgi', 'alias'); + $modules = array('suexec', 'rewrite', 'ssl', 'actions', 'include', 'dav_fs', 'dav', 'auth_digest', 'cgi', 'headers', 'proxy_fcgi', 'alias', 'http2', 'mpm_event'); return $modules; } protected function setDefaultPHP() { - ISPConfigLog::info('Settings default system php version.', true); + ISPConfigLog::info('Setting default system php version.', true); $cmd = 'update-alternatives --set php /usr/bin/php7.0'; $result = $this->exec($cmd); if($result === false) { @@ -172,7 +182,12 @@ class ISPConfigDebianOS extends ISPConfigBaseOS { } if(ISPConfig::shallInstall('web')) { - $cmd = 'update-alternatives --set php-cgi /usr/bin/php-cgi7.0 ; update-alternatives --set php-fpm.sock /run/php/php7.0-fpm.sock'; + // When --use-php-system is used, there is no alternative for php-fpm.sock. + if(ISPConfig::wantsPHP() === 'system') { + $cmd = 'update-alternatives --set php-cgi /usr/bin/php-cgi7.0'; + } else { + $cmd = 'update-alternatives --set php-cgi /usr/bin/php-cgi7.0 ; update-alternatives --set php-fpm.sock /run/php/php7.0-fpm.sock'; + } $result = $this->exec($cmd); if($result === false) { throw new ISPConfigOSException('Command ' . $cmd . ' failed.'); @@ -281,6 +296,15 @@ class ISPConfigDebianOS extends ISPConfigBaseOS { } } + protected function addGoAccessRepo() { + ISPConfigLog::info('Activating GoAccess repository.', true); + $cmd = 'echo "deb https://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list >/dev/null 2>&1 ; wget -O - https://deb.goaccess.io/gnugpg.key 2>&1 | sudo apt-key --keyring /etc/apt/trusted.gpg.d/goaccess.gpg add - 2>&1'; + $result = $this->exec($cmd); + if($result === false) { + throw new ISPConfigOSException('Command ' . $cmd . ' failed.'); + } +} + protected function installUnattendedUpgrades() { ISPConfigLog::info('Installing UnattendedUpgrades', true); @@ -479,6 +503,10 @@ mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"'; $this->addSuryRepo(); } + if(ISPConfig::shallInstall('web')) { + $this->addGoAccessRepo(); + } + $this->updatePackageList(); ISPConfigLog::info('Updating packages (after enabling 3rd party repos).', true); @@ -788,7 +816,6 @@ mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"'; 'apache2-utils', 'libapache2-mod-fcgid', 'apache2-suexec-pristine', - 'libapache2-mod-php', 'libapache2-mod-python', 'libapache2-mod-passenger' ); @@ -813,15 +840,8 @@ mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"'; if(ISPConfig::wantsPHP() === 'system') { $php_versions = array($this->getSystemPHPVersion()); } else { - $php_versions = array( - '5.6', - '7.0', - '7.1', - '7.2', - '7.3', - '7.4', - '8.0' - ); + //ISPConfig::run() validations prevent sending here null values + $php_versions = ISPConfig::wantsPHP(); } $php_modules = array( @@ -866,6 +886,15 @@ mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"'; $this->installPackages($packages); if(ISPConfig::shallInstall('web') && ISPConfig::$WEBSERVER === ISPC_WEBSERVER_APACHE) { + // Disable conflicting modules so mpm_event can be used with http2 + ISPConfigLog::info('Disabling conflicting apache modules.', true); + $modules = $this->getApacheModulesToDisable(); + $cmd = 'a2dismod ' . implode(' ', $modules) . ' 2>&1'; + $result = $this->exec($cmd); + if($result === false) { + throw new ISPConfigOSException('Command ' . $cmd . ' failed.'); + } + ISPConfigLog::info('Enabling apache modules.', true); $modules = $this->getApacheModulesToEnable(); $cmd = 'a2enmod ' . implode(' ', $modules) . ' 2>&1'; @@ -873,6 +902,16 @@ mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"'; if($result === false) { throw new ISPConfigOSException('Command ' . $cmd . ' failed.'); } + + ISPConfigLog::info('Enabling default PHP-FPM config.', true); + $conf = 'php' . $this->getSystemPHPVersion() . '-fpm'; + $cmd = 'a2enconf ' . $conf . ' 2>&1'; + $result = $this->exec($cmd); + if($result === false) { + throw new ISPConfigOSException('Command ' . $cmd . ' failed.'); + } + + $this->restartService('apache2'); } try { @@ -998,7 +1037,8 @@ mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"'; 'pure-ftpd-common', 'pure-ftpd-mysql', 'webalizer', - 'awstats' + 'awstats', + 'goaccess' ); $this->installPackages($packages); @@ -1096,6 +1136,7 @@ mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"'; $replacements = array( '/^\s*\$config\s*\[["\']default_host["\']\]\s*=.*$/m' => '$config[\'default_host\'] = \'localhost\';', '/^\s*\$config\s*\[["\']smtp_server["\']\]\s*=.*$/m' => '$config[\'smtp_server\'] = \'%h\';', + '/^\s*\$config\s*\[["\']smtp_port["\']\]\s*=.*$/m' => '$config[\'smtp_port\'] = 25;', '/^\s*\$config\s*\[["\']smtp_user["\']\]\s*=.*$/m' => '$config[\'smtp_user\'] = \'%u\';', '/^\s*\$config\s*\[["\']smtp_pass["\']\]\s*=.*$/m' => '$config[\'smtp_pass\'] = \'%p\';' ); diff --git a/lib/os/class.ISPConfigUbuntu2004OS.inc.php b/lib/os/class.ISPConfigUbuntu2004OS.inc.php index 8f1d91dbe0bebb83cf7c74898ddd9acc6a458a3f..acc312982960bc4c01a91be94fc510d83686bcc3 100644 --- a/lib/os/class.ISPConfigUbuntu2004OS.inc.php +++ b/lib/os/class.ISPConfigUbuntu2004OS.inc.php @@ -99,7 +99,7 @@ maxretry = 3'; } protected function setDefaultPHP() { - ISPConfigLog::info('Settings default system php version.', true); + ISPConfigLog::info('Setting default system php version.', true); $cmd = 'update-alternatives --set php /usr/bin/php7.4'; $result = $this->exec($cmd); if($result === false) { @@ -107,7 +107,12 @@ maxretry = 3'; } if(ISPConfig::shallInstall('web')) { - $cmd = 'update-alternatives --set php-cgi /usr/bin/php-cgi7.4 ; update-alternatives --set php-fpm.sock /run/php/php7.4-fpm.sock'; + // When --use-php-system is used, there is no alternative for php-fpm.sock. + if(ISPConfig::wantsPHP() === 'system') { + $cmd = 'update-alternatives --set php-cgi /usr/bin/php-cgi7.4'; + } else { + $cmd = 'update-alternatives --set php-cgi /usr/bin/php-cgi7.4 ; update-alternatives --set php-fpm.sock /run/php/php7.4-fpm.sock'; + } $result = $this->exec($cmd); if($result === false) { throw new ISPConfigOSException('Command ' . $cmd . ' failed.'); diff --git a/lib/os/class.ISPConfigUbuntuOS.inc.php b/lib/os/class.ISPConfigUbuntuOS.inc.php index edf3e55ce0249f68a8d11973259823cf18d8dc1c..aa7d4135ddcd14d0b467589c33f62432ae9c7a30 100644 --- a/lib/os/class.ISPConfigUbuntuOS.inc.php +++ b/lib/os/class.ISPConfigUbuntuOS.inc.php @@ -82,7 +82,7 @@ maxretry = 3'; } protected function setDefaultPHP() { - ISPConfigLog::info('Settings default system php version.', true); + ISPConfigLog::info('Setting default system php version.', true); $cmd = 'update-alternatives --set php /usr/bin/php7.2'; $result = $this->exec($cmd); if($result === false) { @@ -90,7 +90,12 @@ maxretry = 3'; } if(ISPConfig::shallInstall('web')) { - $cmd = 'update-alternatives --set php-cgi /usr/bin/php-cgi7.2 ; update-alternatives --set php-fpm.sock /run/php/php7.2-fpm.sock'; + // When --use-php-system is used, there is no alternative for php-fpm.sock. + if(ISPConfig::wantsPHP() === 'system') { + $cmd = 'update-alternatives --set php-cgi /usr/bin/php-cgi7.2'; + } else { + $cmd = 'update-alternatives --set php-cgi /usr/bin/php-cgi7.2 ; update-alternatives --set php-fpm.sock /run/php/php7.2-fpm.sock'; + } $result = $this->exec($cmd); if($result === false) { throw new ISPConfigOSException('Command ' . $cmd . ' failed.');