diff --git a/lib/os/class.ISPConfigBaseOS.inc.php b/lib/os/class.ISPConfigBaseOS.inc.php index 582b408aa0fe06cd584a2bfaaf1a4f0d7dd07d20..c900f46342b43935a63a811211c3513ec7bc7dbe 100644 --- a/lib/os/class.ISPConfigBaseOS.inc.php +++ b/lib/os/class.ISPConfigBaseOS.inc.php @@ -34,7 +34,7 @@ class ISPConfigBaseOS { throw new ISPConfigOSException('Could not detect version of distribution ' . $os['ID']); } if($os['ID'] === 'debian') { - if(!in_array($os['VERSION_ID'], array('9', '10'))) { + if(!in_array($os['VERSION_ID'], array('9', '10', '11'))) { throw new ISPConfigOSException('Version ' . $os['VERSION_ID'] . ' is not supported for ' . $os['ID']); } } elseif($os['ID'] === 'ubuntu') { diff --git a/lib/os/class.ISPConfigDebian10OS.inc.php b/lib/os/class.ISPConfigDebian10OS.inc.php index cbeb262acc5756513bc5544ef0a8bd4beecf32af..942f279ca1116b961d88801d3be9eaab0e8dff26 100644 --- a/lib/os/class.ISPConfigDebian10OS.inc.php +++ b/lib/os/class.ISPConfigDebian10OS.inc.php @@ -61,7 +61,10 @@ class ISPConfigDebian10OS extends ISPConfigDebianOS { 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'; + $cmd = 'update-alternatives --set php-cgi /usr/bin/php-cgi7.3; + update-alternatives --set php-cgi-bin /usr/lib/cgi-bin/php7.3; + update-alternatives --set php-fpm.sock /run/php/php7.3-fpm.sock'; + } $result = $this->exec($cmd); if($result === false) { diff --git a/lib/os/class.ISPConfigDebian11OS.inc.php b/lib/os/class.ISPConfigDebian11OS.inc.php new file mode 100644 index 0000000000000000000000000000000000000000..8d73a9ef57d061fe0c95d21b1821798235d92660 --- /dev/null +++ b/lib/os/class.ISPConfigDebian11OS.inc.php @@ -0,0 +1,249 @@ +replaceContents('/etc/mysql/debian.cnf', array('/^password\s*=.*$/m' => 'password = ' . $mysql_root_pw)); + $this->replaceContents('/etc/mysql/mariadb.conf.d/50-server.cnf', array('/^bind-address/m' => '#bind-address'), true, 'mysqld'); + } + + public function getRestartServiceCommand($service, $command = 'restart') { + if($command != 'start' && $command != 'stop' && $command != 'status') { + $command = 'restart'; + } + + switch($service) { + case 'mysql': + case 'mariadb': + $service = 'mariadb'; + break; + case 'pureftpd': + $service = 'pure-ftpd-mysql'; + break; + } + + return 'systemctl ' . $command . ' ' . escapeshellarg($service) . ' 2>&1'; + } + + protected function getPackagesToInstall($section) { + $packages = parent::getPackagesToInstall($section); + + if($section === 'mail') { + $packages[] = 'p7zip'; + $packages[] = 'p7zip-full'; + $packages[] = 'unrar-free'; + $packages[] = 'lrzip'; + } elseif($section === 'base') { + //$packages[] = 'jailkit'; + } + + return $packages; + } + + protected function shallCompileJailkit() { + return true; + } + + protected function setDefaultPHP() { + ISPConfigLog::info('Setting default system php version.', true); + $cmd = 'update-alternatives --set php /usr/bin/php7.4'; + $result = $this->exec($cmd); + if($result === false) { + throw new ISPConfigOSException('Command ' . $cmd . ' failed.'); + } + + if(ISPConfig::shallInstall('web')) { + // 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-cgi-bin /usr/lib/cgi-bin/php7.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.'); + } + } + } + + protected function getRoundcubePackages() { + return array( + 'roundcube/buster-backports', + 'roundcube-core/buster-backports', + 'roundcube-mysql/buster-backports', + 'roundcube-plugins/buster-backports' + ); + } + + protected function addBusterBackportsRepo() { + ISPConfigLog::info('Activating Buster Backports repository.', true); + $cmd = 'echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/buster-backports.list'; + $result = $this->exec($cmd); + if($result === false) { + throw new ISPConfigOSException('Command ' . $cmd . ' failed.'); + } + } + + protected function installRoundcube($mysql_root_pw) { + $this->addBusterBackportsRepo(); + $this->updatePackageList(); + parent::installRoundcube($mysql_root_pw); + } + + protected function getFail2BanJail() { + $jk_jail = '[pure-ftpd] +enabled = true +port = ftp +filter = pure-ftpd +logpath = /var/log/syslog +maxretry = 3 + +[dovecot] +enabled = true +filter = dovecot +logpath = /var/log/mail.log +maxretry = 5 + +[postfix-sasl] +enabled = true +port = smtp +filter = postfix[mode=auth] +logpath = /var/log/mail.log +maxretry = 3'; + return $jk_jail; + } + + protected function installPHPMyAdmin($mysql_root_pw) { + if(!ISPConfig::shallInstall('web') || !ISPConfig::shallInstall('pma')) { + return; + } + + ISPConfigLog::info('Installing package phpmyadmin', true); + + if(!is_dir('/usr/share/phpmyadmin')) { + mkdir('/usr/share/phpmyadmin', 0755, true); + } + if(!is_dir('/etc/phpmyadmin')) { + mkdir('/etc/phpmyadmin', 0755); + } + if(!is_dir('/var/lib/phpmyadmin/tmp')) { + mkdir('/var/lib/phpmyadmin/tmp', 0777, true); + } + touch('/etc/phpmyadmin/htpasswd.setup'); + + $cmd = 'chown -R www-data:www-data ' . escapeshellarg('/var/lib/phpmyadmin') . ' ; cd /tmp ; rm -f phpMyAdmin-4.9.0.1-all-languages.tar.gz ; wget "https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.tar.gz" 2>/dev/null && tar xfz phpMyAdmin-4.9.0.1-all-languages.tar.gz && cp -a phpMyAdmin-4.9.0.1-all-languages/* /usr/share/phpmyadmin/ && rm -f phpMyAdmin-4.9.0.1-all-languages.tar.gz && rm -rf phpMyAdmin-4.9.0.1-all-languages'; + $result = $this->exec($cmd); + if($result === false) { + throw new ISPConfigOSException('Command ' . $cmd . ' failed.'); + } + + copy('/usr/share/phpmyadmin/config.sample.inc.php', '/usr/share/phpmyadmin/config.inc.php'); + + $replacements = array( + '/^(?:\s*\/\/)?\s*\$cfg\[\'blowfish_secret\'\]\s*=.*$/m' => '$cfg[\'blowfish_secret\'] = \'' . substr(sha1(uniqid('pre', true)), 0, 32) . '\';', + '/^(?:\s*\/\/)?\s*\$cfg\[\'TempDir\'\]\s*=.*$/m' => '$cfg[\'TempDir\'] = \'/var/lib/phpmyadmin/tmp\';' + ); + $this->replaceContents('/usr/share/phpmyadmin/config.inc.php', $replacements, true); + + $contents = '# phpMyAdmin default Apache configuration + +Alias /phpmyadmin /usr/share/phpmyadmin + + + Options FollowSymLinks + DirectoryIndex index.php + + + AddType application/x-httpd-php .php + + php_flag magic_quotes_gpc Off + php_flag track_vars On + php_flag register_globals Off + php_value include_path . + + + + +# Authorize for setup + + + AuthType Basic + AuthName "phpMyAdmin Setup" + AuthUserFile /etc/phpmyadmin/htpasswd.setup + + Require valid-user + + +# Disallow web access to directories that don\'t need it + + Order Deny,Allow + Deny from All + + + Order Deny,Allow + Deny from All +'; + if(ISPConfig::$WEBSERVER === ISPC_WEBSERVER_APACHE) { + file_put_contents('/etc/apache2/conf-available/phpmyadmin.conf', $contents); + + $cmd = 'a2enconf phpmyadmin'; + $result = $this->exec($cmd); + if($result === false) { + throw new ISPConfigOSException('Command ' . $cmd . ' failed.'); + } + + $this->restartService('apache2'); + } + + $pma_pass = ISPConfigFunctions::generatePassword(15); + $pma_pass_enc = preg_replace('/[\'\\\\]/', '\\$1', $pma_pass); + + $queries = array( + 'CREATE DATABASE phpmyadmin;', + 'CREATE USER \'pma\'@\'localhost\' IDENTIFIED BY \'' . $pma_pass_enc . '\';', + 'GRANT ALL PRIVILEGES ON phpmyadmin.* TO \'pma\'@\'localhost\' IDENTIFIED BY \'' . $pma_pass_enc . '\' WITH GRANT OPTION;', + 'FLUSH PRIVILEGES;' + ); + + foreach($queries as $query) { + $cmd = 'mysql --defaults-file=/etc/mysql/debian.cnf -e ' . escapeshellarg($query) . ' 2>&1'; + $result = $this->exec($cmd); + if($result === false) { + ISPConfigLog::warn('Query ' . $query . ' failed.', true); + } + } + + $cmd = 'mysql --defaults-file=/etc/mysql/debian.cnf -D phpmyadmin < /usr/share/phpmyadmin/sql/create_tables.sql'; + $result = $this->exec($cmd); + if($result === false) { + ISPConfigLog::warn('Command ' . $cmd . ' failed.', true); + } + + $uncomment = array( + array( + 'first_line' => '/^(?:\s*\/\/)?\s*\$cfg\[\'Servers\'\]\[\$i\]/', + 'last_line' => '/####nomatch###/', + 'search' => '/^(?:\s*\/\/)?\s*\$cfg\[\'Servers\'\]\[\$i\]/' + ) + ); + $this->uncommentLines('/usr/share/phpmyadmin/config.inc.php', $uncomment, '//'); + + $replacements = array( + '/^(?:\s*\/\/)?\s*(\$cfg\[\'Servers\'\]\[\$i\]\[\'controlhost\'\])\s*=.*$/m' => '$1 = \'localhost\';', + '/^(?:\s*\/\/)?\s*(\$cfg\[\'Servers\'\]\[\$i\]\[\'controlport\'\])\s*=.*$/m' => '$1 = \'\';', + '/^(?:\s*\/\/)?\s*(\$cfg\[\'Servers\'\]\[\$i\]\[\'controluser\'\])\s*=.*$/m' => '$1 = \'pma\';', + '/^(?:\s*\/\/)?\s*(\$cfg\[\'Servers\'\]\[\$i\]\[\'controlpass\'\])\s*=.*$/m' => '$1 = \'' . $pma_pass_enc . '\';', + ); + $this->replaceContents('/usr/share/phpmyadmin/config.inc.php', $replacements, false); + } + + protected function getSystemPHPVersion() { + return '7.4'; + } +} diff --git a/lib/os/class.ISPConfigDebianOS.inc.php b/lib/os/class.ISPConfigDebianOS.inc.php index 1310e9652c2520143aa4db991cccc472ce267386..ad1f696cbcb2f92a5c2cb124a3309622d00e02dc 100644 --- a/lib/os/class.ISPConfigDebianOS.inc.php +++ b/lib/os/class.ISPConfigDebianOS.inc.php @@ -148,7 +148,7 @@ class ISPConfigDebianOS extends ISPConfigBaseOS { 'php-pear', 'php-memcache', 'php-imagick', - 'php-gettext', + 'php-php-gettext', 'mcrypt', 'imagemagick', 'libruby', @@ -703,11 +703,16 @@ mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"'; 'mariadb-client', 'mariadb-server', 'openssl', - 'getmail4', 'rkhunter', 'binutils', 'sudo' ); + $os = $this->getOSVersion(); + if($os['VERSION'] > 10) { + $packages[] = 'getmail'; + } else { + $packages[] = 'getmail4'; + } $this->installPackages($packages); if(ISPConfig::shallInstall('mail')) { @@ -1107,10 +1112,13 @@ mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"'; $packages = array( 'pure-ftpd-common', 'pure-ftpd-mysql', - 'webalizer', 'awstats', 'goaccess' ); + $os = $this->getOSVersion(); + if($os['VERSION'] <= 10) { + $packages[] = 'webalizer'; + } $this->installPackages($packages); ISPConfigLog::info('Enabling TLS for pureftpd', true);