Don Marti

Fri 31 Oct 2008 10:56:57 AM PDT

Up and down scripts for wwwoffle

I use the World Wide Web Offline Explorer to keep a local copy of frequently used pages for offline use and when I'm on a slow link. Here are a couple of scripts to put it in online or offline mode when networking comes up or down. Suggestions welcome.

for if-up.d

    #!/bin/sh -e
    # if-up.d script for wwwoffle:
    # Called when a new interface comes up
    # By Don Marti <dmarti@zgp.org>
    # Based on script for Postfix 
    #   by LaMont Jones <lamont@debian.org>

    # don't bother when lo is configured.
    if [ "$IFACE" = "lo" ]; then
        exit 0
    fi

    # If /var isn't mounted yet, silently bail.
    if [ ! -d /var/cache/wwwoffle ]; then
        exit 0
    fi

    /usr/bin/wwwoffle -online

for if-post-down.d

    #!/bin/sh -e

    # if-post-down.d script for wwwoffle:
    # Called when an interface disconnects
    # By Don Marti <dmarti@zgp.org>
    # Based on script for Postfix 
    #  by LaMont Jones <lamont@debian.org>

    # If /var isn't mounted yet, silently bail.
    if [ ! -d /var/cache/wwwoffle ]; then
        exit 0
    fi


    # If there's no more route to the outside 
    # after this disconnection, put wwwoffle
    # in offline mode.

    /sbin/route -n | /bin/grep -q '^0.0.0.0' \
      || /usr/bin/wwwoffle -offline

Next step...scripts to bring a set of ssh tunnels up and down.