File: blcr.rc

package info (click to toggle)
blcr 0.8.5-2.3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 10,740 kB
  • sloc: ansic: 31,999; sh: 12,633; makefile: 929; perl: 401; cpp: 79; java: 9
file content (107 lines) | stat: -rw-r--r-- 2,071 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
#
# chkconfig:	345 90 01
# description:  Load and unload BLCR kernel modules
#
# $Id: blcr.rc,v 1.17.14.1 2013/01/15 03:50:01 phargrov Exp $

# The only likely configuration is these three variables:
PATH=/bin:/sbin:/usr/bin:/usr/sbin
module_dir=@MODULE_DIR@
if [ -d /var/lock/subsys ]; then
  blcr_lock=/var/lock/subsys/blcr
else
  blcr_lock=/var/lock/blcr
fi

# Default versions if disto-specific ones are lacking.
success() {
  echo "Success!"
}
failure() {
  echo "Failure!"
}

if [ -f /etc/init.d/functions ]; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
fi

do_checkmod() {
	lsmod | grep "^$1 " >/dev/null 2>&1
	return $?
}

# Try modprobe by default, but fallback on insmod+fullpath
do_insmod() {
	modprobe $1 || (do_checkmod $1 || insmod ${module_dir}/${1}.ko)
}

# Try modprobe -r by default, but fallback on rmmod
do_rmmod() {
	modprobe -r $1 || (do_checkmod $1 && rmmod $1)
}

do_start() {
	echo -n "Loading BLCR: "
	if test ! -d ${module_dir}; then
	    echo -n "no ${module_dir} "
	    failure
	else
	    (do_insmod blcr_imports && \
	     do_insmod blcr && \
	     touch $blcr_lock && success) || failure
	fi
	echo
}

do_stop() {
	echo -n "Unloading BLCR: "
	(do_rmmod blcr && \
	 do_rmmod blcr_imports && \
	 rm -f $blcr_lock && success) || failure
	echo
}

case "$1" in
  start)
	do_start
	;;
  stop) 
	do_stop
	;;
  restart | force-reload)
	do_stop
	do_start
	;;
  reload)
	if [ -f $blcr_lock ]; then
	    do_stop
	    do_start
	fi
	;;
  status)
	if [ -f $blcr_lock ]; then
	    do_checkmod blcr && rc1=1 || rc1=0
	    do_checkmod blcr_imports && rc2=1 || rc2=0
	    if [ "x$rc1$rc2" != "x11" ] ; then
		msg="BLCR subsytem lock exists, but the following is/are not loaded:"
		[ $rc1 -ne 1 ] && msg="$msg blcr"
		[ $rc2 -ne 1 ] && msg="$msg blcr_imports"
		echo "$msg"
		exit 2
	    fi
	    echo "BLCR subsytem is active"
	    exit 0
	else
	    echo "BLCR subsytem is stopped"
	    exit 3
	fi
	;;
  *)
	echo "*** Usage: blcr {start|stop|restart|reload|status}"
	exit 1
esac

exit 0