Re: FC2 Ethernet and Wireless settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So my general modus operandi is to boot the laptop, suspend using the
/root/idle script, and resume.  Lid close is set to do nothing, so
there's really no other way to suspend.

Note that tihs script is highly customized for my environment, so it
may not fit yours.  But the ideas are all good, so feel free to pick
and choose the pieces you need/want.

IMPORTANT: I am running rh8 on this laptop, so the actual suspend
method will vary.  I currently cannot suspend, due to acpi not doing
the right thing in 2.4.

one last note before I paste in the script.  I also put in a "killall
-STOP mozilla-bin" into the acpi scripts, and triggered it off the lid
switch detection.  killall -CONT mozilla-bin afterwards.  mozilla
still has the insane bookmark code from netscape that writes out its
bookmark file EVERY MINUTE. keeping the disk spinning, plus eating up
of cpu from animated gif's, flash, etc.

   - Kevin

also available at http://rightsock.com/~kjw/Tech/idle.sh.txt to get
the tabs right.

#!/bin/sh

# usage: $0 [-f] [-n]
# -f = force. no network checks
# -n = not really. do everything but actual suspend

# presumption: eth0 is always the pcmcia.
# my config: builtin ethernet isn't insmod'ed by default, so the system
# just doesn't know it's there.
if ifconfig eth0 >/dev/null 2>&1 ; then

    # check if there is any pending network activity
    if [ " $1" = ' -f' ] ; then
        # -f is specified, skip the network checks
        echo 'Skipping network checks'
        shift 1
    else # no -f found; normal code path

        # check mailq
        MAILQ=`mailq -Ac`
        # rh6.2: while [ "$MAILQ" != 'Mail queue is empty' ] ; do
        # rh7.0: while [ "$MAILQ" != '/var/spool/mqueue is empty' ] ; do
        # rh8.0: while [ "$MAILQ" != '/var/spool/mqueue is empty
#       Total requests: 0' ] ; do
        # rh8.0 client mqueue: (yes, multiline. WHITESPACE IMPORTANT)
        while [ "$MAILQ" != '/var/spool/clientmqueue is empty
        Total requests: 0' ] ; do
            echo 'mail pending. press enter to retry, or -f to override'
            echo "$MAILQ"
            read LINE
            if [ "$LINE" = '-f' ] ; then break ; fi
            MAILQ=`mailq -Ac`
            done
        service sendmail stop

        # check for active tcp connections
        # ignore :25 connections, as the mailq test has that covered
        # ignore web, other 'pending close' states
        # ignore X11 connections. only thing I ever use is x2x
        NETSTAT="`netstat -n --inet 2>&1 | egrep -v '(:25
|TIME_WAIT|FIN_WAIT|CLOS|LAST_ACK|127.0.0.1:|:80 |:443 |:6000 )' `"
        while [ `echo "$NETSTAT" | wc -l` != 2 ] ; do
            echo 'network connections still active. press enter to
retry, or -f to override'
            # by default, only print out the filtered netstat
            echo "$NETSTAT"
            read LINE
            if [ "$LINE" = '-f' ] ; then break ; fi
            NETSTAT="`netstat -n --inet 2>&1 | egrep -v '(:25
|TIME_WAIT|FIN_WAIT|CLOS|LAST_ACK|127.0.0.1:|:80 |:443 |:6000 )' `"
            done
        fi # endif cmd line -f

    # shut down networking
    killall dhcpcd
    ifconfig eth0 down
    # sometimes the wired ethernet is there, but since it's not my
    # normal connection, it must've been temporary
    ifconfig eth1 >/dev/null 2>&1 && ifconfig eth1 down
    rmmod 3c59x
else
    echo 'No network; skipping checks'
    fi

# since I can't suspend with 2.4 acpi, additionally disable certain
# daemons because they eat cpu, and thus power
# lpd reads from disk every minute
service lpd stop
# fetchmail is how I get my mail. obviously useless if the network is down.
# PAUSE it only
killall -STOP fetchmail

# if I can suspend
if false ; then
    # eject card if possible
    #cardctl eject

    # report on battery condition
    apm

    # suspend
    if [ " $1" != ' -n' ] ; then
        sleep 2
        # -n not found; normal code path
        apm --suspend
    else # -n is specified, skip the actual suspend process
        echo 'Not really suspending...'
        fi

    # TODO: wait for eth0 to be up! else all below will fail

    fi

# if I can acpi low-power
if true ; then
    # enter low power state
    echo 4 >/proc/acpi/sleep

    echo "Press enter to revive"
    read

    echo "Getting new dhcp lease"

    # Work network is doubled, because sometimes the dhcp server
    # isn't responsive.
    # NOTE: you can press ctrl-c to skip over various networks
    # without interrupting this script
    for TRY in any Work Work any Work Work any Work Work
        do
        echo "Looking for $TRY network"
        /usr/local/etc/iwkey $TRY
        if dhcpcd -t 10 eth0 ; then break ; fi
        done

    fi

# communicate to the user that eth0 is up now
ifconfig eth0

# resume fetchmail
killall -CONT fetchmail

# kjw hack - I can't send mail directly from my laptop any more because
# of 1- dynamic addresses being blocked and 2- firewall at work, so
# sm-client starts the sendmail client, and an ssh-tunnel to my colo box,
# listening on 127.0.0.1:25.  This way I can locally queue messages for
# later delivery, yet still deliver through the colo, which is a trusted
# mail server.
#service sendmail start
service sm-client start

service lpd start

# immediately switch back into X
chvt 7

exit 0


On Wed, 11 Aug 2004 14:18:15 +1000, Peter Smith <pasmith@xxxxxxxxxxxx> wrote:
> I would like to see Kevin's scripts too.  Is there anything on ifconfig,
> iwconfig and route for beginners?  Google helped me get this far, but I
> don't really know what I am doing :-).



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux