File: halt.in

package info (click to toggle)
apcupsd 3.10.17-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 16,616 kB
  • ctags: 6,941
  • sloc: ansic: 42,075; sh: 7,896; cpp: 3,561; makefile: 2,001; perl: 1,469; tcl: 368; sed: 93
file content (74 lines) | stat: -rw-r--r-- 1,410 bytes parent folder | download | duplicates (24)
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
#! /bin/sh
# Copyright (c) 1996 S.u.S.E. GmbH Fuerth, Germany.  All rights reserved.
#
# Author: Florian La Roche <florian@suse.de>, 1996
#	  Werner Fink <werner@suse.de>, 1996
#
#	Updated for "apcupsd"
#	  Andre M. Hedrick <hedrick@astro.dyer.vanderbilt.edu>, 1997
#
# /sbin/init.d/halt (and symlinked to reboot)
#

. /etc/rc.config

case "$0" in
	*halt)
		message="The system is halted."
		command="halt"
		;;
	*reboot)
		message="Please stand by while rebooting the system..."
		command="reboot"
		;;
	*)
		echo "$0: call me as \"halt\" or \"reboot\" please!"
		exit 1
		;;
esac

# Write to wtmp file before unmounting /var
$command -w 

echo "Sending all processes the TERM signal..."
killall5 -15

if [ "$1" = "fast" ]; then
	sleep 1
else
	sleep 5
fi

echo "Sending all processes the KILL signal..."
killall5 -9

echo "Turning off swap."
sync ; sync
swapoff -a

echo "Unmounting file systems"
umount -av

# maybe we use Multiple devices
if test -f /etc/mdtab -a -x /sbin/mdadd ; then
    echo -n "Disable Multiple Devices"
    /sbin/mdstop -a
    echo "."
fi

# See if this is a powerfail situation.
if [ -f @PWRFAILDIR@/powerfail ]; then
  echo
  echo "Apcupsd will now power off the UPS!"
  echo
  @sysconfdir@/apccontrol killpower
  echo
fi

# on umsdos fs this would lead to an error message. so direct errors to
# /dev/null
mount -no remount,ro / 2> /dev/null
sync

echo $message
exec $command -d -f