Let’s say you have some software installer that needs to be run on a compute node the first time that node is booted. An rc.local script can be added to that node’s software image that checks for the existence of some file to see if the installer has been run on the node before. If that file does not exist, then commands will be executed to run the installer and then create that file.
For example, let’s say that this compute node uses a software image called “compute-image”. The following commands may be run on the cluster’s active head node to set up an rc.local script:
# cm-chroot-sw-img /cm/images/compute-image
% vi /etc/rc.d/rc.local
In the text editor session, the following lines may be appended to the existing rc.local script:
if [ ! -f /tmp/INSTALLED ]; then
## Place your installation commands here
# For example: x.sh -o args
touch /tmp/INSTALLED
fi
You may add the specific command(s) to run the software installer within the bounds of that “if” conditional. Please note that a file called /tmp/INSTALLED will be created after the installer has been run. Please feel free to change the name of that file as you see fit.
After saving and quitting the text editor session, the following commands should be run to make the rc.local script executable and to ensure that the systemd rc-local.service is enabled at boot time:
% chmod +x /etc/rc.d/rc.local
% systemctl enable rc-local.service
% exit
Please note that you may see the following command output as a result of enabling the systemd rc-local.service:
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled or disabled using systemctl.
Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
instance name specified.
You may safely ignore that output; the rc.local script will still work on the compute node.
The following cmsh commands should then be run on the active head node to verify that files under /tmp (including this new /tmp/INSTALLED file) will not be overwritten during an image-to-node sync operation or when rebooting the node in AUTO/SYNC mode:
# cmsh
% category use
% get excludelistsyncinstall | grep tmp
% get excludelistupdate | grep tmp
% quit
Replace
The default exclude list sync install and exclude list update lists for BCM will include this entry:
– /tmp/*
If you see that entry, then /tmp/INSTALLED will not be overwritten during image-to-node sync operations or when rebooted in AUTO/SYNC mode.
If that entry does not exist, then an entry for /tmp/INSTALLED may be added as follows:
# cmsh
% category use
% set excludelistsyncinstall
% set excludelistupdate
% commit
% quit
Replace
A text editor session will be opened for each of those exclude lists. In the session, you may add the following line:
– /tmp/INSTALLED
Now, when the compute node that uses that image gets rebooted, the commands for the software installer should be run the one time at boot, and you should see the /tmp/INSTALLED file upon logging into the node.