efs2 icon indicating copy to clipboard operation
efs2 copied to clipboard

Strategy for linux-dialog style interactive shells (popular with OS installers on raspberry-pi sized devices)

Open paul-hammant opened this issue 5 years ago • 5 comments

Describe the idea

I've a fleet os Raspberry Pi's and smaller less well known devices (Odroid). First boot or first SSH connection of these things oftent goes into an interactive session for initial setup. Completing that workflow before attaching Efs2 for proper post boot setup is a need.

Describe possible implementations

Dialog is a thing that people use. Automating it is a frequent question on Stack Overflow (etc) - https://superuser.com/questions/1041735/automating-dialog - one of the answers links to https://stackoverflow.com/questions/3804577/have-bash-script-answer-interactive-prompts. This seems limited though.

There's https://pypi.org/project/webssh/ which could be used with Selenium (I'm co-creator of v1 back in 2004) to do any timing sensitive navigation of DOM representation of the terminal, and complete that setup.

With that, you'd launch wssh in the background, open selenlium-webdriver, do the needed one-time setup, exit, kill the wssh process.

Then you'd go back in with Efs2 to o the rest (reset default passwords, packages, etc)

Question: Is this the right approach or does Efs2 have a different way?

Additional context

Some little devices have something closer to cloud-init for setup, but there's huge variance for the different OSs that can be used.

paul-hammant avatar Jan 01 '21 15:01 paul-hammant

Dammit, this is a 'question' not an 'enhancement'

paul-hammant avatar Jan 01 '21 15:01 paul-hammant

So there has been another request for Interactive command handling ( #5 ). With your description, it reminds me of something I've done in the past using pyexpect. Long ago I had a script that when given CSV input would basically automate anything, we used it for all sorts of things from app setup to logging into SAN and provisioning volumes out.

There is a Go library for expect i.e. (https://github.com/Netflix/go-expect) might be worthwhile implementing a command instruction called EXPECT that lets you put in a REGEX pattern and when that pattern is found insert the provided input. I would probably more go that route as it doesn't require any installation on the target machines, it keeps all of the processing on the client.

madflojo avatar Jan 01 '21 20:01 madflojo

I'd thought of expect and have used it a couple of times over the years myself, but somehow imagined it to not be sophisticated enough for this.

What you're talking about is a great idea. Regex would be just fine, though there's lots of range for enterable things. For DietPI OS theres a bunch that can be seen here - https://wiki.friendlyarm.com/wiki/index.php/DietPi (scroll 40% of the way down).

paul-hammant avatar Jan 02 '21 08:01 paul-hammant

Actually this is such a niche need, it should be ignored. DietPi is a bad example as it uses Dropbear SSH which doesn't have SFTP enabled and Efs2 needs that.

paul-hammant avatar Jan 02 '21 11:01 paul-hammant

I'm assuming you mean the TUI setup? I agree automating a TUI setup would be pretty tricky. But I think the EXPECT functionality would be pretty nice and give folks something that not a lot of other tools provide.

madflojo avatar Jan 02 '21 18:01 madflojo