aboutsummaryrefslogtreecommitdiff
path: root/recipes-core/auto-serial-console/auto-serial-console/auto-getty
blob: 05d8fb62d41f855f516a14a1ff4d8ab150573113 (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
#!/bin/sh -e

[ -f /etc/default/autogetty ] && . /etc/default/autogetty

[ 1 -gt $ENABLED ] && exit

while true; do
  for arg in $(cat /proc/cmdline); do
    case $arg in
      console=*)
        tty=${arg#console=}
        tty=${tty#/dev/}

        case $tty in
          tty[a-zA-Z]* )
            PORT=${tty%%,*}

            tmp=${tty##$PORT,}
            SPEED=${tmp%%n*}

            # if console=/dev/tty* without speed is given
            [ $SPEED = $PORT ] && SPEED=115200
            BITS=${tmp##${SPEED}n}

            # 8bit serial is default
            [ -z $BITS ] && BITS=8
            # [ 8 -eq $BITS ] && GETTY_ARGS="$GETTY_ARGS -8 "

            [ -z $SPEED ] && SPEED='115200,57600,38400,19200,9600'

            GETTY_ARGS="$AUTOGETTY_ARGS $GETTY_ARGS $SPEED $PORT"
            /sbin/getty $GETTY_ARGS
        esac
    esac
  done
done