ASNMTAP

 view release on metacpan or  search on metacpan

applications/tools/templates/slave/rsync-mirror-distributed-example.sh  view on Meta::CPAN

#    needs to be regularly mirrored. The rsync-mirror-failover-example.conf includes some sample lines.
# ------------------------------------------------------------------------------
#    parameters for /opt/asnmtap/applications/slave/rsync-mirror-failover.sh:
#
#    -c|-C  : config file name
#    -r|-R  : Operating in reverse mode, source and destination fields will be swapped
#    --nodel: no delete (rsync-wrapper-distributed.sh don't allow this for the moment)
#
#  crontab -e
#    */5    * * * * /opt/asnmtap/applications/slave/rsync-mirror-failover.sh > /dev/null  <-- crontab op slave server
#  or
#    0-59/5 * * * * /opt/asnmtap/applications/slave/rsync-mirror-failover.sh > /dev/null  <-- crontab op slave server
#  or
#    1-59/15 * * * * /opt/asnmtap/applications/slave/rsync-mirror-failover-15.sh > /dev/null
#    2-59/10 * * * * /opt/asnmtap/applications/slave/rsync-mirror-failover-10.sh > /dev/null
#    3-59/5  * * * * /opt/asnmtap/applications/slave/rsync-mirror-failover-05.sh > /dev/null
#    4-59/2  * * * * /opt/asnmtap/applications/slave/rsync-mirror-failover-02.sh > /dev/null
#
#  vi /opt/asnmtap/applications/tools/templates/slave/rsync-mirror-failover-tmp.sh
#    #!/bin/bash
#    cd /opt/asnmtap/applications/tools/templates/slave/
#    ./rsync-mirror-failover-example.sh -C rsync-mirror-failover-example.conf
# ------------------------------------------------------------------------------
# Shedule only one rsync-mirror-failover.sh scripts at the same time, unless you have more
# then one of 'rsync-wrapper-distributed.sh' script!  When needed, copy 'rsync-wrapper-distributed.sh' to
# 'rsync-wrapper-distributed-02.sh', 'rsync-wrapper-distributed-05.sh', 'rsync-wrapper-distributed-10.sh'
# & 'rsync-wrapper-distributed-15.sh'
#
# authorized_keys -> command='/opt/asnmtap/applications/master/rsync-wrapper-distributed-02.sh' ...
#                 -> command='/opt/asnmtap/applications/master/rsync-wrapper-distributed-05.sh' ...
#                 -> command='/opt/asnmtap/applications/master/rsync-wrapper-distributed-10.sh' ...
#                 -> command='/opt/asnmtap/applications/master/rsync-wrapper-distributed-15.sh' ...
# ------------------------------------------------------------------------------
# vi hosts.allow
# rsync: <hostname slave failover servers>
#
# vi hosts.deny
# rsync: ALL
# ------------------------------------------------------------------------------
# Setup example:
#
# <slave server>:
#   ssh-keygen -q -t rsa -f /home/asnmtap/.ssh/rsync -N ""
# or
#   ssh-keygen -q -t dsa -f /home/asnmtap/.ssh/rsync -N ""
# 
# chmod go-w   /home/asnmtap/
# chmod 700    /home/asnmtap/.ssh
# chmod go-rwx /home/asnmtap/.ssh/*
# cat /home/asnmtap/.ssh/rsync.pub >> /home/asnmtap/.ssh/authorized_keys
# chmod 600 /home/asnmtap/.ssh/authorized_keys
#
# vi /usr/local/etc/sshd_config or /etc/ssh/sshd_config
# PubkeyAuthentication yes
# PermitEmptyPasswords yes
# 
# <master server>:
# vi authorized_keys
# from="asnmtap.citap.be", command ="/opt/asnmtap/applications/master/rsync-wrapper-distributed-asnmtap.citap.com.sh" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEA5o5rh/yScb8506oLJSPRaKR2PCKfI4U/YOSylN7h8w5z5jIO/6W7qKTwWyJ9lPF3c/D6WM2N4cVkVbcprJq+59vxEPCV9jmD...
#                                                                                                                               ^- rsync.pub
# Testing:
# /opt/asnmtap/applications/slave/rsync-mirror-failover-asnmtap.citap.be.sh
# ------------------------------------------------------------------------------

RMVersion='3.002.003'
echo "rsync-mirror-distributed version $RMVersion"

if [ -f ~/.profile ]; then
  source ~/.profile
fi

if [ -f ~/.bash_profile ]; then
  source ~/.bash_profile
fi

if [ ! "$ASNMTAP_PATH" ]; then
  ASNMTAP_PATH=/opt/asnmtap-3.001.xxx
fi

PidPath="$ASNMTAP_PATH/pid"

Rsync=/usr/local/bin/rsync
RsyncPath=/usr/local/bin/rsync
KeyRsync=/home/asnmtap/.ssh/rsync
ConfFile=rsync-mirror-distributed.conf
ConfPath="$ASNMTAP_PATH/applications/slave"
Delete=''
# AdditionalParams=''                             # --numeric-ids, -H, -v and -R
Reverse=no                                        # 'yes' -> from slave to master
                                                  # 'no'  -> from master to slave

# ------------------------------------------------------------------------------
# DON'T TOUCH BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING!
# ------------------------------------------------------------------------------

cTime='-1'

if [ -f ~/.profile ]; then
  source ~/.profile
fi

if [ -f ~/.bash_profile ]; then
  source ~/.bash_profile
fi

if [ -w "$PidPath" ]; then
  Lockfile="$PidPath/$ConfFile.pid"
else
  echo "Warning: $PidPath is not writable.  Please fix."
  Lockfile="/tmp/$ConfFile.pid"
fi

until [ -z "$1" ]; do
  case "$1" in
    -c|-C)
      if [ -z "$2" ]; then
        echo Missing config file name, exiting >&2
        exit 1
      elif [ ! -e "$ConfPath/$2" ]; then
        echo "Nonexistant config file \"$ConfPath/$2\", exiting" >&2
        exit 1



( run in 1.116 second using v1.01-cache-2.11-cpan-39bf76dae61 )