Merge pull request #51 from corbolais/master

chg: use authcode file located in HOME dir.
This commit is contained in:
KrumpetPirate 2018-03-14 19:40:34 -05:00 committed by GitHub
commit e3d9a9ea35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,8 @@ set -o errexit -o noclobber -o nounset -o pipefail
codec=libmp3lame
extension=mp3
mode=chaptered
authcode=".authcode";
authcodeDirs="${HOME}/ ./";
GREP=$(grep --version | grep -q GNU && echo "grep" || echo "ggrep")
if ! [[ $(type -P "$GREP") ]]; then
@ -47,12 +49,26 @@ then
shift
fi
if [ ! -f .authcode ]; then
auth_code="";
for dir in $authcodeDirs; do
codeFile="${dir}$authcode";
if [ ! -f "$codeFile" ]; then
auth_code=$1
shift
else
auth_code=`head -1 .authcode`
fi
break;
elif [ -s "$codeFile" ]; then
auth_code=`head -1 "$codeFile"`
break;
else
echo "INFO: Sorry, empty \"$codeFile\" found, skipping.";
fi;
done;
if [ -z "$auth_code" ]; then
echo "INFO: Sorry, no authcode provided.";
exit 1;
fi;
debug() {
echo "$(date "+%F %T%z") ${1}"