Is there a sort of update tool for my Raspbian Debian 7 (Wheezy) package?
I installed php
and lighttpd
, and I want to keep those automatically updated for when bugs are found.
Is there a sort of update tool for my Raspbian Debian 7 (Wheezy) package?
I installed php
and lighttpd
, and I want to keep those automatically updated for when bugs are found.
You need to enter some commands into the command line. First of all:
apt-get update
(this will update the sources of software)
apt-get upgrade
(this will upgrade everything to the latest version)
The unattended-upgrades
package is the way to automate updating the OS in these debian-family distributions. Follow instructions found in here.
Basically you have to install the package:
sudo apt-get install unattended-upgrades
and add to /etc/apt/apt.conf.d/10periodic
the following:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";
Additionally (since it seems like the porting of the package has not been flawless), change the following line at the first section of /etc/apt/apt.conf.d/50unattended-upgrades
:
"origin=Debian,archive=stable,label=Debian-Security";
to
// "origin=Debian,archive=stable,label=Debian-Security";
"origin=Raspbian";
Now your system keeps itself up-to-date automatically.
origin=Debian
) is no longer necessary in the latest distribution of Raspbian.
– Dolph
Feb 09 '14 at 17:25
Checking: openssl (["<Origin component:'main' archive:'oldstable' origin:'Raspbian' label:'Raspbian' site:'mirrordirector.raspbian.org' isTrusted:True>"])
– astorije
Jul 05 '15 at 09:09
origin=Raspbian
is still necessary in the configuration file but, no, you don't need to do it yourself anymore indeed, sorry...
– astorije
Jul 05 '15 at 09:12
Dist:
$ sudo apt-get update
$ sudo apt-get upgrade
Rpi-update first time: install git and certifications for reach github.
$ sudo apt-get install ca-certificates
$ sudo apt-get install git-core
$ sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update
$ sudo chmod +x /usr/bin/rpi-update
update firmware
$ sudo rpi-update
$ sudo ldconfig
$ sudo reboot
Rpi-update after:
$ sudo rpi-update
$ sudo ldconfig
$ sudo reboot
rpi-update can now be fetched directly via apt-get, so there would be no need to deal with Wget. So here is now the updated way:
Dist:
$ sudo apt-get update
$ sudo apt-get upgrade
You need to reboot the Raspberry Pi now, otherwise the new kernel would not be used!
Rpi-update first time: Install Git and certifications to reach GitHub.
$ sudo apt-get install ca-certificates
$ sudo apt-get install git-core
$ sudo apt-get install rpi-update
Update firmware
$ sudo rpi-update
$ sudo reboot
You could also write a little script with your apt-get steps in there and run it on a schedule once a day / however often you like, that's what I've done.
How to set up a cron job on the Pi:
http://www.wexoo.net/20130406/running-cron-jobs-on-raspberry-pi-in-raspbmc
How to write a bash script:
https://www.linux.com/learn/tutorials/284789-writing-a-simple-bash-script-
My script was just a simple
apt-get update
apt-get upgrade -yes
apt-get dist-upgrade -yes
apt-get clean
and I had it logging the output to a file with >>
at the end of each line, e.g. apt-get update >> autoupdate.txt
.
It's debatable as to how good an idea it is to do this though!
The Art of Web site has a wonderfull guide for Debian Wheezy that I only had to modify one line for it to work on my testing RPi. The link will take you to thier guide on cron-apt
; which has been peraphrased bellow with modification for RPi repos' system explained.
Install cron-apt
sudo apt-get install cron-apt
Default configuration, actions, and custom configs can be found with
ls -hal /etc/cron-apt/config
ls -hal /etc/cron-apt/action.d/
ls -hal /etc/cron-apt/config.d/
Append the following to /etc/cron-apt/config
file with sudo tee -a
to enable emails to be sent with verbos information on the actions taken during automated update
echo 'MAILON="output"' | sudo tee -a /etc/cron-apt/config
echo 'DEBUG="verbose"' | sudo tee -a /etc/cron-apt/config
Logging is dumped to : /var/log/cron-apt/log
Make new action file for updating only security related packeges with touch command and add one line with sudo tee command; others will be downloaded but wait for sys-admin to install non-security updates. Allerts of updates and output will be emailed to root user or sys-admin for further review and/or actions to be taken.
sudo touch /etc/cron-apt/action.d/5-security
echo 'upgrade -y -o APT::Get::Show-Upgraded=true' | sudo tee -a /etc/cron-apt/action.d/5-security
Make new configuration file to use above action; spicifficly using /etc/apt/sources.list.d/security.list
as the path for security updates. The file path maybe differant on your system if not fully based on Debian Linux; RPi now uses mirror director so /etc/apt/sources.list
should be used instead, however, this can not be advised for production level servers because it'll update non-security updates too.
sudo touch /etc/cron-apt/config.d/5-security
echo 'OPTIONS="-o quiet=1 -o APT::Get::List-Cleanup=false -o Dir::Etc::SourceList=/etc/apt/sources.list.d/security.list -o Dir::Etc::SourceParts=\"/dev/null\""' | sudo tee -a /etc/cron-apt/config.d/5-security
Wait a day for cron-apt
to update your system and check local logs with the following to see what was updated while you slept
sudo cat /var/log/cron-apt/log
This has been tested on one RPi to work for updating every package as well as an Unbuntu PC that only updates security related packages. So I feel that it is one of the more portable options availabe. The other package for automated updates, suggested by grassroot (thank you, I'm going to test it next), unattended-upgrades
seemes like another great option to automate the update process.