Removed extraneous comment lines, added some in return.

master
BrainwreckedTech 5 years ago
parent da824eac17
commit 277d64be34

@ -1,7 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
sectors_to_size() { sectors_to_size() {
SIZE=$(( ${1} * 512 )) SIZE=$(( ${1} * 512 ))
MAG=0 MAG=0
until [ $(awk "BEGIN { print ${SIZE} < 1000 }") -eq 1 ]; do until [ $(awk "BEGIN { print ${SIZE} < 1000 }") -eq 1 ]; do
@ -20,9 +19,7 @@ sectors_to_size() {
} }
[ $EUID -gt 0 ] && "Must run as superuser." && exit 1 [ $EUID -gt 0 ] && "Must run as superuser." && exit 1
#[ ! -b "${1}" ] && "${1} is not a block device." && exit 2
#for DEVICE in $(fdisk -l | grep '^Disk /' | cut -d\ -f2 | cut -d: -f1); do
for DEVICE in $(fdisk -l | grep '^Disk /' | grep -v '/dev/ram' | cut -d\ -f2 | cut -d: -f1); do for DEVICE in $(fdisk -l | grep '^Disk /' | grep -v '/dev/ram' | cut -d\ -f2 | cut -d: -f1); do
FDISKDATA="$(fdisk -l "${DEVICE}")" FDISKDATA="$(fdisk -l "${DEVICE}")"
@ -73,6 +70,8 @@ for DEVICE in $(fdisk -l | grep '^Disk /' | grep -v '/dev/ram' | cut -d\ -f2 |
OVERFLOW=$(( ${PRINTCOLS} + ${LCV} + 1 - ${COLS} )) OVERFLOW=$(( ${PRINTCOLS} + ${LCV} + 1 - ${COLS} ))
####### TOP LINE #######
printf "%s" "┌" printf "%s" "┌"
for (( LCV = 0; LCV < ${#PARTITIONS[@]}; LCV++ )); do for (( LCV = 0; LCV < ${#PARTITIONS[@]}; LCV++ )); do
[ ${LCV} = $(( ${#PARTITIONS[@]} - 1 )) ] && (( PCOLS[${LCV}]-=${OVERFLOW} )) [ ${LCV} = $(( ${#PARTITIONS[@]} - 1 )) ] && (( PCOLS[${LCV}]-=${OVERFLOW} ))
@ -81,6 +80,8 @@ for DEVICE in $(fdisk -l | grep '^Disk /' | grep -v '/dev/ram' | cut -d\ -f2 |
done done
printf "%s\n" "┐" printf "%s\n" "┐"
##### DEVICE NAME ######
printf "%s" "│" printf "%s" "│"
for (( LCV = 0; LCV < ${#PARTITIONS[@]}; LCV++ )); do for (( LCV = 0; LCV < ${#PARTITIONS[@]}; LCV++ )); do
OUTPUT=${PARTITIONS[${LCV}]##*/} OUTPUT=${PARTITIONS[${LCV}]##*/}
@ -91,16 +92,7 @@ for DEVICE in $(fdisk -l | grep '^Disk /' | grep -v '/dev/ram' | cut -d\ -f2 |
done done
printf "%s\n" "│" printf "%s\n" "│"
#echo -n "│" #### PARTITION SIZE ####
#for (( LCV = 0; LCV < ${#PARTITIONS[@]}; LCV++ )); do
# OUTPUT=${PARTSECTS[${LCV}]}s
# WIDTH=$(awk "BEGIN { print int ( ${PARTSIZES[${LCV}]} * ${FACTOR} + 0.5 ) }")
# PADL=$(( ( ${WIDTH} - ${#OUTPUT} ) / 2 ))
# PADR=$(( ${WIDTH} - ${#OUTPUT} - ${PADL} ))
# echo -n "$(printf '%*s%s%*s' ${PADL} "" ${OUTPUT} ${PADR} "")"
# [ ${LCV} -lt $(( ${#PARTITIONS[@]} - 1 )) ] && echo -n "│"
#done
#echo "│"
printf "%s" "│" printf "%s" "│"
for (( LCV = 0; LCV < ${#PARTITIONS[@]}; LCV++ )); do for (( LCV = 0; LCV < ${#PARTITIONS[@]}; LCV++ )); do
@ -112,9 +104,10 @@ for DEVICE in $(fdisk -l | grep '^Disk /' | grep -v '/dev/ram' | cut -d\ -f2 |
done done
printf "%s\n" "│" printf "%s\n" "│"
#### PARTITION TYPE ####
printf "%s" "│" printf "%s" "│"
for (( LCV = 0; LCV < ${#PARTITIONS[@]}; LCV++ )); do for (( LCV = 0; LCV < ${#PARTITIONS[@]}; LCV++ )); do
#OUTPUT=$(blkid -o export "${PARTITIONS[${LCV}]}" | grep '^LABEL=' | cut -d= -f2)
OUTPUT=$(blkid -o export "${PARTITIONS[${LCV}]}" | grep '^\(TYPE=\)' | cut -d= -f2 | sed 's:linux_raid_member:raid:g') OUTPUT=$(blkid -o export "${PARTITIONS[${LCV}]}" | grep '^\(TYPE=\)' | cut -d= -f2 | sed 's:linux_raid_member:raid:g')
PADL=$(( ( ${PCOLS[${LCV}]} - ${#OUTPUT} ) / 2 )) PADL=$(( ( ${PCOLS[${LCV}]} - ${#OUTPUT} ) / 2 ))
PADR=$(( ${PCOLS[${LCV}]} - ${#OUTPUT} - ${PADL} )) PADR=$(( ${PCOLS[${LCV}]} - ${#OUTPUT} - ${PADL} ))
@ -123,9 +116,10 @@ for DEVICE in $(fdisk -l | grep '^Disk /' | grep -v '/dev/ram' | cut -d\ -f2 |
done done
printf "%s\n" "│" printf "%s\n" "│"
### FILESYSTEM LABEL ###
printf "%s" "│" printf "%s" "│"
for (( LCV = 0; LCV < ${#PARTITIONS[@]}; LCV++ )); do for (( LCV = 0; LCV < ${#PARTITIONS[@]}; LCV++ )); do
#OUTPUT=$(blkid -o export "${PARTITIONS[${LCV}]}" | grep '^LABEL=' | cut -d= -f2)
OUTPUT=$(blkid -o export "${PARTITIONS[${LCV}]}" | grep '^\(LABEL=\)' | cut -d= -f2) OUTPUT=$(blkid -o export "${PARTITIONS[${LCV}]}" | grep '^\(LABEL=\)' | cut -d= -f2)
PADL=$(( ( ${PCOLS[${LCV}]} - ${#OUTPUT} ) / 2 )) PADL=$(( ( ${PCOLS[${LCV}]} - ${#OUTPUT} ) / 2 ))
PADR=$(( ${PCOLS[${LCV}]} - ${#OUTPUT} - ${PADL} )) PADR=$(( ${PCOLS[${LCV}]} - ${#OUTPUT} - ${PADL} ))
@ -134,6 +128,8 @@ for DEVICE in $(fdisk -l | grep '^Disk /' | grep -v '/dev/ram' | cut -d\ -f2 |
done done
printf "%s\n" "│" printf "%s\n" "│"
##### BOTTOM LINE ######
echo -n "└" echo -n "└"
for (( LCV = 0; LCV < ${#PARTITIONS[@]}; LCV++ )); do for (( LCV = 0; LCV < ${#PARTITIONS[@]}; LCV++ )); do
printf '─%.0s' $(seq 1 ${PCOLS[${LCV}]}) printf '─%.0s' $(seq 1 ${PCOLS[${LCV}]})

Loading…
Cancel
Save