MatsK007
Posts: 4
Joined: Tue Mar 07, 2017 5:30 am

Headless system - Post install script

Tue Aug 15, 2017 10:43 pm

Hi,

Now when we have /boot/ssh and /boot/wpa_supplicant.conf it's possible to get a Raspberry Pi up and running and reachable via WiFi and SSH.

I would like to promote the idea that a "Post install script" that is executed at first boot would be a nice idea and save a lot of manual work for headless deployment.

But perhaps I am proposing a idea that is there already?

User avatar
fruitoftheloom
Posts: 16204
Joined: Tue Mar 25, 2014 12:40 pm
Location: Bognor Regis UK

Re: Headless system - Post install script

Wed Aug 16, 2017 9:17 am

MatsK007 wrote:
Tue Aug 15, 2017 10:43 pm
Hi,

Now when we have /boot/ssh and /boot/wpa_supplicant.conf it's possible to get a Raspberry Pi up and running and reachable via WiFi and SSH.

I would like to promote the idea that a "Post install script" that is executed at first boot would be a nice idea and save a lot of manual work for headless deployment.

But perhaps I am proposing a idea that is there already?
SSH was specifically disabled for security reasons: https://www.raspberrypi.org/blog/a-secu ... ian-pixel/

How can one read the "post install script" if the RPi is headless ??
""understanding the theoretical, but not always the end goal""

My other Devices are the ChromeBit CS10, ChromeCast & Huawei Mate 10 Pro SmartPhone

B.Goode
Posts: 5243
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Headless system - Post install script

Wed Aug 16, 2017 9:41 am

But perhaps I am proposing a idea that is there already?
It isn't clear to me what you are proposing, but maybe PINN viewtopic.php?f=63&t=142574 or PiBakery http://www.pibakery.org would meet your needs?

User avatar
chrisoh
Posts: 217
Joined: Sun Dec 06, 2015 8:50 pm
Location: Essex, UK

Re: Headless system - Post install script

Wed Aug 16, 2017 10:27 am

Seems MatsK007 is wanting something similar to the ssh and wpa_supplicant.conf files, in that you drop a file named post-install.sh into the /boot dir and Raspbian will automatically copy it over and exec the script on first boot. A simple use case being that you would be able to pre designate a hostname in post-install.sh and it'll be auto configured.
I can see why it'd be useful, as /boot is the only commonly accessible dir yet you can only auto configure ssh and network currently.

Some previous discussion: viewtopic.php?p=297884
Another request: viewtopic.php?t=167544&p=1077846
Similar request: viewtopic.php?t=189676&p=1192668
Coffee's ready...
Raspberry Pi 3 model B Idle @ 250mA
  • HDMI +200mA
  • Minecraft 1.9 Server +100mA
  • 2.4Ghz dongle +20mA

procount
Posts: 992
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: Headless system - Post install script

Wed Aug 16, 2017 2:23 pm

To run a post-install script, there must be some standard way of calling this script on first boot.

Most standard OSes, including Raspbian, do not have this "hook" function, probably for security reasons.
(By 'Standard' I mean an official unaltered distro that you can just download and install)

The problem boils down to how to install such a hook function into an OS that is in a compressed image file of an ext type filesystem, preferably by someone who has a Windows PC or maybe a Mac.

So here is a list of what I know exists (there may be more):
1) Raspbian - No hook. You would have to create one yourself, making it a non-standard distro.
2) PiBakery - This takes the standard Raspbian image, adds a hook function (making it non-standard) and downloads it to your SD card. It has a nice graphical interface to program what the hook function does on first boot.
3) NOOBS - More of an OS installer, but after installation of each OS it uses a hook function to tidy things up due to the changing partitions.
4) NOOBSCONFIG - a little post-install script that takes advantage of NOOBS hook function to drive some initial customisations or additional installs using a simple text file for any standard OS distribution. Not as pretty or comprehensive as PiBakery.
5) PINN- An enhanced version of NOOBS that has noobsconfig built into it, so there is no need to add the noobsconfig post-install script, just add the text file to drive the customisation of any OS.
6) PiKitchen - A whole load of recipe files built on top of noobsconfig that work with NOOBS or PINN.

One difference between noobsconfig and pibakery is that noobsconfig runs a script within NOOBS/PINN before the OS is first booted (post-install), whereas pibakery's script runs within the installed OS when it first boots (post-boot). However, noobsconfig can be used to "post-install" a "post-boot" script such as pibakery's hook function into any OS.

I know Meltwater has developed a proof of concept that merges PiBakery with PINN's noobsconfig feature. If this can be developed it would allow PiBakery to create post-install functions for any standard OS that is installable by PINN.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

User avatar
chrisoh
Posts: 217
Joined: Sun Dec 06, 2015 8:50 pm
Location: Essex, UK

Re: Headless system - Post install script

Wed Aug 16, 2017 2:51 pm

procount wrote:
Wed Aug 16, 2017 2:23 pm
To run a post-install script, there must be some standard way of calling this script on first boot.

Most standard OSes, including Raspbian, do not have this "hook" function, probably for security reasons.
(By 'Standard' I mean an official unaltered distro that you can just download and install)
I'm assuming security reasons of sorts also, seeing as a post-install script would essentially render the current Raspbian ssh and wpa_supplicant 'hooks' moot as they could be encompassed within a post-install instead.

It'd be nice to hear the official take on this concept really, as a post-install hook feature would be rather quite useful.

As a fix doesn't look likely to be released, it would provision a viable workaround for the Broadcom WiFi QoS issue present on the Pi 3 and Pi Zero W, as scripted edits could be applied to the ssh and ntp confs automatically. As it stands at the moment, headless setup over WiFi requires an extra WiFi adapter be used to bypass the onboard chip, which is tedious to say the least.

