#!/bin/sh
#
# Copyright 2009 - 2016 Wachendorff Elektronik GmbH & Co. KG
#
case "$1" in
    start)
        sys_login="::respawn:/sbin/getty -L ttymxc2 115200 vt100"
        /bin/grep weconoff /proc/cmdline
        if [ $? -eq 0 ]; then
            sys_login="::respawn:-/bin/sh"
        fi
        /bin/grep weconusb /proc/cmdline
        if [ $? -eq 0 ]; then
            sys_login="::respawn:/sbin/getty -L ttyUSB0 115200 vt100"
        fi
        /bin/echo $sys_login >>/etc/inittab
        (/bin/sleep 1; /bin/kill -1 1) &
        ;;
    stop)
        /bin/grep weconoff /proc/cmdline
        if [ $? -eq 0 ]; then
            /sbin/setconsole /dev/ttymxc2
        fi
        /bin/grep weconusb /proc/cmdline
        if [ $? -eq 0 ]; then
            /sbin/setconsole /dev/ttymxc2
        fi
        ;;
    *)
        /bin/echo "Usage: /etc/rc.d/init.d/consolefix {start|stop}"
        /bin/echo
        exit 1
        ;;
esac

