$ sudo apt-get install unattended-upgrades
$ sudo nano /etc/apt/apt.conf.d/10periodic
Set the following:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
Where the number is the frequency (in days)
$ sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security";
"${distro_id}:${distro_codename}-updates";
// "${distro_id}:${distro_codename}-proposed";
// "${distro_id}:${distro_codename}-backports";
};
In order to automatically upgrade custom packages do the following:
- Look in
/var/lib/apt/lists/
to find the custom package that you want to update. It should end withRelease
e.g./var/lib/apt/lists/files.freeswitch.org_repo_deb_debian_dists_wheezy_InRelease
- Open up the file
$ nano /var/lib/apt/lists/files.freeswitch.org_repo_deb_debian_dists_wheezy_InRelease
- Look for the
Origin
andSuite
entries. e.g.Origin: freeswitch
Suite: stable
and note these values. - Edit the unattended upgrades configuration again.
$ sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
- Add an entry for the
origin
andsuite
in the configuration
E.g.
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security";
"${distro_id}:${distro_codename}-updates";
"freeswitch:stable";
// "${distro_id}:${distro_codename}-proposed";
// "${distro_id}:${distro_codename}-backports";
};
This will reboot the server if required automatically.
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "19:00"; // Optional
Unattended-Upgrade::Mail "[email protected]";
$ heirloom-mailx
$ sudo su
$ cd ~
$ nano .mailrc
Add the following to .mailrc
in root's home directory.
set smtp-use-starttls
set ssl-verify=ignore
set smtp=smtp://smtp.gmail.com:587
set smtp-auth=login
set [email protected]
set smtp-auth-password=secret
set from="[email protected]
Change the permissions of .mailrc
chmod 400 .mailrc
$ sudo unattended-upgrade -v -d --dry-run
$ sudo unattended-upgrade -v -d
I managed to set up the upgrades, but it still won't send email even though I've configured it the same way.
I can email via the terminal using
mailx -v -s "subject" [email protected]
, but unattended-upgrades keeps failing to email me./etc/apt/apt.conf.d/50unattended-upgrades
has theUnattended-Upgrade::Mail
uncommented and set to my email. However, in/var/spool/mail
it says this (The CENSORED is a placeholder for my email and server name etc.):This doesn't make sense, since
mailx -v -s "subject" [email protected]
works fineThe
.mailrc
is in the root's home folder, owner by root and with the correct permissions (400)Any clue why it won't work?