en
#!/bin/sh
#
#
Environment
#
#
Amend PATH
PATH="/usr/sbin:/usr/bin:$PATH"
export PATH
#
Disk set name
diskset='
'
#
#
Functions
#
#
Echo (verbose) and exec given command, exit on error
execho () {
test -n "$verbose" && echo "$@"
"$@" || exit
}
#
Get full /dev/rdsk path of given slice
fullpath () {
case "$1" in
/dev/dsk/*|/dev/did/dsk/*) echo "$1" | sed 's/dsk/rdsk/' ;;
/*) echo "$1" ;;
*) echo /dev/rdsk/"$1" ;;
esac
}
#
Run fmthard, ignore partboot error, error if output
fmthard_special () {
ignore='Error writing partboot'
out=`fmthard "$@" 2>&1`
result=$?
echo "$out" |
case "$out" in
*"$ignore"*) grep -v "$ignore"; return 0 ;;
'') return "$result" ;;
*) cat; return 1 ;;
esac >&2
}
#
#
Main
#
#
Verify root
if [ "`id | sed 's/^[^(]*(\([^)]*\).*/\1/'`" != root ]
then
echo "
This script must be run as root.
" >&2
exit 1;
fi
#
Check for verbose option
case "$1" in
-v) verbose=1 ;;
*) verbose= ;;
esac
#
Does the disk set exist?
if metaset -s "$diskset" >/dev/null 2>&1
then
#
Take control of disk set
execho metaset -s "$diskset" -t
else
#
Create the disk set
autotakeargs=
/usr/sbin/clinfo || autotakeargs='-A enable'
execho metaset -s "$diskset" $autotakeargs -a -h `uname -n | cut -f1 -d.`
fi
#
Add disks to set
execho metaset -s "$diskset" -a {1}
#
Format slices
execho fmthard_special -d {1}:{5}:0:{2}:{3} `fullpath {4}`
0
0
4
#
Create {1} {2}
#
Does {1} exist?
metahs -s "$diskset" -i {1} >/dev/null 2>&1 || {
execho metainit -s "$diskset" {1}
}
#
Add slices to {1}
execho metahs -s "$diskset" -a {1} {2}
execho metainit -s "$diskset"
1
1
#
Associate {1} {2} with hot spare pool {3}
execho metaparam -s "$diskset" -h {1} {2}
execho metainit -s "$diskset" {1} -m {2}
-g
-r
-S
execho metattach -s "$diskset" {1} {2}
{1}
{2}
{3}
{4}
{5}
Beispielanzeige