forked from ungleich-public/cdist
__apt_unattended_upgrades: rewrite manifest, add more parameters
This commit is contained in:
parent
68e5502fce
commit
cd24a806e7
2 changed files with 63 additions and 29 deletions
|
@ -34,39 +34,61 @@ APT::Periodic::Update-Package-Lists "1";
|
||||||
APT::Periodic::Unattended-Upgrade "1";
|
APT::Periodic::Unattended-Upgrade "1";
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# lets not write into upstream 50unattended-upgrades file,
|
conf='# this file is managed by cdist'
|
||||||
# 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" ]
|
if [ -f "$__object/parameter/mail" ]
|
||||||
then
|
then
|
||||||
mail="$( cat "$__object/parameter/mail" )"
|
conf="$(
|
||||||
else
|
printf \
|
||||||
mail=''
|
'%s\nUnattended-Upgrade::Mail "%s";\n' \
|
||||||
|
"$conf" \
|
||||||
|
"$( cat "$__object/parameter/mail" )"
|
||||||
|
)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$mail" ]
|
|
||||||
then
|
|
||||||
if [ -f "$__object/parameter/mail-on-error" ]
|
if [ -f "$__object/parameter/mail-on-error" ]
|
||||||
then
|
then
|
||||||
mail_on_error='true'
|
conf="$(
|
||||||
else
|
printf \
|
||||||
mail_on_error='false'
|
'%s\nUnattended-Upgrade::MailOnlyOnError "true";\n' \
|
||||||
|
"$conf"
|
||||||
|
)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
__file "$ml_conf" \
|
if [ -f "$__object/parameter/no-auto-fix" ]
|
||||||
--owner root \
|
then
|
||||||
--group root \
|
conf="$(
|
||||||
--mode 644 \
|
printf \
|
||||||
--source - << EOF
|
'%s\nUnattended-Upgrade::AutoFixInterruptedDpkg "false";\n' \
|
||||||
Unattended-Upgrade::Mail "$mail";
|
"$conf"
|
||||||
Unattended-Upgrade::MailOnlyOnError "$mail_on_error";
|
)"
|
||||||
EOF
|
fi
|
||||||
|
|
||||||
else
|
if [ -f "$__object/parameter/no-minimal-steps" ]
|
||||||
__file "$ml_conf" --state absent
|
then
|
||||||
|
conf="$(
|
||||||
|
printf \
|
||||||
|
'%s\nUnattended-Upgrade::MinimalSteps "false";\n' \
|
||||||
|
"$conf"
|
||||||
|
)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/on-shutdown" ]
|
||||||
|
then
|
||||||
|
conf="$(
|
||||||
|
printf \
|
||||||
|
'%s\nUnattended-Upgrade::InstallOnShutdown "true";\n' \
|
||||||
|
"$conf"
|
||||||
|
)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/reboot" ]
|
||||||
|
then
|
||||||
|
conf="$(
|
||||||
|
printf \
|
||||||
|
'%s\nUnattended-Upgrade::Automatic-Reboot "true";\n' \
|
||||||
|
"$conf"
|
||||||
|
)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$__object/parameter/blacklist" ]
|
if [ -f "$__object/parameter/blacklist" ]
|
||||||
|
@ -79,14 +101,22 @@ then
|
||||||
done \
|
done \
|
||||||
< "$__object/parameter/blacklist"
|
< "$__object/parameter/blacklist"
|
||||||
|
|
||||||
bl="$( printf '%s\n}' "$bl" )"
|
conf="$( printf '%s\n%s\n}\n' "$conf" "$bl" )"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$bl" \
|
# lets not write into upstream 50unattended-upgrades file,
|
||||||
| __file "$bl_conf" \
|
# but use our own config files to avoid clashes
|
||||||
|
|
||||||
|
conf_file='/etc/apt/apt.conf.d/51unattended-upgrades-cdist'
|
||||||
|
|
||||||
|
if [ "$( echo "$conf" | wc -l )" -gt 1 ]
|
||||||
|
then
|
||||||
|
echo "$conf" \
|
||||||
|
| __file "$conf_file" \
|
||||||
--owner root \
|
--owner root \
|
||||||
--group root \
|
--group root \
|
||||||
--mode 644 \
|
--mode 644 \
|
||||||
--source -
|
--source -
|
||||||
else
|
else
|
||||||
__file "$bl_conf" --state absent
|
__file "$conf_file" --state absent
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
mail-on-error
|
mail-on-error
|
||||||
|
no-auto-fix
|
||||||
|
no-minimal-steps
|
||||||
|
on-shutdown
|
||||||
|
reboot
|
||||||
|
|
Loading…
Reference in a new issue