X-Git-Url: https://iankelling.org/git/?p=automated-distro-installer;a=blobdiff_plain;f=fai%2Fconfig%2Fhooks%2Fpartition.DEFAULT;h=7c88c7492a8b808ceeb52eaf0c3eb25b87260c47;hp=0a0c2ad69946535a624c74d0ce3f7443ad69671c;hb=53db7c23cb11661c98a08d69295bb315c392003b;hpb=cef9b6ede5c1e028bed1b4dc7895f5dfa121ad6b diff --git a/fai/config/hooks/partition.DEFAULT b/fai/config/hooks/partition.DEFAULT index 0a0c2ad..7c88c74 100755 --- a/fai/config/hooks/partition.DEFAULT +++ b/fai/config/hooks/partition.DEFAULT @@ -15,9 +15,15 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +PS4='+ $LINENO ' set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR +if [[ $EUID != 0 ]]; then + echo "$0: error: need to run as root" >&2 + exit 1 +fi + # for calling outside of FAI: # # need to redep and set that location so that we get luks keys # export FAI=/srv/fai/config @@ -147,18 +153,23 @@ else wipe=true fi -## ignore disks that are mounted, eg when running from fai-cd -declare -A disk_excludes -while read -r l; do - eval "$l" - if [[ ! $PKNAME ]]; then - PKNAME="$KNAME" - fi - if [[ $MOUNTPOINT ]]; then - disk_excludes[$PKNAME]=true - fi -done < <(lsblk -nP -o KNAME,MOUNTPOINT,PKNAME) +if ((`nproc` > 2)); then + mopts=,compress=zstd +fi +declare -A disk_excludes +if ! ifclass USE_MOUNTED; then + ## ignore disks that are mounted, eg when running from fai-cd + while read -r l; do + eval "$l" + if [[ ! $PKNAME ]]; then + PKNAME="$KNAME" + fi + if [[ $MOUNTPOINT ]]; then + disk_excludes[$PKNAME]=true + fi + done < <(lsblk -nP -o KNAME,MOUNTPOINT,PKNAME) +fi hdds=() ssds=() @@ -549,10 +560,10 @@ if [[ $DISTRO == debianstretch_bootstrap ]]; then else boot_vol=boot_$DISTRO fi -if $wipe; then - if [[ -e /mnt/$boot_vol ]]; then - btrfs subvolume delete /mnt/$boot_vol - fi +if $wipe && [[ -e /mnt/$boot_vol ]]; then + btrfs subvolume delete /mnt/$boot_vol +fi +if [[ ! -e /mnt/$boot_vol ]]; then btrfs subvolume create $boot_vol fi cd / @@ -576,8 +587,8 @@ EOF else # note, fai creates the mountpoints listed here cat > /tmp/fai/fstab <