Commit 3c7c9230 authored by Marius Burkard's avatar Marius Burkard
Browse files

- Ubuntu 18.04 added

parent 13225f6a
#!/bin/bash
CURDIR=$(pwd) ;
BASEDIR=$(dirname $0) ;
BASEDIR=$(realpath ${BASEDIR}) ;
......@@ -29,6 +31,24 @@ if [ "$PHP" = "" ] ; then
exit 1;
fi
# TODO download package from server
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 ;
${PHP} -q ${BASEDIR}/ispconfig.ai.php $@ && exit 0 || exit 1;
${PHP} -q ${BASEDIR}/ispconfig.ai.php $@ && exit 0 || exit 1;
\ No newline at end of file
cd ${CURDIR} ;
rm -rf /tmp/ispconfig-ai ;
\ No newline at end of file
......@@ -128,7 +128,7 @@ class ISPConfig {
ISPConfigLog::info('Starting perfect server setup for ' . $os['NAME'], true);
$installer = ISPConfigBaseOS::getOSInstance();
$installer->runPerfectSetup(false);
$installer->runPerfectSetup();
ISPConfigLog::warn('Please delete the log files in var/log/setup-* once you don\'t need them anymore because they contain your passwords!', true);
} catch(Exception $ex) {
throw $ex;
......
......@@ -298,23 +298,23 @@ class ISPConfigBaseOS {
return true;
}
protected function getInstallCommand($packages, $dry_run = false) {
protected function getInstallCommand($packages) {
if(is_string($packages)) {
$packages = array($packages);
}
$cmd = $this->getUpdateCommand('install', $dry_run);
$cmd = $this->getUpdateCommand('install');
$cmd = str_replace('<PACKAGES>', implode(' ', $packages), $cmd);
return $cmd;
}
protected function updatePackageList($dry_run = false) {
$cmd = $this->getUpdateCommand('prepare', $dry_run);
protected function updatePackageList() {
$cmd = $this->getUpdateCommand('prepare');
return $this->exec($cmd, null, 3, array('100'));
}
protected function installPackages($packages, $dry_run = false) {
$cmd = $this->getInstallCommand($packages, $dry_run);
protected function installPackages($packages) {
$cmd = $this->getInstallCommand($packages);
return $this->exec($cmd, null, 3);//, array('100'));
}
......@@ -323,6 +323,11 @@ class ISPConfigBaseOS {
return $this->exec($cmd);
}
protected function startService($service_name) {
$cmd = $this->getRestartServiceCommand($service_name, 'start');
return $this->exec($cmd);
}
protected function stopService($service_name) {
$cmd = $this->getRestartServiceCommand($service_name, 'stop');
return $this->exec($cmd);
......@@ -338,13 +343,19 @@ class ISPConfigBaseOS {
}
}
protected function afterPackageInstall($section = '') {
}
protected function beforePackageInstall($section = '') {
}
public function getPackageVersion($package) {
}
public function getPackageAlias($package) {
}
public function getUpdateCommand($mode = 'update', $dry_run = false) {
public function getUpdateCommand($mode = 'update') {
}
public function getUpdatePackageRegex() {
......@@ -356,6 +367,7 @@ class ISPConfigBaseOS {
public function getRestartServiceCommand($service, $command = 'restart') {
}
public function runPerfectSetup($dry_run = false) {
public function runPerfectSetup() {
}
}
......@@ -5,12 +5,10 @@
* @author croydon
*/
class ISPConfigDebian10OS extends ISPConfigDebianOS {
protected function updateMySQLConfig($mysql_root_pw, $dry_run = false) {
protected function updateMySQLConfig($mysql_root_pw) {
ISPConfigLog::info('Writing MySQL config files.', true);
if(!$dry_run) {
$this->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');
}
$this->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') {
......@@ -43,18 +41,16 @@ class ISPConfigDebian10OS extends ISPConfigDebianOS {
return $packages;
}
protected function setDefaultPHP($dry_run) {
protected function setDefaultPHP() {
ISPConfigLog::info('Settings default system php version.', true);
$cmd = 'update-alternatives --set php /usr/bin/php7.3 ; update-alternatives --set php-cgi /usr/bin/php-cgi7.3';
if(!$dry_run) {
$result = $this->exec($cmd);
if($result === false) {
throw new ISPConfigOSException('Command ' . $cmd . ' failed.');
}
$result = $this->exec($cmd);
if($result === false) {
throw new ISPConfigOSException('Command ' . $cmd . ' failed.');
}
}
protected function installPHPMyAdmin($mysql_root_pw, $dry_run) {
protected function installPHPMyAdmin($mysql_root_pw) {
ISPConfigLog::info('Installing package phpmyadmin', true);
if(!is_dir('/usr/share/phpmyadmin')) {
......@@ -69,11 +65,9 @@ class ISPConfigDebian10OS extends ISPConfigDebianOS {
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 && mv 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';
if(!$dry_run) {
$result = $this->exec($cmd);
if($result === false) {
throw new ISPConfigOSException('Command ' . $cmd . ' failed.');
}
$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');
......@@ -82,9 +76,7 @@ class ISPConfigDebian10OS extends ISPConfigDebianOS {
'/^(?:\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\';'
);
if(!$dry_run) {
$this->replaceContents('/usr/share/phpmyadmin/config.inc.php', $replacements, true);
}
$this->replaceContents('/usr/share/phpmyadmin/config.inc.php', $replacements, true);
$contents = '# phpMyAdmin default Apache configuration
......@@ -127,11 +119,9 @@ Alias /phpmyadmin /usr/share/phpmyadmin
file_put_contents('/etc/apache2/conf-available/phpmyadmin.conf', $contents);
$cmd = 'a2enconf phpmyadmin';
if(!$dry_run) {
$result = $this->exec($cmd);
if($result === false) {
throw new ISPConfigOSException('Command ' . $cmd . ' failed.');
}
$result = $this->exec($cmd);
if($result === false) {
throw new ISPConfigOSException('Command ' . $cmd . ' failed.');
}
$this->restartService('apache2');
......@@ -148,20 +138,16 @@ Alias /phpmyadmin /usr/share/phpmyadmin
foreach($queries as $query) {
$cmd = 'mysql --defaults-file=/etc/mysql/debian.cnf -e ' . escapeshellarg($query) . ' 2>&1';
if(!$dry_run) {
$result = $this->exec($cmd);
if($result === false) {
ISPConfigLog::warn('Query ' . $query . ' failed.', true);
}
$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';
if(!$dry_run) {
$result = $this->exec($cmd);
if($result === false) {
ISPConfigLog::warn('Command ' . $cmd . ' failed.', true);
}
$result = $this->exec($cmd);
if($result === false) {
ISPConfigLog::warn('Command ' . $cmd . ' failed.', true);
}
$uncomment = array(
......@@ -171,10 +157,7 @@ Alias /phpmyadmin /usr/share/phpmyadmin
'search' => '/^(?:\s*\/\/)?\s*\$cfg\[\'Servers\'\]\[\$i\]/'
)
);
if(!$dry_run) {
$this->uncommentLines('/usr/share/phpmyadmin/config.inc.php', $uncomment, '//');
}
$this->uncommentLines('/usr/share/phpmyadmin/config.inc.php', $uncomment, '//');
$replacements = array(
'/^(?:\s*\/\/)?\s*(\$cfg\[\'Servers\'\]\[\$i\]\[\'controlhost\'\])\s*=.*$/m' => '$1 = \'localhost\';',
......@@ -182,8 +165,6 @@ Alias /phpmyadmin /usr/share/phpmyadmin
'/^(?:\s*\/\/)?\s*(\$cfg\[\'Servers\'\]\[\$i\]\[\'controluser\'\])\s*=.*$/m' => '$1 = \'pma\';',
'/^(?:\s*\/\/)?\s*(\$cfg\[\'Servers\'\]\[\$i\]\[\'controlpass\'\])\s*=.*$/m' => '$1 = \'' . $pma_pass_enc . '\';',
);
if(!$dry_run) {
$this->replaceContents('/usr/share/phpmyadmin/config.inc.php', $replacements, false);
}
$this->replaceContents('/usr/share/phpmyadmin/config.inc.php', $replacements, false);
}
}
This diff is collapsed.
......@@ -5,6 +5,97 @@
* @author croydon
*/
class ISPConfigUbuntuOS extends ISPConfigDebianOS {
protected function configureApt() {
// enable contrib and non-free
ISPConfigLog::info('Configuring apt repositories.', true);
$contents = '# created by ISPConfig auto installer
deb http://de.archive.ubuntu.com/ubuntu/ bionic main restricted
deb http://de.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb http://de.archive.ubuntu.com/ubuntu/ bionic universe
deb http://de.archive.ubuntu.com/ubuntu/ bionic-updates universe
deb http://de.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://de.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb http://de.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
';
file_put_contents('/etc/apt/sources.list', $contents);
}
protected function beforePackageInstall($section = '') {
$this->stopService('apparmor');
$this->stopService('sendmail');
$cmd = 'update-rc.d -f apparmor remove ; update-rc.d -f sendmail remove ; apt-get -y -qq remove apparmor apparmor-utils';
$result = $this->exec($cmd);
if($result === false) {
throw new ISPConfigOSException('Command ' . $cmd . ' failed.');
}
}
protected function getPackagesToInstall($section) {
if($section === 'mail') {
$packages = parent::getPackagesToInstall($section);
}
return $packages;
}
protected function afterPackageInstall($section = '') {
if($section === 'mail') {
$cmd = 'freshclam';
$result = $this->exec($cmd, array(62));
if($result === false) {
throw new ISPConfigOSException('Command ' . $cmd . ' failed.');
}
$this->startService('clamav-daemon');
}
}
protected function addSuryRepo() {
ISPConfigLog::info('Activating sury php repository.', true);
$cmd = 'add-apt-repository -y ppa:ondrej/php';
$result = $this->exec($cmd);
if($result === false) {
throw new ISPConfigOSException('Command ' . $cmd . ' failed.');
}
}
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
action = iptables-multiport[name=dovecot-pop3imap, port="pop3,pop3s,imap,imaps", protocol=tcp]
logpath = /var/log/mail.log
maxretry = 5
[postfix-sasl]
enabled = true
port = smtp
filter = postfix
logpath = /var/log/mail.log
maxretry = 3';
return $jk_jail;
}
protected function setDefaultPHP() {
ISPConfigLog::info('Settings default system php version.', true);
$cmd = 'update-alternatives --set php /usr/bin/php7.2 ; update-alternatives --set php-cgi /usr/bin/php-cgi7.2';
$result = $this->exec($cmd);
if($result === false) {
throw new ISPConfigOSException('Command ' . $cmd . ' failed.');
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment