cleanup
[cmdllinux.git] / scripts / loginuser_openvt
blob67af6982a17cea7608b69c3c454ecc812df0864c
1 #!/bin/bash
3 #[$1 -f] force openvt
4 #[$1 -w] wait process to exit
5 #[$1 -s] switch terminal
6 # $1 user
7 # $2 ttyN (without /dev)
9 while [ "${1:0:1}" = '-' ]; do
10 case "$1" in
11 '-f')
12 forceopen="-f"
13 shift
15 '-w')
16 wait_exit="-w"
17 shift
19 '-s')
20 switch="-s"
21 shift
24 echo "unknown option: $1" && exit 1
26 esac
27 done
29 [ -z "$1" -o -z "$2" ] && echo "usage: $0 [-f] [-w] [-s] user ttyN" && exit 1
31 [ "$2" = "$(echo "$2" | sed 's/^tty//')" ] && exit 1
32 who | grep -q "^[^[:space:]]\+[[:space:]]\+$2[[:space:]]\+" && exit 1
33 ttynum=`echo "$2" | sed 's/^tty//'`
34 openvt -c $ttynum $switch $forceopen $wait_exit -- loginuser $1 $2
35 #openvt -c $ttynum -s $forceopen $wait_exit -- sh -c 'exit 0'