From a054fb3a6807f58d951cbab9787853308837b7ec Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Mon, 26 Nov 2018 12:49:34 +0100 Subject: [PATCH] Create directory if not existing --- dsa-nagios-checks/sbin/dsa-update-apt-status | 7 ++++++- dsa-nagios-checks/sbin/dsa-update-unowned-file-status | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dsa-nagios-checks/sbin/dsa-update-apt-status b/dsa-nagios-checks/sbin/dsa-update-apt-status index 8eebe1a..7919f71 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,10 @@ run_required() { return $norun } +if [ ! -d "${STATUSDIR}" ]; then + mkdir -p "${STATUSDIR}" +fi + # do stuff only when required, or when asked to if [ "${1:-""}" != "-f" ] ; then run_required || exit 0 diff --git a/dsa-nagios-checks/sbin/dsa-update-unowned-file-status b/dsa-nagios-checks/sbin/dsa-update-unowned-file-status index 89ac5f6..cc4e812 100755 --- a/dsa-nagios-checks/sbin/dsa-update-unowned-file-status +++ b/dsa-nagios-checks/sbin/dsa-update-unowned-file-status @@ -22,7 +22,12 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CUTOFF=40 -STATUS=/var/cache/dsa/nagios/nouser +STATUSDIR=/var/cache/dsa/nagios +STATUS="${STATUSDIR}"/nouser + +if [ ! -d "${STATUSDIR}" ]; then + mkdir -p "${STATUSDIR}" +fi tmp=`tempfile` trap "rm -f '$tmp'" exit -- 2.20.1