如何在Debian Wheezy上配置自动更新
版本1.0
作者:Falko Timme,Srijan Kishore
最后编辑:07 / Jul / 2014
本教程将介绍如何配置Debian Wheezy系统,以便在没有用户交互的情况下自动安装软件包更新。 除此之外,我还会告诉你需要做什么才能让系统每天都向您发送有关可用更新的信息。
1配置无人值守升级的系统
要使系统自动安装升级,我们需要安装软件包无人值守升级。 如果要配置无人值守升级包来发送电子邮件通知,那么在系统上配置/ usr / bin / mail命令也是很好的,因此我们还安装了bsd-mailx包:
apt-get install unattended-upgrades bsd-mailx
您可以通过修改文件/etc/apt/apt.conf.d/50unattended-upgrades来配置无人参与升级软件包:
vi /etc/apt/apt.conf.d/50unattended-upgrades
通常默认配置应该可以; 如果要更改任何内容,请阅读文件中的注释,使配置自我解释。 例如,您可以指定升级来源(默认值:稳定和安全),您可以黑名单不应更新的软件包,如果有问题,您可以将系统发送给您,您可以让系统在更新后删除未使用的依赖项,或者如果在更新后需要,可以使系统自动重新启动。 请注意:双斜线//作为评论; 在同一行中遵循评论的任何内容都不会被评估。
// Automatically upgrade packages from these origin patterns Unattended-Upgrade::Origins-Pattern { // Archive or Suite based matching: // Note that this will silently match a different release after // migration to the specified archive (e.g. testing becomes the // new stable). // "o=Debian,a=stable"; // "o=Debian,a=stable-updates"; // "o=Debian,a=proposed-updates"; "origin=Debian,archive=stable,label=Debian-Security"; }; // List of packages to not update Unattended-Upgrade::Package-Blacklist { // "vim"; // "libc6"; // "libc6-dev"; // "libc6-i686"; }; // This option allows you to control if on a unclean dpkg exit // unattended-upgrades will automatically run // dpkg --force-confold --configure -a // The default is true, to ensure updates keep getting installed //Unattended-Upgrade::AutoFixInterruptedDpkg "false"; // Split the upgrade into the smallest possible chunks so that // they can be interrupted with SIGUSR1. This makes the upgrade // a bit slower but it has the benefit that shutdown while a upgrade // is running is possible (with a small delay) //Unattended-Upgrade::MinimalSteps "true"; // Install all unattended-upgrades when the machine is shuting down // instead of doing it in the background while the machine is running // This will (obviously) make shutdown slower //Unattended-Upgrade::InstallOnShutdown "true"; |
接下来创建文件/etc/apt/apt.conf.d/02periodic
以启用无人值守升级(再次,文件由于注释而自我解释):
vi /etc/apt/apt.conf.d/02periodic
// Enable the update/upgrade script (0=disable)
APT::Periodic::Enable "1";
// Do "apt-get update" automatically every n-days (0=disable)
APT::Periodic::Update-Package-Lists "1";
// Do "apt-get upgrade --download-only" every n-days (0=disable)
APT::Periodic::Download-Upgradeable-Packages "1";
// Run the "unattended-upgrade" security upgrade script
// every n-days (0=disabled)
// Requires the package "unattended-upgrades" and will write
// a log in /var/log/unattended-upgrades
APT::Periodic::Unattended-Upgrade "1";
// Do "apt-get autoclean" every n-days (0=disable)
APT::Periodic::AutocleanInterval "7";
|
而已! 无人值守升级将从cron工作脚本/etc/cron.daily/apt每天运行一次
脚本将记录到/var/log/unattended-upgrades/unattended-upgrades.log文件日志文件可以在成功升级后具有类似于这些条目的条目:
2014-07-07 17:49:30,878 INFO初始黑名单包:
2014-07-07 17:49:30,880 INFO启动无人值守升级脚本
2014-07-07 17:49:30,880 INFO允许的来源是:[“('Debian','stable')”,“('Debian','wheezy-security')”]
2014-07-07 17:50:05,222 INFO升级的软件包:apache2 apache2-doc apache2-mpm-prefork apache2-utils apache2.2-bin
apache2.2-common apt apt-utils base-files dpkg dselect file gnupg gpgv
libapt-inst1.5 libapt-pkg4.12 libc-bin libc6 libc6:i386 libcurl3:i386
libdbus-1-3 libdbus-1-3:i386 libgnutls26 libgnutls26:i386 libjbig0:i386
libmagic1 libnspr4:i386 libnspr4-0d:i386 libsnmp-base libsnmp15 libssl1.0.0
libssl1.0.0:i386 libwbclient0 libxml2 libxml2:i386 locales alles-all
multiarch-support openssh-client openssh-server openssl samba samba-common
snmp tzdata wget whois
2014-07-07 17:50:05,225 INFO写入dpkg日志到'/var/log/unattended-upgrades/unattended-upgrades-dpkg_2014-07-07_17:50:05.224836.log'
2014-07-07 17:51:51,290 INFO所有升级安装
2使系统发送关于可用更新的通知
还有另一个有用的软件包,称为apticron ,可以通过电子邮件通知有关可用更新的软件包,以及每个更新软件包中的更改列表。
要安装apticron ,只需运行:
apt-get install apticron
要配置apticron ,请编辑/etc/apticron/apticron.conf :
vi /etc/apticron/apticron.conf
所有需要更改的内容是EMAIL指令 - 请指定一个或多个电子邮件地址(由空格分隔),以获得有关可用更新的通知:
[...] # set EMAIL to a space separated list of addresses which will be notified of # impending updates # EMAIL="root@localhost admin@yourdomain.com" [...] |
除此之外,默认配置应适合大多数情况。
3链接
Debian: http : //www.debian.org/