[scripts] Minor updates to pairinghelper.sh option parsing

This commit is contained in:
Scott Shambarger 2017-01-21 15:36:42 -05:00
parent 2cf2eb32aa
commit 37b1678103

View File

@ -4,29 +4,32 @@
conf_path="/etc/forked-daapd.conf" conf_path="/etc/forked-daapd.conf"
usage() { usage() {
echo
echo "Interactive script pair Remote with forked-daapd" echo "Interactive script pair Remote with forked-daapd"
echo echo
echo "Usage: ${0##*/} [ <config-file> ]" echo "Usage: ${0##*/} -h | [ <config-file> ]"
echo echo
echo "Parameters:" echo "Parameters:"
echo " -h Show this help" echo " -h Show this help"
echo " <config-file> Config file (default=$conf_path)" echo " <config-file> Config file (default: $conf_path)"
echo echo
echo "Note: forked-daapd needs to be running..." echo "NOTE: forked-daapd needs to be running..."
exit $1 exit 0
} }
case $1 in case $1 in
-h) usage 0;; -h|--help) usage;;
-*) usage 1;; -*)
echo "Unrecognized option $1 (try -h for usage)"
exit 1
;;
esac esac
[ -n "$1" ] && conf_path="$1" [ -n "$1" ] && conf_path=$1
if [ ! -f "$conf_path" ]; then if [ ! -f "$conf_path" ]; then
echo "Error: Couldn't find config file '$conf_path'" echo "Couldn't find config file '$conf_path' (try -h for usage)"
echo exit 1
usage 1
fi fi
logfile=`awk '$1=="logfile"{print $3}' $conf_path` logfile=`awk '$1=="logfile"{print $3}' $conf_path`