|
@@ -4,10 +4,15 @@ DIR="/home/ravioli/newdisk-automator"
|
|
|
|
|
|
. "${DIR}/error.sh"
|
|
|
. "${DIR}/parse-arguments.sh"
|
|
|
+. "${DIR}/utils.sh"
|
|
|
+. "${DIR}/check-device.sh"
|
|
|
|
|
|
PROGRAM_NAME="$0"
|
|
|
|
|
|
parse_arguments $@
|
|
|
+echo $DEVICE_SIZE
|
|
|
+echo $RAM_SIZE
|
|
|
+exit
|
|
|
|
|
|
DEVICE=$1
|
|
|
SWAP_SIZE=$2
|
|
@@ -16,30 +21,9 @@ TEMP_SIZE=$4
|
|
|
VM_SIZE=$5
|
|
|
|
|
|
|
|
|
-# checking if the disk is used
|
|
|
-if [ ! -e ${DEVICE} ] ; then
|
|
|
- fatal ${NOTEX_E} "${DEVICE} does not exist"
|
|
|
-fi
|
|
|
-if [ ! -b ${DEVICE} ] ; then
|
|
|
- fatal ${NOTBLK_E} "${DEVICE} is not a block file"
|
|
|
-fi
|
|
|
-if grep --quiet "${DEVICE}" /proc/mounts ; then
|
|
|
- fatal ${ISMOUNT_E} "${DEVICE} is mounted"
|
|
|
-fi
|
|
|
-if grep --quiet "${DEVICE}" /proc/swaps ; then
|
|
|
- fatal ${ISSWAP_E} "${DEVICE} is udes as swap"
|
|
|
-fi
|
|
|
-
|
|
|
-if pvs | grep --quiet "${DEVICE}" ; then
|
|
|
- if [ $(lvs --noheadings --select vg_name="$(pvs --noheadings --select pv_name=~"${DEVICE}" -o vg_name)" --select lv_device_open!=0 | wc -l) -ne 0 ] ; then
|
|
|
- fatal ${LVMUSED_E} "${DEVICE} is part of a used lvm volume"
|
|
|
- fi
|
|
|
- if [ $(vgs --noheadings --select pv_name=~"${DEVICE}" -o pv_count | uniq) -gt $(vgs --noheadings --select pv_name=~"${DEVICE}" | wc -l) ] ; then
|
|
|
- fatal ${LVMPV_E} "${DEVICE} is part of a lvm volume group shared with other physical volumes"
|
|
|
- fi
|
|
|
-
|
|
|
- # removing lvm and other filesystem signatures)
|
|
|
- echo "Eresing disk signatures..."
|
|
|
+# removing lvm and other filesystem signatures)
|
|
|
+if [ $LVM == 1]
|
|
|
+ echo "Erasing disk signatures..."
|
|
|
vgchange -an $(vgs --noheadings --select pv_name=~"${DEVICE}" -o vg_name)
|
|
|
wipefs -a ${DEVICE}[[:digit:]]*
|
|
|
wipefs -a ${DEVICE}
|