I made this as a continuation of my current work with the NEO2 but there is no reason why this could not be adapted to other boards. There are also many ways to achieve the same thing i.e. colourful terminal login – this is merely a what I chose to do.
So I like colourful terminals when working with little boards like the Raspberry Pi , NEO and many others. I’ve long since gone off using the graphical interfaces (unless I’m making a media centre) – and play with the boards mainly from my Windows PC using WinSCP which gives me graphical access to the file structure and the ability to use Microsoft Studio Code (I used to use Notepad++ but that was, it seems, a lifetime ago).
So really the boring part of this is the terminal. In a previous article I showed you how I introduced a nice colourful prompt – and I also covered installing various libraries for Python – a language which as you will no doubt see when you read my code, I had studiously avoided until last week (and now I’m even pondering installing on an ESP8266)
So up to now, my little NEO2 board runs off a hard disk, using RSYNC I can back up to the remainder of the SD that I boot off (and it is as well that this works as I’ve messed up a few times and wiped the hard drive in the process of learning)… the only thing is… the signup for the terminal, so lovely on Armbian and even some of the FriendlyArm ROMs was missing from the setup. All I got was a reminder who I was logging in as (like I would not know – and anyway, it’s in the prompt) and a reminder of a standard password I no longer use.
The first thing to change my terminal login was to get rid of that nonsense. It seems there are many ways to put up login messages – from MOTD (message of the day) through a myriad of other options. FriendlyArm chose to to put identical messages in both /etc/issue and /etc/issue.net which, it turns out, are simple text files.
I wiped both of them (just leaving empty files) and lo and behold when I pulled up a terminal all I got was the message to say who I was – this apparently comes courtesy of WinSCP and may not appear depending what tool you use to access the boards.
For me the solution was to create something that would firstly clear the screen then put up a USEFUL welcome message on logging in. I thought it might also be nice if I could ALSO call that – by some new name like “cls” to clear the screen and put up that same information.
As I had already used Python to put up messages on the little LCD display, it occurred to me that I should re-used this new new knowledge! I made (cobbled) a simply Python program that calls mainly a very nice library called platform which can get all sorts of info from the computer to display. I wanted to be able to call that program when a user, any user, logs in – a good place to put the link to the program turns out to be /etc/profile– a simply line at the end that says:
I also wanted an alias – a command of my own that would call this PY file manually. It turns out that /etc/bash.bashrc is a good place to put this – a simple line at the end that says:
alias cls='python /root/info.py'
So now this Python program would be called whenever someone logs into an SSH terminal program – and could also be called by issuing the command “cls”.
Of course once you see the terminal login program in action and look up the libraries it may be you chose to have a completely different set of information up there and the colours – well, that is up to you – I only defined the ones I wanted. Some of the routines were adapted from open source FriendlyArm examples – they are all pretty straightforward – just remember if you make changes – Python is utterly anal about SPACING.. it uses no braces or end statements for function – just positioning – one false move…
And the terminal login program (which bears some resemblance to the more complex I2c program to run a little OLED in a previous blog) called info.py – which I chose to put in the folder “/root” for no good reason...