#!/bin/sh
#
# Very simple wrapper to update wlconfig.wirelessleiden.nl without the need of
# a webbrowser

INTERNAL_URL='http://sunny.wleiden.net/wleiden/config/?action=update&source=internal'
EXTERNAL_URL='http://sunfire.wirelessleiden.nl/wleiden/config/?action=update&source=external'
CLI=`whereis -b fetch wget curl false | awk '{if ($2) {print $2;exit}}'`


case `basename $CLI` in
 "wget") CLI_ARGS="-O - -nv";;
 "curl") CLI_ARGS="-o -";;
 "fetch") CLI_ARGS="-o -";;
 "false") echo "# no URL fetcher found"; exit 1;;
esac

echo "# Processing via internal URL ($INTERNAL_URL) please wait..."
$CLI $CLI_ARGS $INTERNAL_URL || {
  echo "# Processing via external URL ($EXTERNAL_URL) please wait..."
  $CLI $CLI_ARGS $EXTERNAL_URL
}
