Skip to content

Instantly share code, notes, and snippets.

@DennisLfromGA
Last active August 8, 2021 14:24
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/2a37e4a9e89bcd903484c965763562ad to your computer and use it in GitHub Desktop.
Save DennisLfromGA/2a37e4a9e89bcd903484c965763562ad to your computer and use it in GitHub Desktop.
#!/bin/bash
name=${1:-google pixelbook$}
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 name '${name}' - "
count=$(grep -i "name=${name}" -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} '${name}' names.." key
echo
echo "--"
fi
grep --color=auto -i "name=${name}" -A 11 ${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