Last active
August 8, 2021 14:27
-
-
Save DennisLfromGA/9543b6942c25119f3229faa21b3c0aee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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
Renamed script and removed unused variable 'xit'.