Commit 0b8b8e2d authored by Thom's avatar Thom 🛠

Resolve merge conflict

parents ce58c41a e157feb1
# ISPConfig 3 AutoInstaller
![alt text](https://www.ispconfig.org/wp-content/themes/ispconfig/images/ispconfig_logo.png "") \
[![pipeline status](https://git.ispconfig.org/ispconfig/ispconfig-autoinstaller/badges/master/pipeline.svg)](https://git.ispconfig.org/ispconfig/ispconfig-autoinstaller/commits/master)
This script configures your server (Ubuntu 18.04 / Debian 9 and 10 currently) following the "perfect server tutorials" from howtoforge.com and installs ISPConfig 3.
This script configures your server (Ubuntu 18.04, Ubuntu 20.04, Debian 9 and 10 currently) following the "perfect server tutorials" from howtoforge.com and installs ISPConfig 3.
## Using the script
You can use the script with curl
You can use the script with curl
`curl https://get.ispconfig.org | sh`
or with wget
`wget -O - https://get.ispconfig.org | sh`
......@@ -27,4 +27,7 @@ or using wget
If you checked out the installer from git you can simply pass the arguments to the script itself:
`./ispc3-ai.sh --debug --no-mailman`
To see all available arguments, please provide the `--help` argument.
\ No newline at end of file
To see all available arguments, please provide the `--help` argument:
`curl https://get.ispconfig.org | sh -s -- --help`
or using wget
`wget -O - https://get.ispconfig.org | sh -s -- --help`
......@@ -209,6 +209,29 @@ class ISPConfig {
}
}
public static function wantsUnattendedUpgrades() {
if(isset($_GET['unattended-upgrades']) && $_GET['unattended-upgrades']) {
return true;
} else {
return false;
}
}
public static function getUnattendedUpgradesOptions() {
if(isset($_GET['unattended-upgrades']) && $_GET['unattended-upgrades']) {
if ($_GET['unattended-upgrades'] === '') {
return $_GET['unattended-upgrades'];
} else {
$unattendedupgrades_options = explode(',',$_GET['unattended-upgrades']);
if(!empty($unattendedupgrades_options)) {
return $unattendedupgrades_options;
} else {
return false;
}
}
}
}
public static function getISPConfigChannel() {
if(isset($_GET['channel']) && $_GET['channel']) {
return $_GET['channel'];
......@@ -268,6 +291,8 @@ Possible arguments are:
--no-mailman ->Do not install Mailman mailing list manager.
--no-quota ->Disable file system quota
--no-ntp ->Disable NTP setup
--unattended-upgrades
->Install UnattendedUpgrades. You can add extra arguments for automatic cleanup and automatic reboots when necessary with --unattended-upgrades=autoclean,reboot (or only one of them).
--i-know-what-i-am-doing
->Prevent the autoinstaller to ask for confirmation before continuing to reconfigure the server.
';
......@@ -286,7 +311,7 @@ Possible arguments are:
$valid_args = array(
'help', 'debug', 'interactive',
'use-nginx', 'use-amavis', 'use-php', 'use-unbound', 'use-ftp-ports', 'use-certbot', 'channel', 'lang',
'use-nginx', 'use-amavis', 'use-php', 'use-unbound', 'use-ftp-ports', 'use-certbot', 'unattended-upgrades', 'channel', 'lang',
'no-web', 'no-mail', 'no-dns', 'no-firewall', 'no-roundcube', 'no-pma', 'no-mailman', 'no-quota', 'no-ntp', 'no-local-dns',
'i-know-what-i-am-doing'
);
......
......@@ -305,6 +305,33 @@ class ISPConfigDebianOS extends ISPConfigBaseOS {
}
}
protected function installUnattendedUpgrades() {
ISPConfigLog::info('Installing UnattendedUpgrades', true);
$packages = array(
'unattended-upgrades',
'apt-listchanges'
);
$this->installPackages($packages);
// Enable UnattendUpgrades to run every day
$unattendedupgrades = 'APT::Periodic::Update-Package-Lists "1";' . "\n" . 'APT::Periodic::Unattended-Upgrade "1";';
file_put_contents('/etc/apt/apt.conf.d/20auto-upgrades', $unattendedupgrades);
// Enable extra options if set in the arguments
$unattendedupgrades_options = ISPConfig::getUnattendedUpgradesOptions();
if (!empty($unattendedupgrades_options)) {
if (in_array("autoclean", $unattendedupgrades_options)) {
$unattendedupgrades = "\n" . 'APT::Periodic::AutocleanInterval "7";' . "\n" . 'Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";' . "\n" . 'Unattended-Upgrade::Remove-Unused-Dependencies "true";';
file_put_contents('/etc/apt/apt.conf.d/20auto-upgrades', $unattendedupgrades, FILE_APPEND | LOCK_EX);
}
if (in_array("reboot", $unattendedupgrades_options)) {
$unattendedupgrades = "\n" . 'Unattended-Upgrade::Automatic-Reboot "true";' . "\n" . 'Unattended-Upgrade::Automatic-Reboot-Time "03:30";';
file_put_contents('/etc/apt/apt.conf.d/20auto-upgrades', $unattendedupgrades, FILE_APPEND | LOCK_EX);
}
}
}
protected function shallCompileJailkit() {
return true;
}
......@@ -1095,6 +1122,10 @@ mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"';
$this->fixDbconfigCommon();
if(ISPConfig::wantsUnattendedUpgrades()) {
$this->installUnattendedUpgrades();
}
if(ISPConfig::shallInstall('mail') && ISPConfig::shallInstall('roundcube')) {
ISPConfigLog::info('Installing roundcube.', true);
......
......@@ -107,4 +107,12 @@ maxretry = 3';
return '7.2';
}
protected function installUnattendedUpgrades() {
parent::installUnattendedUpgrades();
// Enable normal updates
$replacements = array(
'/^\/\/\s*"\$\{distro_id\}:\$\{distro_codename\}\-updates";/m' => ' "${distro_id}:${distro_codename}-updates";'
);
$result = $this->replaceContents('/etc/apt/apt.conf.d/50unattended-upgrades', $replacements);
}
}
Markdown is supported
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