summaryrefslogtreecommitdiff
path: root/extra/kexec-tools/kexec
blob: bef5b5ef35f20d66d18f73b0241dfb5e22cad23a (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
#!/bin/bash

[ -f /etc/conf.d/kexec ] && . /etc/conf.d/kexec

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
  start)
      stat_busy "Enabled loading kernel for Kexec into running kernel on reboot"
      add_daemon kexec
      stat_done
  ;;
  
  stop|load)
    if [ "$RUNLEVEL" = "6" -o "$1" = "load" ]; then
      stat_busy "Loading kernel for Kexec into running kernel"
      [ -f "$KPATH" ] || stat_fail
      [ -f "$INITRD" ] && _INITRD="--initrd=$INITRD"
      /sbin/kexec -l $KPATH --append="root=$ROOTPART $KPARAM" $_INITRD > /dev/null 2>&1
    else
      stat_busy "Skipping loading kernel for Kexec into running kernel"
    fi
    if [ $? -eq 0 ] ; then
      rm_daemon kexec
      stat_done
    else
      stat_fail
    fi  
  ;;

  unload)
    stat_busy "Unloading Kexec kernel from running kernel"
    /sbin/kexec -u
    if [ $? -eq 0 ] ; then
      stat_done
    else
      stat_fail
    fi
  ;;

  *)
    echo "usage: $0 {start|stop|load|unload}"  
esac
exit 0