summaryrefslogtreecommitdiff
path: root/scripts/ipmi.init.basic
blob: f12c74373772ef65915aeb407b64fec401a22e2b (plain)
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
#!/bin/sh
#
# ipmi:      OpenIPMI Driver init script (basic only)
# Author:    Andy Cress
#
# chkconfig: - 13 87
# description: OpenIPMI Driver init script
#
#    Use this if the Linux distro does not provide one.
#Sample script to install it without chkconfig:
#=====
#ipmisvc=/etc/init.d/ipmi
#cp -f ipmi.init.basic  $ipmisvc
#ln -s $ipmisvc /etc/rc0.d/K87ipmi
#ln -s $ipmisvc /etc/rc1.d/K87ipmi
#ln -s $ipmisvc /etc/rc6.d/K87ipmi
#ln -s $ipmisvc /etc/rc2.d/S13ipmi
#ln -s $ipmisvc /etc/rc3.d/S13ipmi
#ln -s $ipmisvc /etc/rc4.d/S13ipmi
#ln -s $ipmisvc /etc/rc5.d/S13ipmi
#=====
#
rv=0

start() {
  lsmod |grep ipmi_dev >/dev/null
  if [ $? -ne 0 ]; then
     echo "Starting OpenIPMI driver ..."
     # load the ipmi modules, if not already loaded or builtin
     cat /proc/kallsyms |grep ipmi_init_msghandler >/dev/null 2>&1
     if [ $? -ne 0 ]; then
	modprobe ipmi_msghandler
     fi
     cat /proc/kallsyms |grep init_ipmi_si >/dev/null 2>&1
     if [ $? -ne 0 ]; then
        modprobe ipmi_si  
        rv=$?
        if [ $rv -ne 0 ]; then
	   modprobe ipmi_si_drv # try old module name
        fi
     fi
     modprobe ipmi_devintf
     modprobe ipmi_watchdog 2>/dev/null
  fi

  maj=$(cat /proc/devices | awk '/ipmidev/{print $1}')
  if [ "x$maj" != "x" ]; then
      test -e /dev/ipmi0 && rm -f /dev/ipmi0
      /bin/mknod /dev/ipmi0 c $maj 0
  fi
}

stop() {
  lsmod |grep ipmi_msghandler >/dev/null
  if [ $? -eq 0 ]; then
     echo "Stopping OpenIPMI driver ..."
     rmmod ipmi_poweroff 2>/dev/null
     rmmod ipmi_watchdog 2>/dev/null
     rmmod ipmi_devintf  2>/dev/null
     rmmod ipmi_si 
     rv=$?
     rmmod ipmi_msghandler 
  else 
     rv=2
  fi
}

status() {
  lsmod |grep ipmi
  rv=$?
}

case "$1" in 
  start) start ;;
  stop)  stop ;;
  status)  status ;;
  *) start ;;
esac

exit $rv