X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-checks%2Fsbin%2Fdsa-update-apt-status;h=c506feaf2f87841573fcbec95a04b2111ee40abc;hb=eece83df9a12e701d8b9557344ca9985c60c47e1;hp=8a278ce7e757d9f400c82c917060d21cde7434ec;hpb=95d28669b9ad5f8d3309b3b00f9435aedb76395c;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-checks/sbin/dsa-update-apt-status b/dsa-nagios-checks/sbin/dsa-update-apt-status index 8a278ce..c506fea 100755 --- a/dsa-nagios-checks/sbin/dsa-update-apt-status +++ b/dsa-nagios-checks/sbin/dsa-update-apt-status @@ -22,7 +22,8 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. UPDATE_RUNS=3 -STATUS=/var/cache/dsa/nagios/apt +STATUSDIR=/var/cache/dsa/nagios +STATUS="${STATUSDIR}"/apt SLEEP_MAX=$(( 15 * 60 )) MAX_AGE=$(( 23 * 60 * 60 )) @@ -50,6 +51,8 @@ run_required() { return $norun } +mkdir -p "${STATUSDIR}" + # do stuff only when required, or when asked to if [ "${1:-""}" != "-f" ] ; then run_required || exit 0 @@ -63,7 +66,7 @@ fi # run apt-get update, retry a few times if it fails count=0 while [ "$count" -lt "$UPDATE_RUNS" ]; do - apt-get update -qq >/dev/null >&2 + flock -e /var/lib/apt/lists apt-get update -qq >/dev/null >&2 if [ "$?" = "0" ]; then break; fi sleep $(( $RANDOM % 600 )) count="$(( $count + 1 ))"