resume 846 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/bin/sh

PREREQ=""

prereqs()
{
	echo "$PREREQ"
}

case $1 in
# get pre-requisites
prereqs)
	prereqs
	exit 0
	;;
esac

18
# First check if a location is set and is a valid swap partition
19 20
if [ -n "$RESUME" ] && \
   { [ "$RESUME" = none ] || blkid -p -n swap $RESUME >/dev/null 2>&1; }; then
21 22 23 24 25
	# As mkinitramfs copies the config file nothing to do.
	exit 0
fi

# We need to be able to read the listed swap partitions
26
if ischroot || [ ! -r /proc/swaps ]; then
27 28 29 30
	exit 0
fi

# Try to autodetect the RESUME partition, using biggest swap?
31
# Write detected resume to intramfs conf.d
32
RESUME=$(grep ^/dev/ /proc/swaps | sort -rnk3 | head -n 1 | cut -d " " -f 1)
33
if [ -n "$RESUME" ]; then
34 35 36 37
	UUID=$(blkid -s UUID -o value "$RESUME" || true)
	if [ -n "$UUID" ]; then
			RESUME="UUID=$UUID"
	fi
38
	echo "RESUME=${RESUME}" > ${DESTDIR}/conf/conf.d/zz-resume-auto
39
fi