From b49febb27ecf668363950348f5c8d489f73ad5cb Mon Sep 17 00:00:00 2001
From: David Hoese <david.hoese@ssec.wisc.edu>
Date: Tue, 30 Jul 2024 20:37:59 -0500
Subject: [PATCH] Cleanup log directory setup in archive script

---
 README.rst               | 4 ++--
 scripts/archive_ceilo.sh | 3 +--
 scripts/metobs_config.sh | 8 ++++++--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/README.rst b/README.rst
index 11e93cc..a81256c 100644
--- a/README.rst
+++ b/README.rst
@@ -36,8 +36,8 @@ directory or ``/opt/miniforge_YYYYMMDD`` directory.
 2. Clone the git repository into the environment and other setup::
 
     cd /opt/metobs/aoss_ceilo
-    sudo mkdir -p repos/git log locks
-    sudo chown metobs:metobsgrp log locks
+    sudo mkdir -p repos/git log lock
+    sudo chown metobs:metobsgrp log lock
     sudo git clone "https://gitlab.ssec.wisc.edu/metobs/AossCeilo.git" repos/git/AossCeilo
     sudo ln -s repos/git/AossCeilo/scripts .
     sudo git clone "https://gitlab.ssec.wisc.edu/metobs/MetObsCommon.git" repos/git/MetObsCommon
diff --git a/scripts/archive_ceilo.sh b/scripts/archive_ceilo.sh
index 3f0d4e6..8225f9d 100755
--- a/scripts/archive_ceilo.sh
+++ b/scripts/archive_ceilo.sh
@@ -4,10 +4,9 @@
 SCRIPT_HOME="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 # Assumes this script is in /opt/*/aoss_ceilo*/repos/git/AossCeilo/scripts/
 ENV="$(realpath $(realpath ${SCRIPT_HOME})/../../../../)"
-LOGDIR=$ENV/log
-LOCK=$ENV/lock/$(basename $0).lock
 
 source $ENV/scripts/metobs_config.sh
+LOCK=${LOCKDIR}/$(basename $0).lock
 
 (
     flock -x -n 200 || exit $?
diff --git a/scripts/metobs_config.sh b/scripts/metobs_config.sh
index 28adb5a..4643bb1 100644
--- a/scripts/metobs_config.sh
+++ b/scripts/metobs_config.sh
@@ -1,6 +1,10 @@
 #
 # These values should override values used in python or bash scripts
 #
+SCRIPT_HOME="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+# Assumes this script is in /opt/*/aoss_ceilo*/repos/git/AossCeilo/scripts/
+ENV="$(realpath $(realpath ${SCRIPT_HOME})/../../../../)"
+
 # where the ceilo ascii files get pushed to
 DATA_ROOT=${DATA_ROOT:-"/data1"}
 export CEILO_INCOMING_DIR="${DATA_ROOT}/incoming/aoss/ceilo"
@@ -18,9 +22,9 @@ export CEILO_NC_LOC=$CEILO_CACHE_DIR
 
 
 # Directory where logs will be stored
-export LOGDIR="${DATA_ROOT}/log"
+export LOGDIR="${ENV}/log"
 # Directory where lock files will be stored
-export LOCKDIR="${DATA_ROOT}/lock"
+export LOCKDIR="${ENV}/lock"
 # Directory where work files can be placed (inside a separate temp directory)
 export WORKDIR="${DATA_ROOT}/tmp"
 
-- 
GitLab