#!/bin/sh #----------------------------------------------------------------------------- # /var/install/bin/unison-tools-manual # # Copyright (c) 2005 Daniel Vogel # # Creation: 05.07.2005 dv # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #----------------------------------------------------------------------------- #include eislib . /var/install/include/eislib . /etc/config.d/unison PROG=/usr/bin/unison export UNISON=/var/lib/unison if [ "$UNISON_DIR_N" == '0' ] then mecho "" mecho -error "Error: No replication directory configured!" mecho "" exit 1 fi mecho "" mecho -info "Batch synchronisation started..." { echo "" echo "-----------------------------------------------------------------------" echo "Unison manual batch synchronisation started $(date)" echo "-----------------------------------------------------------------------" } > /tmp/unison-header-$$.log idx="1" while [ "$idx" -le "$UNISON_DIR_N" ] do error='0' PROFILE="replica$idx" eval PRESCRIPT='$UNISON_DIR_'$idx'_PRERUN' eval POSTSCRIPT='$UNISON_DIR_'$idx'_POSTRUN' # execute pre script if [ ! -z "$PRESCRIPT" ] then ${PRESCRIPT} 2>> /tmp/unison-header-$$.log >> /tmp/unison-header-$$.log if [ "$?" != "0" ] then echo "failed to execute: ${PRESCRIPT}" echo "failed to execute: ${PRESCRIPT}" >> /tmp/unison-header-$$.log error='1' fi fi if [ "$error" == "0" ] then RUN="$PROG $PROFILE -batch" $RUN -logfile /tmp/unison-$$.log unison_err="$?" if [ -f /tmp/unison-header-$$.log ] then cat /tmp/unison-header-$$.log >> /var/log/unison.log rm -f /tmp/unison-header-$$.log fi if [ "$unison_err" == "0" ] then if [ -f "/tmp/unison-$$.log" ] then cat /tmp/unison-$$.log >> /var/log/unison.log rm /tmp/unison-$$.log else { echo "" echo "No differences where found. Directories are identical!" echo "" } >> /var/log/unison.log fi else echo "Unison terminated with exit code \"$?\"!" >> /var/log/unison.log if [ -f "/tmp/unison-$$.log" ] then cat /tmp/unison-$$.log >> /var/log/unison.log rm /tmp/unison-$$.log fi fi # execute post script if [ ! -z "$POSTSCRIPT" ] then ${POSTSCRIPT} 2>> /var/log/unison.log >> /var/log/unison.log if [ "$?" != "0" ] then echo "failed to execute: $POSTSCRIPT" echo "failed to execute: $POSTSCRIPT" >> /var/log/unison.log fi fi fi idx=`/usr/bin/expr $idx + 1` done mecho -info "Done." exit 0