Index
Previous
Next

Homechoice: General Questions

How do I keep my Homechoice connection permanently running on FreeBSD?


These instructions apply to FreeBSD only, though it may be possible to adapt the technique for other Unix variants

It is possible for Homechoice Internet connectivity to be lost without the PPP daemon noticing, because the PPP daemon only talks to the STB and if there is a problem beyond the STB it may be necessary to close that session down and restart.

Create the following scripts:

/usr/local/bin/pppmonitor

#!/bin/ksh
#
# Script to ensure that PPP connectivity via Homechoice
# is always available.
# Run regularly from "cron".
#
# Ed Randall 14/5/2001
#

# List of well-known hosts for checking.
# If we can't ping _any_ of them, reboot the connection.
HOSTS='
dns1.homechoice.co.uk
dns2.homechoice.co.uk
www.homechoice.co.uk
mail.homechoice.co.uk
croy-gw2.homechoice.co.uk
croy-gw3.homechoice.co.uk
gate.demon.co.uk
'

typeset -i DOWN=1

for HOST in ${HOSTS}
do
    if /sbin/ping -c 1 ${HOST} >/dev/null 2>&1
    then
        DOWN=0
        break
    fi
done

# Can't ping anything, reboot the connection
if (( DOWN ))
then
    print "Cannot ping any of:${HOSTS}"
    /etc/init.d/homechoice.sh restart
fi
    
# EOF

/etc/init.d/homechoice.sh

#!/bin/ksh
#
# Script to control PPP to homechoice
# Provides start, stop, restart and test functions.
#
# Ed Randall 14/5/2001
#

STARTCMD='/usr/sbin/ppp -background homechoice'
PIDFILE=/var/run/tun0.pid
PID=''

function CheckProcess
{
    if [[ ! -r "${PIDFILE}" ]]
    then
        return 1
    fi

    PID=`cat ${PIDFILE}`
    if [[ -z "${PID}" ]]
    then
        return 1
    fi

    ps -p "${PID}" | grep -q "${STARTCMD}"
    return $?
}


function StopProcess
{
    typeset -i count=0
    typeset -i done=0

    print -u2 -n "Stopping ${PID}"
    kill ${PID}
    while (( count < 30 ))
    do
        if ! CheckProcess
        then
            done=1
            break
        fi

        print -u2 -n '.'
        sleep 1
        (( count += 1 ))
    done

    if (( ! done ))
    then
        print -u2 -n 'giving up, sending SIGKILL.'
        kill -9 ${PID}
    fi
    print -u2 ''
}

case $1 in
    start)
        if ! CheckProcess
        then
            ${STARTCMD}
        fi
        ;;

    stop)
        if CheckProcess
        then
            StopProcess
        fi
        ;;

    restart)
        if CheckProcess
        then
            StopProcess
        fi
        ${STARTCMD}
        ;;

    test)
        CheckProcess
        return $?
        ;;

    *)
        ;;
esac

# EOF
Then add the following cronjob as "root":
# crontab -e
55,10,25,40 * * * * /usr/local/bin/pppmonitor

Link connectivity will be tested every 15 minutes, and if down it will be restarted. Ed Randall, Wed Feb 13 00:38:34 2002



chitts@civicart.com

Ed, Tue Oct 7 11:39:21 2003

Index
Previous : How do I debug Windows dial-up networking (using a Homechoice STB modem)?
Next : How do I connect to Homechoice using Linux?