It'd also make cloning installations and applying custom configurations for deployment so much easier in the long run e.g. security camera installations.
Raspberry Pi 3 model B Idle @ 250mA
  • HDMI +200mA
  • Minecraft 1.9 Server +100mA
  • 2.4Ghz dongle +20mA

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5024
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Headless system - Post install script

Wed Aug 16, 2017 3:02 pm

It's coming. Not in the next image, but eventually.

Martin Frezman
Posts: 1021
Joined: Mon Oct 31, 2016 10:05 am

Re: Headless system - Post install script

Wed Aug 16, 2017 3:09 pm

ShiftPlusOne wrote:
Wed Aug 16, 2017 3:02 pm
It's coming. Not in the next image, but eventually.
That's very good news!

Thanks!
If this post appears in the wrong forums category, my apologies.

MatsK007
Posts: 4
Joined: Tue Mar 07, 2017 5:30 am

Re: Headless system - Post install script

Wed Aug 16, 2017 9:45 pm

Thank you all!

The idea is to drop in a script, aka post-install.sh, ssh and wpa_supp into /boot and then will a set of Pi's for a classroom be ready to use with the software needed ready to use.

And I like that it's coming in a future image and I have got a few ideas to use in the meantime.

/Mats

User avatar
meltwater
Posts: 1014
Joined: Tue Oct 18, 2011 11:38 am

Re: Headless system - Post install script

Fri Aug 18, 2017 3:45 pm

Glad to hear there is still interest in a configurable and repeatable turnkey solution.

Looking forward to a system which allows quick and easy configuration, even if it just leverages a hook within the standard installer. Allowing complete setups right out the box.

Hopefully can tie these solutions together and provide benefit for the whole RPi community.

Shall put a pull request to the PiBakery to enable support for PINN/NOOBS SDCard structure, and create the config for injecting the PiBakery files into the clean image.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

MatsK007
Posts: 4
Joined: Tue Mar 07, 2017 5:30 am

Re: Headless system - Post install script

Sat Jan 13, 2018 7:25 am

ShiftPlusOne wrote:
Wed Aug 16, 2017 3:02 pm
It's coming. Not in the next image, but eventually.
And a half year later ish, is there any news on when?

Or what could I do to help?


/Mats

mfa298
Posts: 1099
Joined: Tue Apr 22, 2014 11:18 am

Re: Headless system - Post install script

Sun Jan 14, 2018 12:02 am

MatsK007 wrote:
Tue Aug 15, 2017 10:43 pm
Now when we have /boot/ssh and /boot/wpa_supplicant.conf it's possible to get a Raspberry Pi up and running and reachable via WiFi and SSH.

I would like to promote the idea that a "Post install script" that is executed at first boot would be a nice idea and save a lot of manual work for headless deployment.

But perhaps I am proposing a idea that is there already?
This sort of functionality already exists if you use the likes of ansible, chef, puppet or salt to manage systems.

Ansible seems to be particularly popular and uses play books to configure a variety of things. I use chef (which uses cookbooks and recipes) on most of my systems to manage them. One of the benefits these can also provide is on going updates to configuration (one of my pis runs a dhcp server with the configuration updates managed via chef).

MatsK007
Posts: 4
Joined: Tue Mar 07, 2017 5:30 am

Re: Headless system - Post install script

Sun Jan 14, 2018 12:03 pm

Noop, chef, puppet, ansibel doesn't exist without a manual interaction, first login, some commands to install, configure and deploy !

What Im aiming at is to get something that other auto deployment tools like RHEL's Kickstarts and Debians preseed's "Post script". A script that run at first boot after the installation is completed.

I have discovered that on Github there is https://github.com/RPi-Distro and that has two repos, raspberrypi-sys-mods that handles the SSH enabling part and raspberrypi-net-mods that move wpa_supplicant.conf to /etc/wpa_supplicant/wpa_supplicant.conf.

And raspberrypi-net-mods and raspberrypi-sys-mods are used with Pi-gen to create new images.

To incorporate a "Post script" is not an overly complex task, and as soon as I have got my build environment up and running I will start experimenting with it.

An first draft could be something like this:

Code: Select all

[Unit]
Description=Copy first boot script to ....
ConditionPathExists=/boot/firstrun.sh

[Service]
Type=oneshot
ExecStart=.....
ExecStartPost=.....

[Install]
WantedBy=multi-user.target

mfa298
Posts: 1099
Joined: Tue Apr 22, 2014 11:18 am

Re: Headless system - Post install script

Sun Jan 14, 2018 4:11 pm

MatsK007 wrote:
Sun Jan 14, 2018 12:03 pm
Noop, chef, puppet, ansibel doesn't exist without a manual interaction, first login, some commands to install, configure and deploy !
I can't comment on the others but with chef you bootstrap from a management node (has keys to create the required stuff on the chef server and is able to login to the client being configured). That bootstrap process should install the required binaries (you might need to find/build an armhf chef package) and do the required configuration. What I've heard of ansible it's probably even easier to work with. So as long as the pi is on the network and has ssh enabled then you should be able to use those tools to configure the pi without any manual logging in and installing stuff.

dazz100
Posts: 23
Joined: Mon Apr 17, 2017 4:54 am

Re: Headless system - Post install script

Wed Apr 18, 2018 10:44 am

Hi
I ended up here because I really want a post script. At present it takes me about a day to manually install Raspian, configure the OS, install, configure and test the applications I run.

I want to be able to put an SD card into my PC (Linux or Windows) and write an image that includes the post script. I want to be able to then insert that SD card into a Pi and boot up. After a cup of coffee, I want to have a fully configured system running.

Return to “Advanced users”

Who is online

Users browsing this forum: clivem, droleary, guysoft and 6 guests