Created
March 26, 2014 20:05
-
-
Save Thanatermesis/9791996 to your computer and use it in GitHub Desktop.
This is a (not working) demo file about a problem with the automated indenting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source /usr/lib/elive-tools/functions | |
main(){ | |
# pre {{{ | |
local disk partition | |
# ways to get partitions: | |
# lsblk -f | |
# /proc/partitions | |
# sfdisk | fdisk | |
# fdisk -l /dev/[sh]d? | |
# more info (size, fs, etc) | |
# parted /dev/sda print | |
# show uuid|label: | |
# blkid | |
# udevadm info --query=all --name=/dev/mapper/vg_rootdisk-lv_var | |
# }}} | |
# get a normal list of partitions | |
for i in /dev/[sh]d[a-z][0-9]* | |
do | |
[[ -b "$i" ]] && el_array_member_add "${i}::traditional" "${partitions[@]}" ; partitions=("${_out[@]}") | |
done | |
# debug: | |
el_debug "Partitions get in raw and traditional mode from /dev/[sh]d[a-z][0-9]*: ${partitions[@]}" | |
# LVM support | |
if [[ -x /sbin/pvdisplay ]] && [[ -x /sbin/vgchange ]] && ( vgchange -ay | grep -q "logical volume.*active" ) ; then | |
for pvname in $( LC_ALL=C pvdisplay | grep "PV Name" | sed 's|^.*/dev/|/dev/|g') | |
do | |
# remove partition from our list if is part of a group | |
el_array_member_unset "$pvname" "${partitions[@]}" ; partitions=("${_out[@]}") | |
el_debug "Removed ${pvname} from our list of partitions because it is part of a Physical Volume (LVM2) set" | |
done | |
for lvname in $( LC_ALL=C lvdisplay | grep "LV Name" | sort -u | sed 's|^.*LV Name||g' | awk '{print $1" "$2" "$3" "$4}' ) | |
do | |
listpartitions="$listpartitions $lvname" | |
done | |
unset lvname pvname | |
fi | |
# REsults | |
for item in "${partitions[@]}" | |
do | |
echo -e "Partition: $item" | |
done | |
echo -en "\nTotal: " | |
for item in "${partitions[@]}" | |
do | |
echo -e "Partition: $item" | |
done | wc -l | |
} | |
# | |
# MAIN | |
# | |
main "$@" | |
# vim: set foldmethod=marker : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment