diff --git a/debian/control b/debian/control index 0760e2cde..facedbff2 100644 --- a/debian/control +++ b/debian/control @@ -27,7 +27,7 @@ Depends: ${python3:Depends}, ${misc:Depends} , rspamd, opendkim-tools, postsrsd, procmail, mailutils , redis-server , acl - , git, curl, wget, cron, unzip, jq, bc, at + , git, curl, wget, cron, unzip, jq, bc, at, procps , lsb-release, haveged, fake-hwclock, equivs, lsof, whois Recommends: yunohost-admin , ntp, inetutils-ping | iputils-ping diff --git a/debian/postinst b/debian/postinst index e93845e88..9fb9b9977 100644 --- a/debian/postinst +++ b/debian/postinst @@ -38,6 +38,24 @@ do_configure() { systemctl restart yunohost-api else echo "(Delaying the restart of yunohost-api, this should automatically happen after the end of this upgrade)" + cat << EOF | at -M now >/dev/null 2>&1 +# Wait for apt / dpkg / yunohost to not be up anymore, hence the upgrade finished + +while pgrep -x apt || pgrep -x apt-get || pgrep dpkg || test -e /var/run/moulinette_yunohost.lock; +do + sleep 3 +done + +# Restart yunohost-api, though only if it wasnt already restarted by something else in the last 60 secs + +API_START_TIMESTAMP="\$(date --date="\$(systemctl show yunohost-api | grep ExecMainStartTimestamp= | awk -F= '{print \$2}')" +%s)" + +if [ "\$(( \$(date +%s) - \$API_START_TIMESTAMP ))" -ge 60 ]; +then + echo "restart" >> /var/log/testalex + systemctl restart yunohost-api +fi +EOF fi fi }