summaryrefslogtreecommitdiffstats
path: root/hooks/resume
blob: 04ca1aa13d7561aef9f95c62793eeaf555597436 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/ash

run_hook () {
    local resumedev

    case $resume in
        '')
            err "resume: no device specified for hibernation"
            return 1;
            ;;
        swap:*|file:*)
            # tux-on-ice syntax: swap:/dev/sda2 or file:/dev/sda2:0xdeadbeef
            if [ -d /sys/power/tuxonice  ]; then
                echo "$resume" >/sys/power/tuxonice/resume
                echo >/sys/power/tuxonice/do_resume
                return 0
            else
                err "resume: tux-on-ice syntax detected, but no support found"
                return 1
            fi
            ;;

        *)
            # standard hibernation
            if resumedev=$(resolve_device "$resume" "$rootdelay"); then
                if [ -e /sys/power/resume ]; then
                    printf "%d:%d" $(stat -Lc "0x%t 0x%T" "$resumedev") >/sys/power/resume
                    return 0
                else
                    err "resume: no hibernation support found"
                    return 1
                fi
            fi
            ;;
    esac

    err "resume: hibernation device '$resume' not found"
    return 1
}

# vim: set ft=sh ts=4 sw=4 et: