5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
26 #ident "%Z%%M% %I% %E% SMI"
28 # If the /etc/power.conf file does not have a "statefile" entry
29 # to specify the pathname of the cpr statefile, build one and
30 # add the line. We choose the largest of the standard Sun partitions.
32 init_statefile_entry
() {
33 [ ! -f /etc
/power.conf
-o ! -w /etc
/power.conf
] && return
35 # Whitespace regular expression below is [<TAB><SPACE>]
37 pattern
="^[ ]*statefile[ ][ ]*/"
38 [ `/usr/bin/grep -c "$pattern" /etc/power.conf` -ge 1 ] && return
40 avail
=0 # Free blocks in current filesystem
41 max_avail
=0 # Most available free blocks encountered so far
42 statefile
=.CPR
# Default cpr statefile name
44 # Remove old statefile (if any) from root
45 [ -f /$statefile ] && /usr
/bin
/rm -f /$statefile
47 /usr
/bin
/df
-k -F ufs |
49 read line
# Skip past the header line of the df output
51 while read device kbytes used avail capacity filesys
; do
53 /|
/usr|
/var|
/export
/home
)
54 if [ $avail -gt $max_avail ]; then
62 if [ $max_avail -gt 0 ]; then
63 echo "statefile ${winner}/${statefile}" \
69 if [ $max_avail -eq 0 ]; then
70 if [ X
`df -n / | awk '{print $3}'` != "Xzfs" ] ; then
73 rootpool
=`zfs mount | grep ' \/$' | awk '{print $1 }' |\
75 if [ X
$rootpool = "X" ] || \
76 [ ! -L /dev
/zvol
/dsk
/$rootpool/dump
]; then
79 echo "statefile /dev/zvol/dsk/$rootpool/dump" \
86 /usr
/sbin
/uadmin
3 2 2>/dev
/null
91 if [ -x /usr
/sbin
/pmconfig
-a -r /etc
/power.conf
]; then
92 /usr
/sbin
/pmconfig
>/dev
/console
2>&1
97 if [ -x /usr
/sbin
/pmconfig
]; then
98 /usr
/sbin
/pmconfig
-r >/dev
/null
2>/dev
/null
103 echo "Usage: $0 { start | stop }"