#!/bin/ksh #ident "@(#)hiber 3.2 98/11/10 ynp@ynp.net" # # This script takes care of all routine procedures needed to # be performed each time the notebook goes to suspend mode # (section `stop') and gets resumed (section `start'). # What it basically does is deactivates (before suspending) # drivers for those devices - PCMCIA network and modem cards # and sound system - that are most affected by suspend/resume # cycle, and activates (after resuming) those that were # deactivated at suspend time. # This one definitely works on Tecra 550CDT, although other # models may require similar treatment of suspend mode. # # Syntax: hiber [ -nms ] { on | off } # # -n (de)activate PCMCIA NIC driver (pcelx); # -m (de)activate PCMCIA modem driver (pcser); # -s (de)activate OSS audio driver (oss); # (default is act upon all three devices); # on prepare system for going suspend mode; # off restore system after resuming operations. typeset -r SCRIPT=$(basename $0) typeset -r NET=pcelx typeset -r INT=${NET}0 typeset -r IP=192.168.254.118 typeset -r MDM=pcser typeset -r SND=oss typeset -r DELAY=1 typeset -r MIX_PCM=100 MIX_CD=80 typeset -r SETUP=/etc/opt/hiber.cf typeset DO_NET=no DO_MDM=no DO_SND=no typeset MODID CONF usage () { print -u2 " $SCRIPT 3.1 98/10/04 ynp@ynp.net Syntax: $SCRIPT [ -nms ] { on | off } -n (de)activate network driver (pcelx); -m (de)activate serial driver (pcser); -s (de)activate audio driver (oss); (default is act upon all three devices); on prepare system for going to suspend mode; off restore system after resuming operations. " exit 1 } loaded () { MODID=$(modinfo 2>/dev/null | awk "\$6 == \"$1\" {print \$1}") if [[ -n "$MODID" ]]; then return 0 fi return 1 } plumbed () { CONF=$(ifconfig $1 2>/dev/null) if [[ -n "$CONF" ]]; then return 0 fi return 1 } while getopts :nms DO; do case $DO in (n) DO_NET=yes;; (m) DO_MDM=yes;; (s) DO_SND=yes;; (?) usage;; esac done shift $(($OPTIND - 1)) if [[ $DO_NET$DO_MDM$DO_SND = nonono ]]; then if [[ "$1" = off && -s $SETUP ]]; then . $SETUP else DO_NET=yes DO_MDM=yes DO_SND=yes fi fi case "$1" in (off|stop) if [[ $DO_NET = yes ]]; then # reload PCMCIA NIC card driver module and recreate interface if loaded $NET; then : else print "Loading network driver module ($NET) ..." modload -p drv/$NET sleep $DELAY fi if loaded $NET; then if plumbed $INT; then : else print "Bringing up interface ($INT) ..." ifconfig $INT plumb sleep $DELAY ifconfig $INT $IP up fi fi fi if [[ $DO_MDM = yes ]]; then # reload PCMCIA modem card driver module if loaded $MDM; then : else print "Loading modem driver module ($MDM) ..." modload -p drv/$MDM sleep $DELAY fi fi if [[ $DO_SND = yes ]]; then # reload sound driver module and reset mixer if loaded $SND; then : else print "Loading sound driver module ($SND) ..." soundon fi if loaded $SND; then print "Resetting mixer ..." ossmix pcm $MIX_PCM cd $MIX_CD fi fi ;; (on|start) >$SETUP if [[ $DO_NET = yes ]]; then # shut down interface and unload PCMCIA NIC card driver module if plumbed $INT; then print "Bringing down interface ($INT) ..." ifconfig $INT unplumb fi if loaded $NET; then print "Unloading network driver module ($NET) ..." sleep $DELAY modunload -i $MODID print DO_NET=yes >>$SETUP else print DO_NET=no >>$SETUP fi else print DO_NET=no >>$SETUP fi if [[ $DO_MDM = yes ]]; then # unload PCMCIA modem card driver module if loaded $MDM; then print "Unloading modem driver module ($MDM) ..." sleep $DELAY modunload -i $MODID print DO_MDM=yes >>$SETUP else print DO_MDM=no >>$SETUP fi else print DO_MDM=no >>$SETUP fi if [[ $DO_SND = yes ]]; then # unload sound driver module if loaded $SND; then print "Unloading sound driver module ($SND) ..." soundoff print DO_SND=yes >>$SETUP else print DO_SND=no >>$SETUP fi else print DO_SND=no >>$SETUP fi ;; (*) usage ;; esac