File: getty-hook.sh

package info (click to toggle)
debootstick 2.8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 296 kB
  • sloc: sh: 1,364; makefile: 34
file content (28 lines) | stat: -rwxr-xr-x 772 bytes parent folder | download | duplicates (3)
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
#!/bin/bash
. /dbstck.conf  # get GETTY_COMMAND

first_init()
{
    # - we will talk to the console
    # - since we were called as a subprocess,
    #   we can avoid leaking the lock fd
    exec 0</dev/console 1>/dev/console 2>&1 200>&-
    # run debootstick init procedure
    /opt/debootstick/live/init/first-init.sh
}

# several getty processes will be spawned concurrently,
# we have to use a lock
{
    flock 200
    if [ -f "${GETTY_COMMAND}.orig" ]
    then
        # original getty not restored yet
        # => this means we are first, we will do the job.
        (first_init)    # execute in a sub-shell
        # restore original getty
        mv "${GETTY_COMMAND}.orig" "$GETTY_COMMAND"
    fi
} 200>/var/lib/debootstick-init.lock

exec "$GETTY_COMMAND" "$@"