#!/bin/sh

# This script makes a backup before the tsm.json gets removed.

# NOTE: This means we are intentionally leaving behind files on uninstall.



TSM_JSON_PATH=$(nisyncloc persistentTsmJson)



if [ -f $TSM_JSON_PATH ]; then

   BAK_FILENAME=$TSM_JSON_PATH.bak

   if [ -f $BAK_FILENAME ]; then

      BAK_NUMBER=1

      while [ -f $BAK_FILENAME.$BAK_NUMBER ]; do

         BAK_NUMBER=$((BAK_NUMBER+1))

      done

      BAK_FILENAME=$BAK_FILENAME.$BAK_NUMBER

   fi

   mv -f $TSM_JSON_PATH $BAK_FILENAME

   echo "INFO: Moved $TSM_JSON_PATH to $BAK_FILENAME"

fi



