#!/bin/bash # Remote TTY monitoring script # Check local TTY emulation # If broken for any reason, remount remote TTY with socat # Remote TTY configured in /etc/remote-tty.conf # # Revision history : # 18/02/2016 - V1.0 - Creation by N. Bernaerts # 18/09/2017 - V1.1 - Allow tty device access to anybody # configuration TTY_CONF="/etc/remote-tty.conf" # loop thru configuration file while read LINE; do if [ "$LINE" != "" ] then # get variables REMOTE_IP=$(echo "$LINE" | cut -d';' -f1) REMOTE_PORT=$(echo "$LINE" | cut -d';' -f2) LOCAL_TTY=$(echo "$LINE" | cut -d';' -f3) # test if local TTY file is absent as a caracter file if [ ! -c "/dev/${LOCAL_TTY}" ] then # create tty socat pty,raw,echo=0,link=/dev/${LOCAL_TTY} tcp:${REMOTE_IP}:${REMOTE_PORT} & # wait for 1 second sleep 1 # give 666 access right chmod 666 "/dev/${LOCAL_TTY}" fi fi done < $TTY_CONF