Appointment

FirstBoot is an AccentOS module that installs and configures software the first time you start a physical or virtual server. Can also be used to ensure that services start correctly on subsequent startups.

Installation method

Installation service uses Cobbler and response files when running.

Answer file part example:

d-i preseed/late_command string wget -O- \
   http://$http_server/init/update_kernel | chroot /target /bin/sh -s; wget -O- \
   http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_late_default | \
   chroot /target /bin/sh -s; wget -O- \
   http://$http_server/cblr/svc/op/nopxe/$what/$name; wget -O- \
   http://$http_server/server | /bin/sh -s;

Command stored in d-i preseed/late_command is run at the very end of the installer and is for installing custom software.

In this example, the kernel is updated, then Cobbler is called to run the preseed_late_default script and remove the server network boot flag, then the script http://$http_server/server is launched on the side of the installed server (in this case), which installs the FirstBoot service and downloads the necessary module scripts to install the server software on first run. Server is a script file hosted on the side of Cobbler, in which software installation scripts are written.

Example of such script:

#!/bin/bash

http_server=cobbler.test.loc

wget -O-  http://$http_server/init/firstboot | chroot /target /bin/sh -s
wget -O /target/var/lib/firstboot/scripts/15-install.sh http://$http_server/init/rc-local
wget -O /target/var/lib/firstboot/scripts/05-initrc.source http://$http_server/init/initrc.controllerone
wget -O /target/var/lib/firstboot/scripts/20-install_bind9.sh http://$http_server/init/install_bind9
wget -O /target/var/lib/firstboot/scripts/20-install_ntp.sh http://$http_server/init/install_ntp
wget -O /target/var/lib/firstboot/scripts/20-install_update-dns.sh http://$http_server/init/install_update-dns
wget -O /target/var/lib/firstboot/scripts/25-install_consul.sh http://$http_server/init/install_consul
wget -O /target/var/lib/firstboot/scripts/25-install_openstackclient.sh http://$http_server/init/install_openstackclient
wget -O /target/var/lib/firstboot/scripts/45-install_nova-compute.sh http://$http_server/init/install_nova-compute
wget -O /target/var/lib/firstboot/scripts/40-install_neutron-compute.sh http://$http_server/init/install_neutron-compute
wget -O /target/var/lib/firstboot/scripts/80-install_install_vm_controllerdb.sh http://$http_server/init/install_vm_controllerdb
wget -O /target/var/lib/firstboot/scripts/50-install_ceilometer-compute.sh http://$http_server/init/install_ceilometer-compute
wget -O /target/var/lib/firstboot/scripts/90-correct_nova_shell.sh http://$http_server/init/correct_nova_shell

Script http://$http_server/server downloads script modules from the Cobbler server (or other server) and saves them with a digital prefix to ensure the required launch order. The save path is prefixed with /target, since this script is executed in the environment of the distribution’s installer, and the file system of the server to be installed is mounted in the /target directory. The source script storage paths can be further changed to create an appropriate directory hierarchy for installing different distributions and their versions.

The first downloaded script runs immediately after downloading. It is this script that creates the FirstBoot service and forms the necessary directory hierarchy for this service. The order in which the other scripts are loaded is not important, but you should pay attention to the numerical prefix of the names of the saved scripts in order to ensure that they are given the necessary priority for execution by the FirstBoot service.

It is need to set up files with initrc and openrc variables.

All variables for configuring the cloud are specified in the openrc file.

Description of how the FirstBoot service works

FirstBoot service is a bash script that, on first startup, sorts the scripts in the /var/lib/firstboot/scripts directory by name and runs them. For ease of understanding, script names start with numbers.

Scripts are divided into two types: variable definition scripts and setup scripts. To define variables, scripts must have the .source suffix; these scripts are called using the source command. Other scripts are run via /bin/bash regardless of extension.

The output of the scripts is saved to file /var/log/firstboot or journalctl -u firstboot.

The end of the first start of the service is completed by creating the file /var/lib/firstboot/onstart. By deleting this file, you can test the operation of the service again.

The presence of the file /var/lib/firstboot/onstart signals to the FirstBoot service that the server is being restarted and not the first boot, and the service will run scripts from the /var/lib/firstboot/boot directory. This mode is convenient if the process of starting a service is complex: using timeouts or other conditions for starting a particular service, but at the same time undesirable for placement in systemd files, for example, for a quick restart while the server is running.