#!/bin/bash

. /.initrd/initenv
. uevent-sh-functions
. initrd-sh-functions

PROG="${QUEUE:--}: session=${SESSION:-0}: $PROG"
message_time=1

handler() {
	if [ ! -e /sys/power/resume ]; then
		message "Kernel does not support resume - doing normal boot"
		return 0
	fi

	if ! resume_checked; then
		# hardcode path, uswsusp ships an resume binary too
		/bin/resume "$INIT_RESUME" ${RESUME_OFFSET-}

		message "resume failed - doing normal boot"
		set_resume_checked
	fi

	return 0
}

for e in "$eventdir"/resume.*; do
	[ -f "$e" ] || break
	# Ignore the return code to continue normal boot
	( . "$e"; handler; ) ||:
	done_event "$e"
done
