如何在Debian Squeeze上配置自动更新
本教程将介绍如何配置Debian Squeeze系统以在没有用户交互的情况下自动安装软件包更新。 除此之外,我还会告诉你需要做什么才能让系统每天都向您发送有关可用更新的信息。
我不会保证这将为您工作!
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, archive) pairs Unattended-Upgrade::Allowed-Origins { "${distro_id} stable"; "${distro_id} ${distro_codename}-security"; // "${distro_id} ${distro_codename}-updates"; // "${distro_id} ${distro_codename}-proposed-updates"; }; // List of packages to not update Unattended-Upgrade::Package-Blacklist { // "vim"; // "libc6"; // "libc6-dev"; // "libc6-i686"; }; // Send email to this address for problems or packages upgrades // If empty or unset then no email is sent, make sure that you // have a working mail setup on your system. The package 'mailx' // must be installed or anything that provides /usr/bin/mail. //Unattended-Upgrade::Mail "root@localhost"; // Do automatic removal of new unused dependencies after the upgrade // (equivalent to apt-get autoremove) //Unattended-Upgrade::Remove-Unused-Dependencies "false"; // Automatically reboot *WITHOUT CONFIRMATION* if a // the file /var/run/reboot-required is found after the upgrade //Unattended-Upgrade::Automatic-Reboot "false"; // Use apt bandwidth limit feature, this example limits the download // speed to 70kb/sec //Acquire::http::Dl-Limit "70"; |
接下来创建文件/etc/apt/apt.conf.d/02periodic
以启用无人值守的upgrates(同样,文件由于注释而自我解释):
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
文件。 升级成功后,该日志文件可能有与之相似的条目:
2011-07-13 16:49:30,878 INFO Initial blacklisted packages:
2011-07-13 16:49:30,880 INFO Starting unattended upgrades script
2011-07-13 16:49:30,880 INFO Allowed origins are: ["('Debian', 'stable')", "('Debian', 'squeeze-security')"]
2011-07-13 16:50:05,222 INFO Packages that are upgraded: apt apt-listchanges apt-utils base-files bind9-host
console-setup dnsutils dpkg e2fslibs e2fsprogs host isc-dhcp-client isc-dhcp-common keyboard-configuration
klibc-utils libbind9-60 libcomerr2 libdns69 libgssapi-krb5-2 libgssrpc4 libisc62 libisccc60 libisccfg62
libk5crypto3 libkadm5clnt-mit7 libkadm5srv-mit7 libkdb5-4 libklibc libkrb5-3 libkrb5support0 libldap-2.4-2
liblwres60 libperl5.10 libruby1.8 libss2 libxml2 linux-base linux-image-2.6.32-5-amd64 login openssl passwd
perl perl-base perl-modules python python-apt python-apt-common python-minimal tzdata
2011-07-13 16:50:05,225 INFO Writing dpkg log to '/var/log/unattended-upgrades/unattended-upgrades-dpkg_2011-07-13_16:50:05.224836.log'
2011-07-13 16:51:51,290 INFO All upgrades installed
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/