#!/bin/bash 
 
TERM=$1
RNDNO=$RANDOM
CURRDIR=$PWD

if [[ $# -eq 0 ]] ; then
    echo 'Usage: ./search_dump.sh <search term>'
    exit 1
fi

echo Current: $CURRDIR
echo Creating: /mnt/$RNDNO
mkdir /mnt/$RNDNO

echo Mounting NAS
mount -t cifs //192.168.0.13/NAS /mnt/$RNDNO -o username=nanoymaster,password=***REMOVED***,vers=1.0
cd /mnt/$RNDNO/DB_Dumps/bigDB

echo Searching for $TERM in $PWD \(Est. 1hr\)...
rg "$TERM"

echo Unmounting and removing: /mnt/$RNDNO
cd $CURRDIR
umount /mnt/$RNDNO
rmdir /mnt/$RNDNO
