From b8cfc2211fdae0e10180faf711f7095d25df6393 Mon Sep 17 00:00:00 2001
From: davidh-ssec <david.hoese@ssec.wisc.edu>
Date: Tue, 3 Jun 2014 12:46:36 -0500
Subject: [PATCH] Added some error checking to the 2 archive scripts. Added a
 .bash_profile init script Added an upstart/init script.

---
 circus_init.conf             | 13 +++++++++++++
 init.sh                      |  8 ++++++++
 scripts/archive_aeri.sh      |  2 +-
 scripts/archive_hsrl.sh      |  2 +-
 scripts/sparc_archive_env.sh |  4 ++++
 5 files changed, 27 insertions(+), 2 deletions(-)
 create mode 100644 circus_init.conf
 create mode 100644 init.sh

diff --git a/circus_init.conf b/circus_init.conf
new file mode 100644
index 0000000..2ec0460
--- /dev/null
+++ b/circus_init.conf
@@ -0,0 +1,13 @@
+# init/upstart file to start circus daemon
+# Currently runs circus as root. Attempts to run as sparc user from upstart failed.
+# Copy file to /etc/init/circus.conf
+# Important upstart commands:
+# $ initctl status circus
+# $ stop circus
+# $ start circus
+
+start on started sshd
+stop on runlevel[016]
+
+respawn
+exec /opt/circus-env/bin/circusd /etc/circus.ini
diff --git a/init.sh b/init.sh
new file mode 100644
index 0000000..9d71fb7
--- /dev/null
+++ b/init.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+# Environment script to be loaded from .bash_profile. Add the following lines to "~sparc/.bash_profile":
+# if [ -f ~/repos/git/sparchive/init.sh ]; then
+#     . ~/repos/git/sparchive/init.sh
+# fi
+
+export PATH=$HOME/repos/git/sparchive/scripts:$PATH
+alias circusctl="/opt/circus-env/bin/circusctl --endpoint=ipc:///var/circus/endpoint"
\ No newline at end of file
diff --git a/scripts/archive_aeri.sh b/scripts/archive_aeri.sh
index db350ac..7d19cbb 100755
--- a/scripts/archive_aeri.sh
+++ b/scripts/archive_aeri.sh
@@ -13,7 +13,7 @@ RSYNC_OPTIONS="-L --partial --inplace --append --archive -vv --progress --timeou
 # Shouldn't need ssh inside the SPARC, let's just do anonymous
 # FIXME: Get correct mount point
 log_msg "Pulling data from AERI: ${AERI_USER}@${AERI_HOST}"
-rsync $RSYNC_OPTIONS ${AERI_USER}@${AERI_HOST}:/cygdrive/c/ftp/AE$DATE $AERI_BASE_DIR/
+rsync $RSYNC_OPTIONS ${AERI_USER}@${AERI_HOST}:/cygdrive/c/ftp/AE$DATE $AERI_BASE_DIR/ || log_fatal_msg "Rsync failed"
 
 # Push the new data
 #log_msg "Pushing data to SSEC: ${AERI_BASE_DIR} -> ${PUSH_USER}@${PUSH_HOST}:${PUSH_BASE_DIR}/"
diff --git a/scripts/archive_hsrl.sh b/scripts/archive_hsrl.sh
index fcb63cd..79df6fd 100755
--- a/scripts/archive_hsrl.sh
+++ b/scripts/archive_hsrl.sh
@@ -14,7 +14,7 @@ RSYNC_OPTIONS="-L --partial --inplace --append --archive -vv --progress --timeou
 # Shouldn't need ssh inside the SPARC, let's just do anonymous
 # FIXME: Get correct mount point
 log_msg "Pulling data from HSRL: ${HSRL_USER}@${HSRL_HOST}"
-rsync $RSYNC_OPTIONS ${HSRL_USER}@${HSRL_HOST}:/cygdrive/c/ftp/AE$DATE $HSRL_BASE_DIR/
+rsync $RSYNC_OPTIONS ${HSRL_USER}@${HSRL_HOST}:/cygdrive/c/ftp/AE$DATE $HSRL_BASE_DIR/ || log_fatal_msg "Rsync failed"
 
 # Push the new data
 #log_msg "Pushing data to SSEC: ${HSRL_BASE_DIR} -> ${PUSH_USER}@${PUSH_HOST}:${PUSH_BASE_DIR}/"
diff --git a/scripts/sparc_archive_env.sh b/scripts/sparc_archive_env.sh
index e4116f6..8f1c60c 100755
--- a/scripts/sparc_archive_env.sh
+++ b/scripts/sparc_archive_env.sh
@@ -9,6 +9,10 @@ if [ -z "$SPARC_REV" ]; then
     log_msg() {
         echo "$0 : `date -u +%Y-%m-%dT%H:%M:%S` : $1"
     }
+    log_fatal_msg() {
+        echo "$0 : `date -u +%Y-%m-%dT%H:%M:%S` : FATAL : $1"
+        exit 1
+    }
     log_msg "Loading SPARC environment"
 
     # Base directory of all archived data
-- 
GitLab