#!/bin/bash
script=$1
shift

result=$(ps -eo comm,args |egrep 'dpkg|apt'|grep -v grep|wc -l)
if [ "$result" -gt 0 ]; then
    result=$(ps -eo etime,comm,args |egrep 'dpkg|apt'|grep -v grep|tr -s ' '|cut -d ' ' -f2|egrep -v '^[0-9]+:[0-9]+$'|wc -l) # On test si on a moins ou plus qu'1h
    if [ "$result" -gt 0 ]; then
        echo "$script : Unity upgrade detected. But time exec too long"
    else

	    echo "$script : Unity upgrade detected. Reboot isn't possible."
        exit 1
    fi
fi
eval "$script $@"
