Skip to content

Instantly share code, notes, and snippets.

@DennisLfromGA
Last active August 8, 2021 14:27
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/9543b6942c25119f3229faa21b3c0aee to your computer and use it in GitHub Desktop.
Save DennisLfromGA/9543b6942c25119f3229faa21b3c0aee to your computer and use it in GitHub Desktop.
#!/bin/bash
board=${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 boardname '${board}' - "
count=$(grep "file=.*_${board}_.*" -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} '${board}' boards ..." key
echo
echo "--"
fi
grep --color=auto "file=.*_${board}_.*" -A 2 -B 9 ${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