minor improvements
authorIan Kelling <iank@fsf.org>
Mon, 16 Feb 2026 07:19:00 +0000 (02:19 -0500)
committerIan Kelling <iank@fsf.org>
Mon, 16 Feb 2026 07:19:00 +0000 (02:19 -0500)
fai/config/hooks/partition.DEFAULT

index 34abf44ca8f7053ce6b4e6a50b8b9000f73738ef..82cc314dd5c317b33d69040909daf0adf6a62123 100755 (executable)
@@ -66,7 +66,10 @@ Options
 
 -s SPECIAL_DISK    For use outside of fai. A base disk name like
 /dev/sdk. If set, we just cryptsetup and partition this one disk then
-exit. This also sets REPARTITION.
+exit. This also sets REPARTITION & prompts. REMINDER! Collect /tmp/fai/{crypttab,fstab}
+before running the script again.
+
+-y    Disable prompt from -s.
 
 ARGS (only 0 or 1 is valid). All args are for use outside of fai.
 
@@ -140,9 +143,11 @@ fi
 
 ##### begin command line parsing ########
 
+skip_o=false
 data_part=false
 max_size=false
-temp=$(getopt -l help hc:dms: "$@") || usage 1
+do_special_disk_prompt=true
+temp=$(getopt -l help hc:dms:y "$@") || usage 1
 eval set -- "$temp"
 while true; do
   case $1 in
@@ -154,9 +159,15 @@ while true; do
       boot_devs_count=$2
       shift
       ;;
-    -d) data_part=true ;;
+    -d)
+      data_part=true
+      skip_o=true
+      ;;
     -m) max_size=true ;;
     -s) special_disk="$2"; shift ;;
+    -y)
+      do_special_disk_prompt=false
+      ;;
     -h|--help) usage ;;
     --) shift; break ;;
     *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;;
@@ -385,7 +396,7 @@ crypt-$vg-root /dev/$vg/root  none  keyscript=/root/keyscript,discard,luks,initr
 crypt-$vg-swap /dev/$vg/swap  /dev/urandom  nofail,swap,cipher=aes-xts-plain64,size=256,hash=ripemd160
 EOF
       if ! $skip_o; then
-      cat >>/tmp/fai/crypttab <<EOF
+        cat >>/tmp/fai/crypttab <<EOF
 crypt-$vg-o    /dev/$vg/o     none  nofail,keyscript=/root/keyscript,discard,luks,initramfs
 EOF
       fi
@@ -499,7 +510,7 @@ EOF
 }
 
 maybe-prompt() {
-  if [[ $special_disk ]]; then
+  if [[ $special_disk ]] && $do_special_disk_prompt; then
     cmd_prompt+=("$*")
   else
     "$@"
@@ -577,8 +588,6 @@ devwipe() {
 
 ##### begin variable setup
 
-skip_o=false
-
 partition=false
 if ifclass REPARTITION; then
   partition=true # force a full wipe
@@ -1009,7 +1018,9 @@ if $partition; then
     for cmd in "${cmd_prompt[@]}"; do
       echo "$cmd"
     done
-    read -r -t 1000 -p 'Y/n ' -n 1 prompt_input
+    if $do_special_disk_prompt; then
+      read -r -t 1000 -p 'Y/n ' -n 1 prompt_input
+    fi
     if [[ ! $prompt_input || $prompt_input == [Yy] ]]; then
       for cmd in "${cmd_prompt[@]}"; do
         $cmd