cat apt.conf.d/80upgradehook
DPkg::Post-Invoke {"/etc/apt/myhook/docker.sh";};
root@debian-home:/etc/apt# cat myhook/docker.sh
function update_docker(){
local r="ExecStart=\/usr\/bin\/dockerd \-H fd:\/\/ --containerd=\/run\/containerd\/containerd.sock" # old
local u="ExecStart=\/usr\/bin\/dockerd -g \/home\/docker_containers -H unix:\/\/" # new
local f="/lib/systemd/system/docker.service" # config file
local wrcmd="systemctl daemon-reload" # restart services
local prcmd1="if [[ -f /etc/init.d/docker ]];then /etc/init.d/docker restart;fi"
local prcmd2="if [[ -f /var/run/docker.sock ]];then chmod 666 /var/run/docker.sock;fi"
local prcmd3="if [[ -f ${f} ]];then sed -i -e \"s/${r}/${u}/g\";fi"
# patch it
echo "$0: Patching $f..."
# sed -i "s/$r/$u/g" $f
#if [[ -f ${f} ]];then sed -i -e "s/${r}/${u}/g" ${f};fi
# restart it
${wrcmd}
${prcmd3}
${prcmd1}
${prcmd2}
}
#docker_install
update_docker
Пишет, что не может найти команду if. Запускается всё это через ansible