__apt_unattended_upgrades: initial commit

This commit is contained in:
ander 2020-01-04 16:36:44 +02:00
parent bc1990c7c8
commit 94e32dcd78
5 changed files with 77 additions and 0 deletions

View file

@ -0,0 +1,74 @@
#!/bin/sh -e
__package unattended-upgrades
# in normal circumstances 20auto-upgrades is managed
# by debconf and it can only contain these lines
# https://wiki.debian.org/UnattendedUpgrades
require='__package/unattended-upgrades' \
__file /etc/apt/apt.conf.d/20auto-upgrades \
--owner root \
--group root \
--mode 644 \
--source - << EOF
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
EOF
# lets not write into upstream 50unattended-upgrades file,
# but use our own config files to avoid clashes
ml_conf='/etc/apt/apt.conf.d/51unattended-upgrades-mail'
bl_conf='/etc/apt/apt.conf.d/51unattended-upgrades-blacklist'
if [ -f "$__object/parameter/mail" ]
then
mail="$( cat "$__object/parameter/mail" )"
else
mail=''
fi
if [ -n "$mail" ]
then
if [ -f "$__object/parameter/mail-on-error" ]
then
mail_on_error='true'
else
mail_on_error='false'
fi
__file "$ml_conf" \
--owner root \
--group root \
--mode 644 \
--source - << EOF
Unattended-Upgrade::Mail "$mail";
Unattended-Upgrade::MailOnlyOnError "$mail_on_error";
EOF
else
__file "$ml_conf" --state absent
fi
if [ -f "$__object/parameter/blacklist" ]
then
bl='Unattended-Upgrade::Package-Blacklist {';
while read -r l
do
bl="$( printf '%s\n"%s";\n' "$bl" "$l" )"
done \
< "$__object/parameter/blacklist"
bl="$( printf '%s\n}' "$bl" )"
echo "$bl" \
| __file "$bl_conf" \
--owner root \
--group root \
--mode 644 \
--source -
else
__file "$bl_conf" --state absent
fi

View file

@ -0,0 +1 @@
mail-on-error

View file

@ -0,0 +1 @@
mail

View file

@ -0,0 +1 @@
blacklist