~bladernr/checkbox/1095713-set-pipefail-on-sleep-jobs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash

# NB: This script must be run with root privileges in order to have any effect!

CURRENT_VT=`/bin/fgconsole`

if [ "$CURRENT_VT" == "" ]
then
    echo "Unable to determine current virtual terminal." >&2
    exit 1
fi

if [ "$CURRENT_VT" -ne "1" ]
then
    chvt 1
else
    chvt 2
fi

sleep 2
chvt "$CURRENT_VT"