On Thursday 28 June 2001 10:25, Hadi Ariwibowo wrote:
> Cool :)
> Bila email send/receive sudah selesai, bisa disconnect lagi ?

Bisa donk.. tinggal di set aja kalau udah idle selama 1 menit disconnect 
secara automatic

> Kalau saya pakai windmodem ( driver ), bila menggunakan script
> dial on demand yang kamu bilang bisa juga kan ?

Bisa. No problem.

> Dan karena winmodem nggak bisa diatur hidup/matinya ( kecuali dicabut
> kabelnya ) apakah bisa dengan tidak menggunakan fasilitas crontab
> agar tidak melakukan koneksi secara otomatis ?

Bisa. 

>
> BTW, bagi2x donk scriptnya :)

Bagi yang pake SuSE sudah include dari sejak distro 6.4. Nah Bagi distro lain 
coba copy script berikut ke directory /etc/rc.d/init.d/ dengan nama wvdial.dod

Script ini sudah pernah saya terapkan ke Mandrake 7.2 di rumah. Dan jalan 
dengan sukses.. no problem...

Semoga bermanfaat.


---script begin---

#! /bin/bash
#
# Copyright (c) 2000 SuSE GmbH Nuernberg, Germany. All rights reserved.
#
#
# parameters
# start section section section
# restart section section section
# start or restart the daemon with parameters found in /etc/wvdial.conf
# section is the name of a section in the /etc/wvdial.conf file
# (see man wvdial)
# stop
# stop the pppd
# hangup # hang up the telephone line
# This script will be started at boot time, if the parameter
# PPPD_DOD_START in the /etc/rc.config file is set to "yes"
# --commented by Romie--
# bagi distro lain script ini sudah diakalin kok.. jadi langsung jalan
# --commented by Romie--
# additional Parameters in /etc/wvdial.conf could be
# Idle: sets the idle-time for waiting before hang up (default 180s)
# Remote IP: remote IP-address (default 192.168.99.99)
# Local IP: local IP-address (default 192.168.99.1)
# Defaultroute: no: pppd will not set the default route to the remote ip
# when the connection is established. Resetting the previsious ip address
# when the connection is going down
# (default yes)

# time to sleep for pppd to come up
WAITFORPPPD=2
# configuration file
CONFFILE="/etc/wvdial.conf"
# set defaults, no defaults for
# Username, Modem, Baud
LocalIP="192.168.99.1"
RemoteIP="192.168.99.99"
Idle=180
DEFAULTROUTE="defaultroute"
PPPD_DOD_START="yes"

function log()
{
        # logs the messages to system log
        HEAD=$0[$$]
        logger -st $HEAD "$@"
}

function setpppdparam()
{
        TMPFILE=`mktemp -q /tmp/$base.XXXXXX`
        if [ $? -ne 0 ]; then
                echo "$base: Can't create temp file, exiting..."
                exit 1
        fi

        # extract subsection
        cat $CONFFILE | sed -n "/Dialer.*$SECTION/ \
        {:x;p;n;/Dialer/q;bx}" > $TMPFILE
        for VAR in Modem Baud Username RemoteIP LocalIP Idle Defaultroute ISDN
        do
                VALUE=`sed -n 
's/^'"$VAR"'[[:space:]]*=[[:space:]]*\(.*[^[:space:]]\)[[:space:]]*/\1/p' 
$TMPFILE`
                [ "$VALUE" ] && eval "$VAR='$VALUE'"
        done
        if [ X$Defaultroute = XNo -o X$Defaultroute = XNO -o X$Defaultroute = 
Xno ]; then
            DEFAULTROUTE="nodefaultroute"
        fi
        if [ $ISDN = 1 ]; then
                ASYNCMAP="default-asyncmap"
        fi
        rm -f $TMPFILE
}

function killpppd()
{
        if [ -e $PIDFILE ]; then
            PID=`cat $PIDFILE`
            log "killing pppd process [PID=$PID]"
            kill -15 $PID 2>/dev/null
            rm $PIDFILE
        fi
}

function startpppd()
{

        # get params from section "Dialer Default"
        SECTION=Defaults
        setpppdparam

        # parse given section ([Dailer xxx]) parameters
        while [ ! -z $1 ]; do
            SECTION=$1
            setpppdparam
            shift
        done

        # start pppd in demand mode
        set -- "$LocalIP:$RemoteIP" "$Modem" "$Baud" modem crtscts\
        "$DEFAULTROUTE" $ASYNCMAP -detach user "$Username" ipcp-accept-local\
        ipcp-accept-remote usepeerdns call wvdial demand idle "$Idle"
        pppd "$@" connect "/usr/bin/wvdial --chat $WVPARAMS" \
        &>/dev/null &
        PPPDPID=$!
        echo $PPPDPID > $PIDFILE
        log "starting pppd $* connect \"/usr/bin/wvdial\
        --chat $WVPARAMS\"... [PID=$PPPDPID]"

        # if not started by user root, ifconfig cannot be executed
        if [ $UID != 0 ]; then
            log "wvdial.dod was not started by user root. ->"
            log "Cannot set device $DEVICE dynamic"
            exit 0
        fi

        # setting dynamic - parameter for ppp - device
        # waiting pppd to come up
        sleep $WAITFORPPPD
        ls /var/run/ppp?.pid | while read PIDFILE ; do
            if [ X$PPPDPID = X`cat $PIDFILE` ]; then
                DEVICE=`echo $PIDFILE | cut -c 10-13`
                MESSAGE="setting $DEVICE dynamic "
                ifconfig $DEVICE dynamic
                ifconfig $DEVICE | grep "DYNAMIC" -q
                RES=$?
                if [ $RES -gt 0 ]; then
                    MESSAGE=$MESSAGE"failed"
                    log $MESSAGE
                    exit 1
                fi
                MESSAGE=$MESSAGE$"done"
                log $MESSAGE
            fi
        done
        exit 0
}

# main
LINKNAME=dod
PIDFILE=/var/run/pppd.$LINKNAME.pid
ACTION=$1
shift
WVPARAMS=$@
 
. /etc/rc.config
 
# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}
 
# Force execution if not called by a runlevel directory.
test $link = $base && PPPD_DOD_START=yes
# logger base, link, PPPD_DOD_START $base $link $PPPD_DOD_START
test "$PPPD_DOD_START" = "yes" || exit 0
 
case "$ACTION" in
   start)
        # make sure to start even when uncleanly stopped
        killpppd
        startpppd $@
        ;;
   stop)
        # handle stop
        killpppd
        exit 0
        ;;
   reload|restart)
        killpppd
        startpppd $@
        ;;
   hangup)
        if [ -e $PIDFILE ]; then
               PID=`cat $PIDFILE`
               MESSAGE=$MESSAGE"PID=$PID"
               log "hangup pppd connection "
               killall wvdial #&>/dev/null
               kill -SIGHUP $PID #2>/dev/null
               exit 0
        fi
        log "no pppd connection"
        exit 1
        ;;
   # status)
        # ;;
   *)
        echo "Usage: /sbin/init.d/wvdial.dod {start " \
        "[section [section [..]]]|hangup|stop|restart}"
        exit 1
        ;;
esac

---end of script---



-- 
Best regards,
Romie Djapri

-- 
Utk berhenti langganan, kirim email ke [EMAIL PROTECTED]
Dapatkan FAQ milis dg mengirim email kosong ke [EMAIL PROTECTED]
Informasi arsip di http://www.linux.or.id/milis.php3

Kirim email ke