Got it!
Not a "systemd" solution per say, but I found this reference that led me to an acceptable solution. This was the first reference I found that suggested editing the /etc/profile file.
http://www.opentechguides.com/how-to...uto-start.html
The following is my basic outline. More code will be need to be added to loop around to restart the telnet session when the user logs out or telnet prompt times out, but I'm not going to clutter the basic outline with those details. This is tested and working in both the minimal and full Raspian (Recommended) Debian/Jessie install.
To begin, get your Pi configured to boot into CLI mode with auto-login.
Next, install the telnet package (not included in defaults OS installation):
Code:
sudo apt-get -y install telnet
Now begins the magic trick I was looking for where .bashrc, .bash_profile, rc.local and crontab all failed me:
Code:
sudo vi /etc/profile
Append the bottom of the file with this line and be sure to include the preceding "dot":
That line will invoke your script after the Raspberry reaches the system command prompt. I have no idea what that "dot" is there for but it was in the reference sample so I just followed suite, and it works. (Don't fix it if it ain't broke)
Next you create the script you want to invoke after the auto-login:
Code:
sudo vi /opt/dotelnet
Populate the file with the following code:
Code:
#!/bin/bash
portName=`who am i | awk '{print $2}'`
echo "you are $portName"
case $portName in
tty1) portName="ok" ;;
tty2) portName="ok" ;;
tty3) portName="ok" ;;
tty4) portName="ok" ;;
tty5) portName="ok" ;;
tty6) portName="ok" ;;
esac
if [ "$portName" = "ok" ] ; then
echo "Entering terminal mode..."
sleep 1
/usr/bin/telnet 192.168.1.138
fi
Save it and make the script executable:
Code:
sudo chmod 755 /opt/dotelnet
One last step to see the magic happen:
Obvious to some more than others, you might want to change the name and/or location of the "/opt/dotelnet" file. Up to you. And the 192.168.1.138 address will probably need to be adjusted to point to your local host machine.
It should also be noted here, the above solution is invoked not only on the tty1 auto-login session but also works when you login on any of the VT screens, and this should work regardless what user name you use. I am using the default "pi" user.
In case you are asking "why did he use the case esac structure to test for the console screens", it turned out this simpler more elegant code worked perfectly in the full Raspian installation but failed in the minimal Raspian installation. (go figure
)
Code:
#!/bin/bash
portName=`who am i | awk '{print $2}'`
echo "you are $portName"
if [ "$portName" = "tty[1-6]" ] ; then
echo "Entering terminal mode..."
sleep 1
/usr/bin/telnet 192.168.1.138
fi
Would be interesting to know why that is. Whatever the case, the script is
never invoked when you ssh into the Raspberry.