# 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 ))
return $norun
}
+mkdir -p "${STATUSDIR}"
+
# do stuff only when required, or when asked to
if [ "${1:-""}" != "-f" ] ; then
run_required || exit 0
# 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 ))"