A collection of scripts which signon to StofaNet (Danish ISP) from a Linux box.
If you have a dynamic IP address you might also be interested in visiting DynDNS.
NOTICE!
StofaNet now offers an Always-On service, which somewhat deprecates this collection of scripts.
System V Init Signon
This is a SysV Init script. It is especially useful if any of the sysvinit started daemons need internet access (e.g. ntpd).
#!/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
stofanet.sh
To install the script as a sysvinit service; rename it to
/etc/init.d/stofanet.sh
and add it to the runlevels (notice the dot at the end),
update-rc.d stofanet.sh start 50 2 3 4 5 .
or if, for some reason, you are not running a Debian based distribution,
for runlevel in /etc/rc{2,3,4,5}.d do ln -s /etc/init.d/stofanet.sh $runlevel/S50stofanet.sh done
GUI Signon
This is the GUI of a Tcl/Tk script. The script monitors /proc/net/snmp for outgoing connections and only signs on when needed. After the specified idle timeout it signs the connection off. This is very useful when paying per minute uptime.
Download script: stofanet.tcl
Telnet Signon
This is a telnet based signon; kind of a poor mans Expect script. This technique could probably be useful in other similar situations.
#!/bin/sh ############################################################################# ## telnetsignon.sh - StofaNet signon script (telnet) ## ## 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>" # SignOn server IP IP="192.168.30.2" # SignOn server port PORT="259" if [ -z "$1" ] || [ "$1" != 1 -a "$1" != 2 -a "$1" != 3 ]; then echo "Usage: `basename $0` 1|2|3" echo "" echo " 1 = signon" echo " 2 = signoff" echo " 3 = status" echo "" exit 1 fi # Telnet closes the connection as soon as its standard input is exausted, # therefore the delays are added. This is a poor mans 'Expect' script :-) ( echo $USER; sleep 1 echo $PASS; sleep 1 echo $1 ; sleep 1 ) |telnet $IP $PORT # EOF
telnetsignon.sh
Browser Signon
This is by far the most boring form of StofaNet signon! Make browser bookmarks pointing to the following URLs; The first URL signs you on, the second signs you off.
http://signon.stofanet.dk/signon.php?user=<user>&pass=<pass> http://signon.stofanet.dk/signon.php?user=<user>&pass=<pass>&log_af.x=0