File: crypt-generator.sh

package info (click to toggle)
dracut 110-8
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,184 kB
  • sloc: sh: 24,970; ansic: 5,236; makefile: 346; perl: 186; python: 48; javascript: 19
file content (39 lines) | stat: -rwxr-xr-x 1,054 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

command -v getargbool > /dev/null || . /lib/dracut-lib.sh

generator_set_device_timeout() {
    local _name
    local _timeout="$2"

    _name=$(dev_unit_name "$1")

    if ! [ -f "$GENERATOR_DIR"/"${_name}".device.d/timeout.conf ]; then
        mkdir -p "$GENERATOR_DIR"/"${_name}".device.d
        {
            echo "# Automatically generated by ${0##*/}"
            echo
            echo "[Unit]"
            echo "JobTimeoutSec=$_timeout"
            echo "JobRunningTimeoutSec=$_timeout"
        } > "$GENERATOR_DIR"/"${_name}".device.d/timeout.conf
    fi
}

if ! getargbool 1 rd.luks; then
    # crypto LUKS detection is disabled
    return 0
fi

[ -e /etc/crypttab ] || return 0

GENERATOR_DIR="$1"
[ -n "$GENERATOR_DIR" ] || return 1
[ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"

timeout=$(getarg rd.timeout)
timeout=${timeout:-infinity}
while read -r _ _source_device _ || [ -n "$_source_device" ]; do
    _dev=$(label_uuid_to_dev "$_source_device")
    generator_set_device_timeout "$_dev" "$timeout"
done < /etc/crypttab