#!/bin/sh
#
# RC script for murasaki
#   Copyright (c) by Shuu Yamaguchi <shuu@dotaster.com>
#
#   modified for Vine Linux with kernel-2.4.x
#   by MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>
#
#   $Id: rc.murasaki,v 2.4 2001/12/19 06:15:53 shuu Exp shuu $
#
#   Can be freely distributed and used under the terms of the GNU GPL.
#
# chkconfig: 2345 01 99
# description: murasaki - another hotplug for kernel >= 2.4.1
#

PATH=$PATH:/sbin:/usr/sbin;export PATH
MURASAKI_HOTPLUG=/sbin/hotplug.murasaki
MURASAKI_PRELOAD=/etc/murasaki/murasaki.preload
DEFAULT_HOTPLUG=/sbin/hotplug
PROC_PATH=/proc/sys/kernel/hotplug
MODPROBE=/sbin/modprobe
MODPROBE_OPT=-as
AUTOSETUP=/etc/murasaki/auto_setup
LOCK_FILE=/var/lock/subsys/murasaki
# OVERWITE:if you want to setup automatically every boot,
# 			you choose 'true'
OVERWRITE=true


# exit this script if the running kernel don't have /proc/sys/kernel/hotplug!
# (with kernel-2.2.x, or the kernel-2.4.x built without hotplug support)
[ ! -f ${PROC_PATH} ] && exit 1


case "$1" in
start)
	if [ ! -f ${MURASAKI_PRELOAD} -o ${OVERWRITE} = 'true' ];then
		${AUTOSETUP} > ${MURASAKI_PRELOAD}
	fi
	${MODPROBE} ${MODPROBE_OPT} `cat ${MURASAKI_PRELOAD}`
	touch ${LOCK_FILE}
	echo ${MURASAKI_HOTPLUG} > ${PROC_PATH}
	;;
stop)
	rm -f ${LOCK_FILE}
	echo ${DEFAULT_HOTPLUG} > ${PROC_PATH}
	;;
start|stop)
	$0 stop
	$0 start
	;;
*)
	echo "Usage: /etc/rc.d/init.d/murasaki {start|stop}"
	;;
esac
