Move cleargpt.sh and cleargmirror.sh scripts to main repo

This commit is contained in:
Renato Botelho 2015-07-27 17:05:05 -03:00
parent f8948f8637
commit 31e66b412d
2 changed files with 39 additions and 0 deletions

26
usr/local/sbin/cleargmirror.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
clear_disk() {
local _disk="${1}"
local _mirror=$(/sbin/gmirror dump ${_disk} 2>/dev/null | sed '/name: /!d; s,^.*: ,,')
if [ -n "${_mirror}" ]; then
/sbin/gmirror destroy -f ${_mirror} >/dev/null 2>&1
fi
/sbin/gmirror clear ${_disk} >/dev/null 2>&1
}
mirror="${1}"
disk1="${2}"
disk2="${3}"
if [ -z "${mirror}" -o -z "${disk1}" -o -z "${disk2}" ]; then
echo "You must specify mirror name, and disks that should be cleared"
exit 1
fi
/sbin/gmirror destroy -f ${mirror} >/dev/null 2>&1
clear_disk ${disk1}
clear_disk ${disk2}
exit 0

13
usr/local/sbin/cleargpt.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
DISK=$1
if [ "$DISK" = "" ]; then
echo "You must specify the disk that should be formatted/cleared."
exit 1
fi
for PART in `/sbin/gpart show $DISK | grep -v '=>' | awk '{ print $3 }'`; do
if [ "$PART" != "" ]; then
/sbin/gpart delete -i $PART $DISK >/dev/null
fi
done
/sbin/gpart destroy $DISK >/dev/null
exit 0