#!/bin/sh

# dupeloop
# Copyright (C) 2025 Joseph Rosevear, San Diego CA, USA.

# This file is part of SAM.handy, a library of tools for use with SAM.

# SAM.handy 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 3 of the License, or (at your
# option) any later version.

# SAM.handy is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.

# You should have received a copy of the GNU General Public License
# along with SAM.handy. If not, see <http://www.gnu.org/licenses/>.

# To learn more about SAM and SAM.handy, see <https://RosevearSoftware.com>.



# Joseph Rosevear 210115 I wrote this script.

# Joseph Rosevear 210507 I added a section that runs sleeps and prompts
# user to check Internet connection, if there is a failure.

# I modified the "quit trying" message.

# Joseph Rosevear 251215 01:22PM I changed a comment at the top.



result=1
for count in 1 2 3 4 5; do

   dupe $*
   result=$?
   
   if [ "$result" = "0" ]; then

      cat << DONE
dupe $*:
   Success.
DONE
      #
      
      sleep 3
      exit

   else
   
      cat << DONE
dupe $*:
   Failure $count.

   Check Internet connection.
DONE


      sleep 30
   fi
done

cat << DONE
dupe $*:
   Failed 6 times--quit trying.
DONE
