#!/bin/sh
#
# stofanet - StofaNet System V init signon/off script
#
# Copyright (C) 2002 Jess Thrysoee <jess@thrysoee.dk>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#

# UserName
USER="<username>"
# PassWord
PASS="<password>"

CURL=/usr/bin/curl

test -x "$CURL" || exit 1

NAME=`basename $0`
set -e

signon() {

   URL="http://signon.stofanet.dk"
   URL="$URL/signon.php?user=$USER&pass=$PASS"

   if test "$1" = "log_af"
   then
      URL="$URL&log_af.x=0"
   fi

   $CURL -s $URL |\
   grep 'Du er nu logget' >/dev/null
}

case "$1" in
   start)
      echo -n "$NAME: Starting ISP connection... "
      signon log_paa && echo OK || echo FAILED
      ;;
   stop)
      echo -n "$NAME: Stopping ISP connection... "
      signon log_af && echo OK || echo FAILED
      ;;
   *)
      echo "Usage: $NAME {start|stop}" >&2
      exit 1
      ;;
esac

exit 0
