Skip to content

Instantly share code, notes, and snippets.

@DennisLfromGA
Last active August 8, 2021 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DennisLfromGA/72352741e2bf303b03b5d894e3e8a2dd to your computer and use it in GitHub Desktop.
Save DennisLfromGA/72352741e2bf303b03b5d894e3e8a2dd to your computer and use it in GitHub Desktop.
#!/bin/bash
hwid=${1:-eve}
confdiff=''
conffile="recovery.conf"
confscript='get-recovery.conf'
location="${HOME}/Downloads/"
del=3
key=''
mkdir -p ${location}
if [ -s ${location}/${conffile} ]; then
cp ${location}/${conffile} ${location}/${conffile}.old
else
if ! type ${confscript} >/dev/null 2>&1; then
echo "The script '${confscript}' is not installed in your \$PATH, exiting ..."
exit 1
else
${confscript} && sleep ${del}
fi
fi
confdiff=$(stat -c %Y ${location}/${conffile} | echo $(expr $(date +%s) - $(cat)))
if [ "${confdiff}" -gt 86400 ]; then
echo "${conffile} is not from today ..."
${confscript} && sleep ${del}
#else
# echo "The '${conffile}' is from today, you're good ..."
fi
echo -n "Getting ${conffile} info. for hwidmatch '${hwid}' - "
count=$(grep -i "hwidmatch=^${hwid}" -c ${location}/${conffile})
echo "${count} found."
if [ ${count} = 0 ]; then
exit 1
elif [ ${count} = 1 ]; then
echo "--"
else
read -s -n 1 -t "${del}" -p "Press any key or wait ${del} seconds to view ${count} '${hwid}' hwidmatches .." key
echo
echo "--"
fi
grep --color=auto -i "hwidmatch=^${hwid}" -A 7 -B 4 ${location}/${conffile}
echo "--"
exit 0
@DennisLfromGA
Copy link
Author

Renamed script and removed unused variable 'xit'.

@DennisLfromGA
Copy link
Author

Ensured directory $location exists and removed unnecessary 'good to go' comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment