#!/bin/bash
# -*- Mode: shell-script -*-
# Copyright (C) 2003 by MandrakeSoft, Chmouel Boudjnah <chmouel@mandrakesoft.com>
# Redistribution of this file is permitted under the terms of the GNU 
# Public License (GPL)
#
# suspend: 30
# resume: 20
#

. /etc/sysconfig/suspend

ARG=$1

function suspend {
    if [[ $RESTART_NFS == "yes" ]];then
	service netfs stop
    fi

    if [[ $RESTART_NETWORK = "yes" ]];then
	service network stop
	interfaces=`/sbin/modprobe -c |grep eth[0-9]|sed 's/alias eth[0-9] //g'`
	for i in $interfaces; do
	    /sbin/modprobe -r $i
	done
    fi
}

function resume {
    if [[ $RESTART_NETWORK == "yes" ]];then
	service network start
	sync
    fi
    if [[ $RESTART_NFS == "yes" ]];then
	service netfs start
	sync
    fi
}

case $ARG in
    suspend)
	suspend
	;;
    resume)
	resume
	;;
esac