# vim:set ft=sh:
run_hook ()
{
    if [ -n "${resume}" ]; then
        if [ "${resume}" != "${resume/:}" ]; then
            # Tux-on-ice syntax: swap:/dev/sda2 or file:/dev/sda2:0xdeadbeef
            resumedev=${resume#*:}
            resumedev=${resumedev%%:*}
        else
            # Classical syntax: just a device
            resumedev="${resume}"
        fi
        if poll_device "${resumedev}" ${rootdelay}; then
            if [ "${resume}" != "${resume/:}" ]; then
                # Try resuming with tuxonice
                tuxoniceroot="/sys/power/tuxonice"
                if [ -d "${tuxoniceroot}" ]; then
                    echo ${resume} > ${tuxoniceroot}/resume
                    echo > ${tuxoniceroot}/do_resume
                fi
            else
                # Try resuming with vanilla hibernation
                if [ -e "/sys/power/resume" ]; then
                    printf "%d:%d" $(stat -Lc "0x%t 0x%T" ${resume}) > /sys/power/resume
                fi
            fi
        fi
    fi
}