]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[OPENSM] remove Linux scripts; add Windows osmtest regression script.
authorStan Smith <stan.smith@intel.com>
Thu, 27 May 2010 18:00:30 +0000 (18:00 +0000)
committerStan Smith <stan.smith@intel.com>
Thu, 27 May 2010 18:00:30 +0000 (18:00 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@2817 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/ulp/opensm/user/scripts/opensm.init.in [deleted file]
trunk/ulp/opensm/user/scripts/opensm.logrotate [deleted file]
trunk/ulp/opensm/user/scripts/opensm.sysconfig [deleted file]
trunk/ulp/opensm/user/scripts/osm-regress.bat [new file with mode: 0644]
trunk/ulp/opensm/user/scripts/redhat-opensm.init.in [deleted file]
trunk/ulp/opensm/user/scripts/sldd.sh.in [deleted file]

diff --git a/trunk/ulp/opensm/user/scripts/opensm.init.in b/trunk/ulp/opensm/user/scripts/opensm.init.in
deleted file mode 100644 (file)
index 997dce5..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/bin/bash\r
-#\r
-# opensm:              Manage OpenSM\r
-#\r
-# chkconfig: - 09 91\r
-# description:  Manage OpenSM\r
-#\r
-### BEGIN INIT INFO\r
-# Provides: opensm\r
-# Required-Start: $syslog\r
-# Default-Start: none\r
-# Default-Stop: 0 1 6\r
-# Description:  Manage OpenSM\r
-### END INIT INFO\r
-#\r
-# Copyright (c) 2008 Voltaire, Inc. All rights reserved.\r
-# Copyright 2006 PathScale, Inc.  All Rights Reserved.\r
-#\r
-# This Software is licensed under one of the following licenses:\r
-#\r
-# 1) under the terms of the "Common Public License 1.0" a copy of which is\r
-#    available from the Open Source Initiative, see\r
-#    http://www.opensource.org/licenses/cpl.php.\r
-#\r
-# 2) under the terms of the "The BSD License" a copy of which is\r
-#    available from the Open Source Initiative, see\r
-#    http://www.opensource.org/licenses/bsd-license.php.\r
-#\r
-# 3) under the terms of the "GNU General Public License (GPL) Version 2" a\r
-#    copy of which is available from the Open Source Initiative, see\r
-#    http://www.opensource.org/licenses/gpl-license.php.\r
-#\r
-# Licensee has the right to choose one of the above licenses.\r
-#\r
-# Redistributions of source code must retain the above copyright\r
-# notice and one of the license notices.\r
-#\r
-# Redistributions in binary form must reproduce both the above copyright\r
-# notice, one of the license notices in the documentation\r
-# and/or other materials provided with the distribution.\r
-\r
-prefix=@prefix@\r
-exec_prefix=@exec_prefix@\r
-\r
-# Source function library.\r
-if [[ -s /etc/init.d/functions ]]; then\r
-    . /etc/init.d/functions\r
-    rc_status() { :; }\r
-    rc_exit() { exit $RETVAL; }\r
-fi\r
-if [[ -s /etc/rc.status ]]; then\r
-    . /etc/rc.status\r
-    failure() { rc_status -v; }\r
-    success() { rc_status -v; }\r
-fi\r
-\r
-CONFIG=@sysconfdir@/sysconfig/opensm\r
-if [[ -s $CONFIG ]]; then\r
-    . $CONFIG\r
-fi\r
-\r
-start () {\r
-    echo -n "Starting opensm: "\r
-    @sbindir@/opensm --daemon $OPTIONS > /dev/null\r
-    if [[ $RETVAL -eq 0 ]]; then\r
-        touch /var/lock/subsys/opensm\r
-        success\r
-    else\r
-        failure\r
-    fi\r
-    echo\r
-}\r
-\r
-stop () {\r
-    echo -n "Shutting down opensm: "\r
-    killproc opensm\r
-    if [[ $RETVAL -eq 0 ]]; then\r
-        rm -f /var/lock/subsys/opensm\r
-        success\r
-    else\r
-        failure\r
-    fi\r
-    echo\r
-}\r
-\r
-Xstatus () {\r
-       pid="`pidof opensm`"\r
-       ret=$?\r
-       if [ $ret -eq 0 ] ; then\r
-               echo "OpenSM is running... pid=$pid"\r
-       else\r
-               echo "OpenSM is not running."\r
-       fi\r
-}\r
-\r
-restart() {\r
-    stop\r
-    start\r
-}\r
-\r
-# See how we were called.\r
-case "$1" in\r
-    start)\r
-       start\r
-       ;;\r
-    stop)\r
-       stop\r
-       ;;\r
-    status)\r
-        Xstatus\r
-       ;;\r
-    restart | force-reload | reload)\r
-       restart\r
-       ;;\r
-    try-restart | condrestart)\r
-       [ -e /var/lock/subsys/opensm ] && restart\r
-       ;;\r
-    resweep)\r
-       killall -HUP opensm\r
-        RETVAL=$?\r
-       ;;\r
-    rotatelog)\r
-       killall -USR1 opensm\r
-        RETVAL=$?\r
-       ;;\r
-    *)\r
-       echo $"Usage: $0 {start|stop|status|restart|reload|condrestart|resweep|rotatelog}"\r
-       RETVAL=1\r
-       ;;\r
-esac\r
-\r
-_rc_status_all=$RETVAL\r
-rc_exit\r
diff --git a/trunk/ulp/opensm/user/scripts/opensm.logrotate b/trunk/ulp/opensm/user/scripts/opensm.logrotate
deleted file mode 100644 (file)
index ee5a455..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-/var/log/opensm.log {\r
-    missingok\r
-    notifempty\r
-    copytruncate\r
-    weekly\r
-    compress\r
-}\r
diff --git a/trunk/ulp/opensm/user/scripts/opensm.sysconfig b/trunk/ulp/opensm/user/scripts/opensm.sysconfig
deleted file mode 100644 (file)
index 2d72350..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-# It will be used for sldd.sh\r
-OSM_HOSTS=""\r
diff --git a/trunk/ulp/opensm/user/scripts/osm-regress.bat b/trunk/ulp/opensm/user/scripts/osm-regress.bat
new file mode 100644 (file)
index 0000000..9229f91
--- /dev/null
@@ -0,0 +1,45 @@
+@echo off\r
+setlocal\r
+\r
+rem requires cmd.exe /E /V, make it so... JLP\r
+set F=on\r
+set F=off\r
+if "!F!" == "off" goto OK\r
+\r
+%comspec% /E:on /V:on /C %0 %1 %2\r
+exit /B %ERRORLEVEL%\r
+\r
+:OK\r
+\r
+if "%1" == "" (\r
+:usage\r
+    echo usage: osm-regress results-filename {exit-on-error}\r
+    exit /B 1\r
+)\r
+if exist "%1"  del /Q "%1"\r
+\r
+rem if not exist "osmtest.dat" (\r
+rem    echo missing inventory file .\osmtest.dat ?\r
+rem    exit /B 1\r
+rem )\r
+\r
+rem set T=..\..\..\bin\user\objchk_wlh_amd64\amd64\osmtest.exe\r
+set T=osmtest.exe\r
+\r
+rem Event forwarding test 'e' is not yet implemented [3.3.5]\r
+\r
+set TESTS="c" "v" "m -M1" "m -M2" "m -M3" "m -M4" "f -s1" "f -s2" "f -s3" "f -s4" "s" "a"\r
+rem set TESTS="c" "v" "a" "f -s1" "f -s2" "f -s3" "f -s4" "s"\r
+\r
+for %%t in ( %TESTS% ) DO (\r
+    echo TEST: osmtest -f %%~t\r
+    echo TEST: osmtest -f %%~t >> %1\r
+    %T% -f %%~t >> %1\r
+    if !ERRORLEVEL! NEQ 0  (\r
+      echo Error !ERRORLEVEL! reported in osmtest -f %%~t ?\r
+      if Not "%2" == ""  exit /B 1\r
+    )\r
+    echo. >> %1\r
+    echo    PASS.\r
+)\r
+endlocal\r
diff --git a/trunk/ulp/opensm/user/scripts/redhat-opensm.init.in b/trunk/ulp/opensm/user/scripts/redhat-opensm.init.in
deleted file mode 100644 (file)
index 71d95d5..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-#!/bin/bash\r
-#\r
-# Bring up/down opensm\r
-#\r
-# chkconfig: - 15 85\r
-# description: Activates/Deactivates InfiniBand Subnet Manager\r
-#\r
-### BEGIN INIT INFO\r
-# Provides:       opensm\r
-### END INIT INFO\r
-#\r
-# Copyright (c) 2008 Voltaire, Inc. All rights reserved.\r
-# Copyright (c) 2006 Mellanox Technologies. All rights reserved.\r
-#\r
-# This Software is licensed under one of the following licenses:\r
-#\r
-# 1) under the terms of the "Common Public License 1.0" a copy of which is\r
-#    available from the Open Source Initiative, see\r
-#    http://www.opensource.org/licenses/cpl.php.\r
-#\r
-# 2) under the terms of the "The BSD License" a copy of which is\r
-#    available from the Open Source Initiative, see\r
-#    http://www.opensource.org/licenses/bsd-license.php.\r
-#\r
-# 3) under the terms of the "GNU General Public License (GPL) Version 2" a\r
-#    copy of which is available from the Open Source Initiative, see\r
-#    http://www.opensource.org/licenses/gpl-license.php.\r
-#\r
-# Licensee has the right to choose one of the above licenses.\r
-#\r
-# Redistributions of source code must retain the above copyright\r
-# notice and one of the license notices.\r
-#\r
-# Redistributions in binary form must reproduce both the above copyright\r
-# notice, one of the license notices in the documentation\r
-# and/or other materials provided with the distribution.\r
-#\r
-#\r
-#  $Id: openib-1.0-opensm.init,v 1.5 2006/08/02 18:18:23 dledford Exp $\r
-#\r
-# processname: @sbindir@/opensm\r
-# config: @sysconfdir@/sysconfig/opensm\r
-# pidfile: /var/run/opensm.pid\r
-\r
-prefix=@prefix@\r
-exec_prefix=@exec_prefix@\r
-\r
-. /etc/rc.d/init.d/functions\r
-\r
-CONFIG=@sysconfdir@/sysconfig/opensm\r
-if [ -f $CONFIG ]; then\r
-    . $CONFIG\r
-fi\r
-\r
-prog=@sbindir@/opensm\r
-bin=${prog##*/}\r
-\r
-# Handover daemon for updating guid2lid cache file\r
-sldd_prog=@sbindir@/sldd.sh\r
-sldd_bin=${sldd_prog##*/}\r
-sldd_pid_file=/var/run/sldd.pid\r
-\r
-ACTION=$1\r
-\r
-# Setting OpenSM start parameters\r
-PID_FILE=/var/run/${bin}.pid\r
-touch $PID_FILE\r
-\r
-if [[ -n "${OSM_HOSTS}" && $(echo -n ${OSM_HOSTS} | wc -w | tr -d '[:space:]') -gt 1  ]]; then\r
-    HONORE_GUID2LID="--honor_guid2lid"\r
-fi\r
-\r
-#########################################################################\r
-\r
-start_sldd()\r
-{\r
-    if [ -f $sldd_pid_file ]; then\r
-            local line p\r
-            read line < $sldd_pid_file\r
-            for p in $line ; do\r
-                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"\r
-            done\r
-    fi\r
-\r
-    if [ -z "$sldd_pid" ]; then\r
-        sldd_pid=`pidof -x $sldd_bin`\r
-    fi\r
-\r
-    if [ -n "${sldd_pid:-}" ] ; then\r
-       kill -9 ${sldd_pid} > /dev/null 2>&1\r
-    fi\r
-\r
-    $sldd_prog > /dev/null 2>&1 &\r
-    sldd_pid=$!\r
-\r
-    echo ${sldd_pid} > $sldd_pid_file\r
-    # Sleep is needed in order to update local gid2lid cache file before running opensm\r
-    sleep 3\r
-}\r
-\r
-stop_sldd()\r
-{\r
-    if [ -f $sldd_pid_file ]; then\r
-            local line p\r
-            read line < $sldd_pid_file\r
-            for p in $line ; do\r
-                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"\r
-            done\r
-    fi\r
-\r
-    if [ -z "$sldd_pid" ]; then\r
-        sldd_pid=`pidof -x $sldd_bin`\r
-    fi\r
-\r
-    if [ -n "${sldd_pid:-}" ] ; then\r
-        kill -15 ${sldd_pid} > /dev/null 2>&1\r
-    fi\r
-\r
-}\r
-\r
-start()\r
-{\r
-    local OSM_PID=\r
-\r
-    pid=""\r
-\r
-    if [ -f $PID_FILE ]; then\r
-            local line p\r
-            read line < $PID_FILE\r
-            for p in $line ; do\r
-                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p"\r
-            done\r
-    fi\r
-\r
-    if [ -z "$pid" ]; then\r
-        pid=`pidof -o $$ -o $PPID -o %PPID -x $bin`\r
-    fi\r
-\r
-    if [ -n "${pid:-}" ] ; then\r
-        echo $"${bin} (pid $pid) is already running..."\r
-    else\r
-\r
-       if [ -n "${HONORE_GUID2LID}" ]; then\r
-               # Run sldd daemod\r
-               start_sldd\r
-       fi\r
-\r
-        # Start opensm\r
-       echo -n "Starting IB Subnet Manager"\r
-        $prog --daemon ${HONORE_GUID2LID} ${OPTIONS} > /dev/null\r
-        cnt=0; alive=0\r
-        while [ $cnt -lt 6 -a $alive -ne 1 ]; do\r
-               echo -n ".";\r
-               sleep 1\r
-               alive=0\r
-                OSM_PID=`pidof $prog`\r
-                if [ "$OSM_PID" != "" ]; then\r
-                        alive=1\r
-                fi\r
-               let cnt++;\r
-       done\r
-\r
-        echo $OSM_PID > $PID_FILE\r
-        checkpid $OSM_PID\r
-        RC=$?\r
-        [ $RC -eq 0 ] && echo_success || echo_failure\r
-        [ $RC -eq 0 ] && touch /var/lock/subsys/opensm\r
-       echo\r
-\r
-    fi\r
-return $RC\r
-}\r
-\r
-stop()\r
-{\r
-    local pid=\r
-    local pid1=\r
-    local pid2=\r
-\r
-    # Stop sldd daemon\r
-    stop_sldd\r
-\r
-    if [ -f $PID_FILE ]; then\r
-            local line p\r
-            read line < $PID_FILE\r
-            for p in $line ; do\r
-                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid1="$pid1 $p"\r
-            done\r
-    fi\r
-\r
-    pid2=`pidof -o $$ -o $PPID -o %PPID -x $bin`\r
-\r
-    pid=`echo "$pid1 $pid2" | sed -e 's/\ /\n/g' | sort -n | uniq | sed -e 's/\n/\ /g'`\r
-\r
-    if [ -n "${pid:-}" ] ; then\r
-        # Kill opensm\r
-       echo -n "Stopping IB Subnet Manager."\r
-        kill -15 $pid > /dev/null 2>&1\r
-               cnt=0; alive=1\r
-        while [ $cnt -lt 6 -a $alive -ne 0 ]; do\r
-               echo -n ".";\r
-               alive=0\r
-               for p in $pid; do\r
-                       if checkpid $p ; then alive=1; echo -n "-"; fi\r
-               done\r
-               let cnt++;\r
-               sleep $alive\r
-       done\r
-\r
-        for p in $pid\r
-        do\r
-            while checkpid $p ; do\r
-                kill -KILL $p > /dev/null 2>&1\r
-                echo -n "+"\r
-                sleep 1\r
-            done\r
-        done\r
-        checkpid $pid\r
-        RC=$?\r
-        [ $RC -eq 0 ] && echo_failure || echo_success\r
-       echo\r
-        RC=$((! $RC))\r
-    else\r
-       echo -n "Stopping IB Subnet Manager."\r
-        echo_failure\r
-       echo\r
-        RC=1\r
-    fi\r
-\r
-    # Remove pid file if any.\r
-    rm -f $PID_FILE\r
-    rm -f /var/lock/subsys/opensm\r
-    return $RC\r
-}\r
-\r
-status()\r
-{\r
-    local pid\r
-\r
-    # First try "pidof"\r
-    pid=`pidof -o $$ -o $PPID -o %PPID -x ${bin}`\r
-    if [ -n "$pid" ]; then\r
-            echo $"${bin} (pid $pid) is running..."\r
-            return 0\r
-    fi\r
-\r
-     # Next try "/var/run/opensm.pid" files\r
-     if [ -f $PID_FILE ] ; then\r
-             read pid < $PID_FILE\r
-             if [ -n "$pid" ]; then\r
-                     echo $"${bin} dead but pid file $PID_FILE exists"\r
-                     return 1\r
-             fi\r
-     fi\r
-     echo $"${bin} is stopped"\r
-     return 3\r
-}\r
-\r
-\r
-\r
-case $ACTION in\r
-       start)\r
-                start\r
-               ;;\r
-       stop)\r
-               stop\r
-               ;;\r
-       restart)\r
-               stop\r
-                start\r
-               ;;\r
-       status)\r
-               status\r
-               ;;\r
-       condrestart)\r
-               pid=`pidof -o $$ -o $PPID -o %PPID -x $bin`\r
-               if [ -n "$pid" ]; then\r
-                       stop\r
-                       sleep 1\r
-                       start\r
-               fi\r
-               ;;\r
-       *)\r
-               echo\r
-               echo "Usage: `basename $0` {start|stop|restart|status}"\r
-               echo\r
-               exit 1\r
-               ;;\r
-esac\r
-\r
-RC=$?\r
-exit $RC\r
diff --git a/trunk/ulp/opensm/user/scripts/sldd.sh.in b/trunk/ulp/opensm/user/scripts/sldd.sh.in
deleted file mode 100644 (file)
index b661f0f..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-#!/bin/bash\r
-#\r
-# Copyright (c) 2008 Voltaire, Inc. All rights reserved.\r
-# Copyright (c) 2006 Mellanox Technologies. All rights reserved.\r
-#\r
-# This Software is licensed under one of the following licenses:\r
-#\r
-# 1) under the terms of the "Common Public License 1.0" a copy of which is\r
-#    available from the Open Source Initiative, see\r
-#    http://www.opensource.org/licenses/cpl.php.\r
-#\r
-# 2) under the terms of the "The BSD License" a copy of which is\r
-#    available from the Open Source Initiative, see\r
-#    http://www.opensource.org/licenses/bsd-license.php.\r
-#\r
-# 3) under the terms of the "GNU General Public License (GPL) Version 2" a\r
-#    copy of which is available from the Open Source Initiative, see\r
-#    http://www.opensource.org/licenses/gpl-license.php.\r
-#\r
-# Licensee has the right to choose one of the above licenses.\r
-#\r
-# Redistributions of source code must retain the above copyright\r
-# notice and one of the license notices.\r
-#\r
-# Redistributions in binary form must reproduce both the above copyright\r
-# notice, one of the license notices in the documentation\r
-# and/or other materials provided with the distribution.\r
-#\r
-#\r
-\r
-# OpenSM found to have the following problem\r
-# when handover is performed:\r
-# If some of the cluster nodes are rebooted during the handover they loose their LID assignment.\r
-# The reason for it is that the standby SM does not obey its own Guid to LID table\r
-# and simply uses the discovered LIDs. If some nodes are not available for it\r
-# their previous LID assignment is lost forever.\r
-\r
-# The idea is to use an external daemon that will distribute\r
-# the semi-static LID assignment table from the master SM to all standby SMs.\r
-# A standby SM, becoming a master . needs to obey the copied semi static LID assignment table.\r
-\r
-prefix=@prefix@\r
-exec_prefix=@exec_prefix@\r
-\r
-CONFIG=@sysconfdir@/sysconfig/opensm\r
-if [ -f $CONFIG ]; then\r
-       . $CONFIG\r
-fi\r
-\r
-SLDD_DEBUG=${SLDD_DEBUG:-0}\r
-\r
-CACHE_FILE=${CACHE_FILE:-/var/cache/opensm/guid2lid}\r
-CACHE_DIR=$(dirname ${CACHE_FILE})\r
-tmp_cache=${CACHE_FILE}.tmp\r
-\r
-PING='ping -w 1 -c 1'\r
-\r
-RCP=${RCP:-/usr/bin/scp}\r
-RSH=${RSH:-/usr/bin/ssh}\r
-IFCONFIG=${IFCONFIG:-'/sbin/ifconfig -a'}\r
-\r
-declare -i SLDD_DEBUG\r
-RESCAN_TIME=${RESCAN_TIME:-60}\r
-\r
-if [ -z "${OSM_HOSTS}" ]; then\r
-       [ $SLDD_DEBUG -eq 1 ] &&\r
-       echo "No OpenSM servers (OSM_HOSTS) configured for the IB subnet."\r
-       exit 0\r
-fi\r
-\r
-\r
-declare -a arr_OSM_HOSTS\r
-arr_OSM_HOSTS=(${OSM_HOSTS})\r
-\r
-num_of_osm_hosts=${#arr_OSM_HOSTS[@]}\r
-\r
-if [ ${num_of_osm_hosts} -eq 1 ]; then\r
-       [ $SLDD_DEBUG -eq 1 ] &&\r
-       echo "One OpenSM server configured in the IB subnet." &&\r
-       echo "Nothing to be done for SLDD"\r
-\r
-       exit 0\r
-fi\r
-\r
-trap 'trap_handler' 15\r
-\r
-trap_handler()\r
-{\r
-       logger -i "SLDD: Exiting."\r
-       exit 0\r
-}\r
-\r
-is_alive()\r
-{\r
-       $PING $1 > /dev/null 2>&1\r
-       return $?\r
-}\r
-\r
-is_local()\r
-{\r
-       $IFCONFIG | grep -w "$1" > /dev/null 2>&1\r
-       return $?\r
-}\r
-\r
-update_remote_cache()\r
-{\r
-       /bin/rm -f ${CACHE_FILE}.upd\r
-       /bin/cp -a ${CACHE_FILE} ${CACHE_FILE}.upd\r
-\r
-       [ $SLDD_DEBUG -eq 1 ] &&\r
-       echo "Updating remote cache file"\r
-\r
-       for host in ${OSM_HOSTS}\r
-       do\r
-               # Skip local host update\r
-               if [ "${host}" == "${local_host}" ]; then\r
-                       continue\r
-               fi\r
-\r
-               if is_alive $host; then\r
-                       stat=$($RSH $host "/bin/mkdir -p ${CACHE_DIR} > /dev/null 2>&1; /bin/rm -f ${CACHE_FILE}.${local_host} > /dev/null 2>&1; echo \$?" | tr -d '[:space:]')\r
-                       if [ "X${stat}" == "X0" ]; then\r
-                               [ $SLDD_DEBUG -eq 1 ] &&\r
-                               echo "Updating $host"\r
-                               logger -i "SLDD: updating $host with ${CACHE_FILE}"\r
-                               $RCP ${CACHE_FILE}.upd ${host}:${CACHE_FILE}.${local_host}\r
-                               /bin/cp ${CACHE_FILE}.upd ${CACHE_FILE}.${host}\r
-                       else\r
-                               [ $SLDD_DEBUG -eq 1 ] &&\r
-                               echo "$RSH to $host failed."\r
-                               logger -i "SLDD: Failed to update $host with ${CACHE_FILE}. $RSH without password should be enabled"\r
-                               exit 5\r
-                       fi\r
-               else\r
-                       [ $SLDD_DEBUG -eq 1 ] &&\r
-                       echo "$host is down."\r
-                       continue\r
-               fi\r
-       done\r
-}\r
-\r
-get_latest_remote_cache()\r
-{\r
-       # Find most updated remote cache file (the suffix should be like ip address: *.*.*.*)\r
-       echo -n "$(/bin/ls -1t ${CACHE_FILE}.*.* 2> /dev/null | head -1)"\r
-}\r
-\r
-get_largest_remote_cache()\r
-{\r
-       # Find largest (size) remote cache file (the suffix should be like ip address: *.*.*.*)\r
-       echo -n "$(/bin/ls -1S ${CACHE_FILE}.*.* 2> /dev/null | head -1)"\r
-}\r
-\r
-swap_cache_files()\r
-{\r
-       /bin/rm -f ${CACHE_FILE}.old\r
-       /bin/mv ${CACHE_FILE} ${CACHE_FILE}.old\r
-       /bin/cp ${largest_remote_cache} ${CACHE_FILE}\r
-       touch ${CACHE_FILE}.tmp\r
-}\r
-\r
-# Find local host in the osm hosts list\r
-local_host=""\r
-for host in ${OSM_HOSTS}\r
-do\r
-       if is_local $host; then\r
-               local_host=${host}\r
-       fi\r
-done\r
-\r
-# Get cache file info\r
-declare -i new_size=0\r
-declare -i last_size=0\r
-declare -i largest_remote_cache_size=0\r
-\r
-if [ -e ${CACHE_FILE} ]; then\r
-       last_size=$(du -b ${CACHE_FILE} | awk '{print$1}' | tr -d '[:space:]')\r
-else\r
-       touch ${CACHE_FILE} ${CACHE_FILE}.tmp\r
-fi\r
-\r
-# if [ ${last_size} -gt 0 ]; then\r
-#      # First time update\r
-#      update_remote_cache\r
-# fi\r
-\r
-while true\r
-do\r
-       if [ -s "${CACHE_FILE}" ]; then\r
-               new_size=$(du -b ${CACHE_FILE} | awk '{print$1}' | tr -d '[:space:]')\r
-               # Check if local cache file grew from its last version or the time stamp changed\r
-               if [ ${new_size} -gt ${last_size} ]\r
-                  [ "$(/bin/ls -1t ${CACHE_FILE} ${CACHE_FILE}.tmp 2> /dev/null | head -1)"  != "${CACHE_FILE}.tmp" ]; then\r
-                       largest_remote_cache=$(get_largest_remote_cache)\r
-                       if [[ -n "${largest_remote_cache}" && -s "${largest_remote_cache}" ]]; then\r
-                               largest_remote_cache_size=$(du -b ${largest_remote_cache} 2> /dev/null | awk '{print$1}' | tr -d '[:space:]')\r
-                       else\r
-                               largest_remote_cache_size=0\r
-                       fi\r
-\r
-                       # Check if local cache file larger than remote chache file\r
-                       if [ ${new_size} -gt ${largest_remote_cache_size} ]; then\r
-                               [ $SLDD_DEBUG -eq 1 ] &&\r
-                               echo "Local cache file larger then remote. Update remote cache files"\r
-                               last_size=${new_size}\r
-                               update_remote_cache\r
-                               continue\r
-                       fi\r
-               fi\r
-\r
-               largest_remote_cache=$(get_largest_remote_cache)\r
-               if [[ -n "${largest_remote_cache}" && -s "${largest_remote_cache}" ]]; then\r
-                       largest_remote_cache_size=$(du -b ${largest_remote_cache} 2> /dev/null | awk '{print$1}' | tr -d '[:space:]')\r
-               else\r
-                       largest_remote_cache_size=0\r
-               fi\r
-\r
-               # Update local cache file from remote\r
-               if [ ${largest_remote_cache_size} -gt ${new_size} ]; then\r
-                       [ $SLDD_DEBUG -eq 1 ] &&\r
-                       echo "Local cache file shorter then remote. Use ${largest_remote_cache}"\r
-                       logger -i "SLDD: updating local cache file with ${largest_remote_cache}"\r
-                       swap_cache_files\r
-                       last_size=${largest_remote_cache_size}\r
-               fi\r
-\r
-       else # The local cache file is empty\r
-               [ $SLDD_DEBUG -eq 1 ] &&\r
-               echo "${CACHE_FILE} is empty"\r
-\r
-               largest_remote_cache=$(get_largest_remote_cache)\r
-               if [[ -n "${largest_remote_cache}" && -s "${largest_remote_cache}" ]]; then\r
-                       # Copy it to the current cache\r
-                       [ $SLDD_DEBUG -eq 1 ] &&\r
-                       echo "Local cache file is empty. Use ${largest_remote_cache}"\r
-                       logger -i "SLDD: updating local cache file with ${largest_remote_cache}"\r
-                       swap_cache_files\r
-               fi\r
-\r
-       fi\r
-\r
-       [ $SLDD_DEBUG -eq 1 ] &&\r
-       echo "Sleeping ${RESCAN_TIME} seconds."\r
-       sleep ${RESCAN_TIME}\r
-\r
-done\r