#!/bin/sh

# This script sets method "palo" for all partitions that have the palo
# flag set.

. /lib/partman/definitions.sh

for dev in /var/lib/partman/devices/*; do
    [ -d "$dev" ] || continue
    cd $dev
    partitions=
    open_dialog PARTITIONS
    while { read_line num id size type fs path name; [ "$id" ]; }; do
	if [ "$fs" != free ]; then
	    partitions="$partitions $id"
	fi
    done
    close_dialog

    for id in $partitions; do
	palo=no
	open_dialog GET_FLAGS $id
	while { read_line flag; [ "$flag" ]; }; do
	    if [ "$flag" = palo ]; then
		palo=yes
                # can not break here
	    fi
	done
	close_dialog
	if [ "$palo" = yes ]; then
	    mkdir -p $id
	    echo palo >$id/method
	fi
    done
done

