From df527b15666036f88e11908eb0d981d0e8521782 Mon Sep 17 00:00:00 2001
From: David Hoese <david.hoese@ssec.wisc.edu>
Date: Tue, 30 Jul 2024 12:01:59 -0500
Subject: [PATCH] Try to make scripts relative to ENV

---
 scripts/archive_ceilo.sh      | 4 +++-
 scripts/ceilo_ingest.cfg      | 5 ++++-
 scripts/start_ceilo_ingest.sh | 6 +++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/scripts/archive_ceilo.sh b/scripts/archive_ceilo.sh
index a927a35..3f0d4e6 100755
--- a/scripts/archive_ceilo.sh
+++ b/scripts/archive_ceilo.sh
@@ -1,7 +1,9 @@
 #!/usr/bin/env bash
 # Moves ceilometer data in raw (inst-data) and cache
 
-ENV=/opt/metobs/aoss_ceilo
+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
 
diff --git a/scripts/ceilo_ingest.cfg b/scripts/ceilo_ingest.cfg
index 0701762..77e792a 100644
--- a/scripts/ceilo_ingest.cfg
+++ b/scripts/ceilo_ingest.cfg
@@ -1,3 +1,6 @@
+[DEFAULT]
+root_log_dir = /opt/metobs/aoss_ceilo/log
+log_file = $(root_log_dir)s/ceilo_ingest.log
 
 [ct25k]
 # settings: 24007E1
@@ -46,7 +49,7 @@ formatter = generic
 #    size 20M
 #}
 class = handlers.WatchedFileHandler
-args = ('/opt/metobs/aoss_ceilo/log/ceilo_ingest.log','a')
+args = (%(log_file)s,'a')
 level = NOTSET
 formatter = generic
 
diff --git a/scripts/start_ceilo_ingest.sh b/scripts/start_ceilo_ingest.sh
index c5c7bab..0252fa7 100755
--- a/scripts/start_ceilo_ingest.sh
+++ b/scripts/start_ceilo_ingest.sh
@@ -1,9 +1,13 @@
 #!/usr/bin/env bash
+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})/../../../../)"
+
 NAME=ceilo_ingest
 SCRN=$(screen -list | grep $NAME | awk '{print $1}')
 if [ -n "$SCRN" ]; then
 echo Screen already running: $SCRN
 else
-screen -S $NAME -d -m /opt/metobs/aoss_ceilo/bin/python -m aossceilo.ingest -c /opt/metobs/aoss_ceilo/repos/git/AossCeilo/scripts/$NAME.cfg
+screen -S $NAME -d -m ${ENV}/bin/python -m aossceilo.ingest -c ${ENV}/repos/git/AossCeilo/scripts/$NAME.cfg
 echo Started in screen $(screen -list | grep $NAME | awk '{print $1}')
 fi
-- 
GitLab