You could possibly offer a configure script (I just added something similar to this in my “BSD Pot template”)?
touch configure
Copy below to the file.
chmod +x ./configure
NOTE: coded quickly (one pass over).
#!/bin/sh
#: configure --
# Reads
# Establish some default values.
REMOTE_SERVER="192.168.1.250"
MODE="PULL"
# Find the name of the config file.
_cfg_name="$(find . -type f -name 'config.sh')"
# Check to see if file exists.
[ "$_cfg_name" ] || echo "*ERROR* Unable to locate config.sh, exiting..." && exit
# Allow the user to specify the values by calling this script.
for arg in "$@"; do
case "$arg" in
--REMOTE_SERVER=*)
REMOTE_SERVER=`echo \"$arg\" | sed 's/--REMOTE_SERVER=//'`
;;
--MODE=*)
MODE=`echo \"$arg\" | sed 's/--MODE=//'`
;;
--help)
echo 'usage: ./configure [options]'
echo 'options:'
echo ' --REMOTE_SERVER=<ip number>: IP number of remote server'
echo ' --MODE=<PULL/PUSH>'
echo 'all invalid options are silently ignored'
exit 0
;;
esac
done
sed -i '' "s/^REMOTE_SERVER.*/REMOTE_SERVER=$REMOTE_SERVER/g" $_cfg_name
sed -i '' "s/^MODE.*/MODE=$MODE/g" $_cfg_name
echo 'configuration complete.'
I have now also included some checks to exit the script under certain conditions, including absence of snapshots on source and destination and mismatch of snapshots.
I’ve also included a small script that will check the latest log file for the status (which is always listed at the bottom of the log file) and in the case of XigmaNAS, can be called via email task and sent to your email.
Log directory now also defaults to script directory.