#!/bin/bash ## Copyright (C) 2012 - 2023 ENCRYPTED SUPPORT LP ## See the file COPYING for copying conditions. sigterm_trap() { if [ "$lastpid" = "" ]; then exit 143 fi ps -p "$lastpid" >/dev/null 2>&1 if [ ! "$?" = "0" ]; then ## Already terminated. exit 143 fi kill -s sigterm "$lastpid" exit 143 } trap "sigterm_trap" SIGTERM SIGINT [ -n "$timeout_after" ] || timeout_after="600" [ -n "$kill_after" ] || kill_after="10" timeout \ --kill-after="$kill_after" \ "$timeout_after" \ apt-get update --error-on=any "$@" & lastpid="$!" wait "$lastpid" exit "$?"