在配置文件中启用 webmin 计划的包更新

在配置文件中启用 webmin 计划的包更新

我正在使用 Terraform 和 cloud-init 在许多服务器上部署 webmin。我想在安装过程中使用配置文件模板启用“软件包更新”模块中的“计划升级”。我可以通过在 /etc/webmin/package-updates/config 中包含以下内容来成功配置操作和报告电子邮件:

sched_email=sys.admin@...
sched_action=2

但是,似乎没有用于计划间隔选择和启用它的条目。此信息存储在哪个其他配置文件(如果有)中?

我也尝试过使用 webmin CLI,但无法找出正确的选项名称:

# webmin set-config -m package-updates -o schedule -value 1
# Error: Option 'schedule' is unknown in module package-updates

答案1

弄清楚了:保存 GUI 设置时,它会在模块目录中创建一个 cron 作业并更新脚本。通过命令行启用:

# echo "0 15 * * * /etc/webmin/package-updates/update.pl" >> /var/spool/cron/root
# touch /etc/webmin/package-updates/update.pl
# chmod a+x /etc/webmin/package-updates/update.pl

然后在update.pl中添加以下内容:

#!/usr/bin/perl
open(CONF, "</etc/webmin/miniserv.conf") || die "Failed to open /etc/webmin/miniserv.conf : $!";
while(<CONF>) {
    $root = $1 if (/^root=(.*)/);
    }
close(CONF);
$root || die "No root= line found in /etc/webmin/miniserv.conf";
$ENV{'PERLLIB'} = "$root";
$ENV{'WEBMIN_CONFIG'} = "/etc/webmin";
$ENV{'WEBMIN_VAR'} = "/var/webmin";
delete($ENV{'MINISERV_CONFIG'});
chdir("$root/package-updates");
exec("$root/package-updates/update.pl", @ARGV) || die "Failed to run $root/package-updates/update.pl : $!";

相关内容