#! /bin/bash
#
#
network Bring up/down fc
#
# chkconfig: 2345 10 90
# description: Activates/Deactivates all fc
#
### BEGIN INIT INFO
# Provides: $fc
# Should-Start: iptables ip6tables
# Short-Description: Bring up/down fc
# Description: Bring up/down fc
### END INIT INFO
# Source function library.
. /etc/init.d/functions
# See how we were called.
case "$1" in
start)
# Check if /home is mounted
HOMEMOUNT=$(mount | grep test | sed 's/ .*//' | sed
's#.*/##' )
# Load module if not already loaded
if [[ ! "$(eval lsmod | grep "^flashcache")" ]];
then
modprobe flashcache
fi
# Mount flashcache /test if not already mounted
if [[ ! "$HOMEMOUNT" == "cachedev" ]]; then
umount /test
if [ ! -e /dev/mapper/cachedev ];
then
flashcache_load /dev/sdc
fi
mount /dev/mapper/cachedev
/test
fi
;;
stop)
# Check if /home is mounted
HOMEMOUNT=$(mount | grep test | sed 's/ .*//' | sed
's#.*/##' )
# Load module if not already loaded
if [[ ! "$(eval lsmod | grep "^flashcache")" ]];
then
modprobe flashcache
fi
# Mount flashcache /test if not already mounted
if [[ ! "$HOMEMOUNT" == "cachedev" ]]; then
umount /test
if [ ! -e /dev/mapper/cachedev ];
then
flashcache_load /dev/sdc
fi
mount /dev/mapper/cachedev
/test
fi
;;
status)
# Check if /home is mounted
HOMEMOUNT=$(mount | grep test | sed 's/ .*//' | sed
's#.*/##' )
# Load module if not already loaded
if [[ ! "$(eval lsmod | grep "^flashcache")" ]];
then
modprobe flashcache
fi
# Mount flashcache /test if not already mounted
if [[ ! "$HOMEMOUNT" == "cachedev" ]]; then
umount /test
if [ ! -e /dev/mapper/cachedev ];
then
flashcache_load /dev/sdc
fi
mount /dev/mapper/cachedev
/test
fi
;;
restart|reload|force-reload)
# Check if /home is mounted
HOMEMOUNT=$(mount | grep test | sed 's/ .*//' | sed
's#.*/##' )
# Load module if not already loaded
if [[ ! "$(eval lsmod | grep "^flashcache")" ]];
then
modprobe flashcache
fi
# Mount flashcache /test if not already mounted
if [[ ! "$HOMEMOUNT" == "cachedev" ]]; then
umount /test
if [ ! -e /dev/mapper/cachedev ];
then
flashcache_load /dev/sdc
fi
mount /dev/mapper/cachedev
/test
fi
;;
*)
echo $"Usage: $0
{start|stop|status|restart|reload|force-reload}"
exit 2
esac