How to run a bash script on the very first boot
Posted: Thu Mar 15, 2018 10:56 am
Hello
I created a basic image with some configuration i need for setting up a kubernetes cluster .
But when i burn this image the machine-id from /etc/machine-id stays the same on every node of my raspberry pi cluster.
I have to delete this and create a new one with these commands
But i want this included in my basic image so every time i burn my basic image on a sd card this code will run once at first boot. So the machine id will be recreated.
Until now i had the idea to create a line in /etc/rc.local to call a bash script in my home folder where i run these commands , delete /etc/rc.local and copy the /etc/rc.local.bak to make a fresh /etc/rc.local and delete its self and reboot , so that on the next boot there is a fresh /etc/rc.local and the machine id was not the one from the cloned image. But that didn't worked out to well and i thought there have to be a better way to do this. After some unsuccesfully google searches i was hoping someone of the raspberry pi community will help me in the right direction to solve this problem.
I created a basic image with some configuration i need for setting up a kubernetes cluster .
But when i burn this image the machine-id from /etc/machine-id stays the same on every node of my raspberry pi cluster.
I have to delete this and create a new one with these commands
Code: Select all
sudo rm /etc/machine-id
sudo rm /var/lib/dbus/machine-id
sudo dbus-uuidgen --ensure=/etc/machine-id
Until now i had the idea to create a line in /etc/rc.local to call a bash script in my home folder where i run these commands , delete /etc/rc.local and copy the /etc/rc.local.bak to make a fresh /etc/rc.local and delete its self and reboot , so that on the next boot there is a fresh /etc/rc.local and the machine id was not the one from the cloned image. But that didn't worked out to well and i thought there have to be a better way to do this. After some unsuccesfully google searches i was hoping someone of the raspberry pi community will help me in the right direction to solve this problem.