I've been given an old rsync script to update some data files on a few different servers... I am trying to understand what directory on the server it gets it's files as the way it seems to refer to the data on the server is:
data_source='random-server.fqdominan.net::Firstlogic'
Not sure what the "::Firstlogic" part with the two :: means. Here is the entire script:
Code:
#!/bin/sh
# Begin user-configurable options #
###################################
# Who can run this script
authorized_user='appdtools'
# From where we rsync the update data
data_source='random-server.fqdominan.net::Firstlogic'
# From where we rsync the rollback data
rollback_data_source='random-server.fqdominan.net::Firstlogic_rollback'
# Where updates will go
data_target='/Firstlogic/postware/dirs'
# How to do the rsync
/usr/bin/tty > /dev/null
if [ $? -eq 1 ]; then
rsync_args='-av --partial --delete --stats'
else
rsync_args='-avP --delete --stats'
fi
# These logs will be cleaned before restart
standardizer_logs='/Firstlogic/log/*.log'
# Command to stop the address standardizer
stop_address_command="${HOME}/tools/irwaddress stop"
# Command to start the address standardizer
start_address_command="${HOME}/tools/irwaddress start"
###################################
# End user-configurable options #
###################################
rsync_test=''
PATH=/bin:/usr/bin; export PATH
case ${1} in
update )
action='UPDATE'
;;
rollback )
do_rollback=true
action='ROLL BACK'
data_source=${rollback_data_source}
;;
test )
rsync_test='-n'
action='TEST'
;;
* )
echo "usage: update_firstlogic [update|rollback|test]"
echo " Update the Firstlogic data files."
echo " With argument 'update', update with new data."
echo " With argument 'rollback', roll back to previous data."
echo " With argument 'test', do an update dry run"
echo " without transferring any files."
exit 1
;;
esac
splash() {
if [ `id -nu` != "${authorized_user}" ]; then
echo "ERROR: You must be user ${authorized_user} to run this script." >&2
exit 1
fi
cat <<END_OF_SPLASH
WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING
You are about to ${action} the Firstlogic address data
in ${data_target}.
If this is not what you want to do, press ^C now!
WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING
END_OF_SPLASH
sleep 10
echo "Continuing"
}
stop_address() { # Stop the address standardizer
${stop_address_command}
if [ $? -gt 0 ]; then
echo "ERROR: Failed to stop the address standardizer" >&2
echo " Bailing out now" >&2
exit 1
fi
}
start_address() { # Start the address standardizer
${start_address_command}
if [ $? -gt 0 ]; then
echo "ERROR: Failed to start the address standardizer" >&2
echo " Bailing out now" >&2
exit 2
fi
}
update_address_data() { # Update the address data
echo "NOTICE: Beginning ${action} of Firstlogic data in ${data_target}."
rsync ${rsync_test} ${rsync_args} ${data_source} ${data_target}
rc=$?
if [ ${rc} -eq 0 ]; then
echo "Success"
else
echo "ERROR: rsync failed with return code ${rc}."
exit ${rc}
fi
}
clean_logs() { # Nullify existing log files
for log_file in ${standardizer_logs}
do
echo "NOTICE: Cleaning log file ${log_file}"
cat /dev/null > ${log_file}
rc=$?
if [ ${rc} -eq 0 ]; then
echo "Success"
else
echo "ERROR: cat failed with return code ${rc}."
fi
done
}
################################################################################
# Here is where we do the "work".
################################################################################
splash # Check user and print warning
if [ "${rsync_test}" == "-n" ]; then
update_address_data # Test the monthly update
else
stop_address # Stop the address standardizer
update_address_data # Load the monthly update
clean_logs # Empty the old log files
start_address # Start the address standardizer
fi
I have not tested this script yet but evidentially it used to work... I just need to find out where to stick the files on random-server.fqdomain.net to test it out. The server it points to no longer has the files on them...