#!/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 INDEX=$1 export UNISON=/var/lib/unison if [ "$INDEX" == "" ] then if [ "$UNISON_DIR_N" == '0' ] then mecho "" mecho -error "Error: No replication directory configured!" mecho "" exit 1 fi mecho "" mecho -info "Select directory to synchronize" mecho "" techo begin 4 22 25 25 techo row -info No -info Host -info Local-Dir -info Remote-Dir idx="1" while [ "$idx" -le "$UNISON_DIR_N" ] do eval netsync='$UNISON_DIR_'$idx'_NETSYNC' eval host='$UNISON_DIR_'$idx'_HOST' eval localdir='$UNISON_DIR_'$idx'_LOCAL' eval remotedir='$UNISON_DIR_'$idx'_REMOTE' remotedir=$(echo "$remotedir" | sed 's/\\/\\\\/g') if [ "$netsync" == "yes" ] then techo row "$idx" "$host" "$localdir" "$remotedir" else techo row "$idx" "(local)" "$localdir" "$remotedir" fi idx=`/usr/bin/expr $idx + 1` done techo end idx="1" mecho idx=`/var/install/bin/ask "Select (0 = cancel)" "$idx" "0-$UNISON_DIR_N"` if [ "$idx" -eq 0 ] then mecho "" mecho -info "Selection canceled!" mecho "" exit 0 fi PROFILE="replica$idx" RUN="$PROG $PROFILE" eval PRESCRIPT='$UNISON_DIR_'$idx'_PRERUN' eval POSTSCRIPT='$UNISON_DIR_'$idx'_POSTRUN' mecho "" mecho -info "Manual synchronisation started..." else PROFILE="replica$INDEX" eval PRESCRIPT='$UNISON_DIR_'$INDEX'_PRERUN' eval POSTSCRIPT='$UNISON_DIR_'$INDEX'_POSTRUN' RUN="$PROG $PROFILE -batch" fi { echo "" echo "-----------------------------------------------------------------------" echo "Unison interactive synchronisation started $(date)" echo "-----------------------------------------------------------------------" } > /tmp/unison-header-$$.log # 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 exit 1 fi fi $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 result='0' 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 result='1' 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 anykey exit "$result"