#!/bin/bash# This script is used to repaire links when you what to move TDengine# data to other places and to access data.# Read link pathread-p"Please enter link directory such as /var/lib/taos/tsdb: " linkDirwhile true;do if[!-d$linkDir];thenread-p"Paht not exists, please enter the correct link path:" linkDircontinue fibreakdonedeclare-A dirHashfor linkFile in$(find -L$linkDir-xtype l);dotargetFile=$(readlink-f$linkFile)echo"targetFile: ${targetFile}"# TODO : Extract directory part and basename partdirName=$(dirname$(dirname${targetFile}))baseName=$(basename$(dirname${targetFile}))/$(basename${targetFile})# TODO : newDir="${dirHash["$dirName"]}"if[-z"${dirHash["$dirName"]}"];thenread-p"Please enter the directory to replace ${dirName}:" newDirread-p"Do you want to replcace all[y/N]?" replcaceAllif[[("${replcaceAll}"=="y")||("${replcaceAll}"=="Y")]];thendirHash["$dirName"]="$newDir"fi fi# Replcace the fileln-sf"${newDir}/${baseName}""${linkFile}"done