#! /bin/bash

# This file tracks changes in shio configurations

# get to the correct folder
HOME=/home/tidepool-deploy/shio
cd $HOME
FOLDER=/home/tidepool-deploy/shio/shiostatus

# make sure we have a shiostatus folder
if [ ! -d shiostatus ]; then
    mkdir shiostatus
fi

$HOME/bin/shio slots show >$FOLDER/latest.shiostatus

if $(shasum --check $FOLDER/latest.checksum --status); then
    echo "updating!"
    shasum $FOLDER/latest.shiostatus >$FOLDER/latest.checksum
    $HOME/saveServers.sh all $FOLDER/latest.restore
    ts=$(date "+%Y-%m-%d-%H-%M-%S")
    cp $FOLDER/latest.shiostatus $FOLDER/$ts.shiostatus
    cp $FOLDER/latest.restore $FOLDER/$ts.restore
else
    # we're good
    echo "not updating"
fi


#! /bin/bash

# This file tracks changes in shio configurations

# get to the correct folder
HOME=/home/tidepool-deploy/shio
cd $HOME
FOLDER=/home/tidepool-deploy/shio/shiostatus

# make sure we have a shiostatus folder
if [ ! -d shiostatus ]; then
    mkdir shiostatus
fi

$HOME/bin/shio slots show >$FOLDER/latest.shiostatus

if $(shasum --check $FOLDER/latest.checksum --status); then
    # we're good
    echo "not updating"
else
    echo "updating!"
    shasum $FOLDER/latest.shiostatus >$FOLDER/latest.checksum
    $HOME/saveServers.sh all $FOLDER/latest.restore
    ts=$(date "+%Y-%m-%d-%H-%M-%S")
    cp $FOLDER/latest.shiostatus $FOLDER/$ts.shiostatus
    cp $FOLDER/latest.restore $FOLDER/$ts.restore
fi


Revert "Swap sense of shasum check"
Revert "Swap sense of shasum check"

This reverts commit e3aa3562a6d4b262ffe4b2ebc2b52e151c1e1c6d.
