Commit a26e3290 authored by Thom's avatar Thom 🛠

Use parent::installUnattendedUpgrades() (#25)

parent 895bbbe7
......@@ -108,35 +108,11 @@ maxretry = 3';
}
protected function installUnattendedUpgrades() {
ISPConfigLog::info('Installing UnattendedUpgrades', true);
$packages = array(
'unattended-upgrades',
'apt-listchanges'
parent::installUnattendedUpgrades();
// Enable normal updates
$replacements = array(
'/^\/\/\s*"\$\{distro_id\}:\$\{distro_codename\}\-updates";/m' => ' "${distro_id}:${distro_codename}-updates";'
);
$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);
}
}
// 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);
$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