This article is being updated. Please be aware the content herein, not limited to version numbers and slight syntax changes, may not match the output from the most recent versions of Bright. This notation will be removed when the content has been updated.
With a finalize script you write to somewhere under localdrive, which is the root of the local filesystem.
With an initialize script, things are a bit trickier.
Background
In the pre-provisioning, pre-init, early user space, initial root file system environment on the regular node, saving something to persistent storage is a bit roundabout. Storing it on the tmpfs is not a persistent option because the pivot process after the finalize script, before the init system runs, gets rid of those.
What we can do is store it temporarily to the tmpfs with the initialize script and then save the file to the localdisk with the finalize script. This can be done because the finalize script runs after the local disk is mounted.
Example
For example, this initializescript dumps some environment variables and their values at the point when the initializescript runs:
#!/bin/bash
echo "HOSTNAME=$CMD_HOSTNAME" > /var/run/initialenv
echo "TAG=$CMD_TAG" >> /var/run/initialenv
echo "MAC=$CMD_MAC" >> /var/run/initialenv
while this finalizescript dumps the environment variables and their values at the point when the finalizescript runs:
#!/bin/bash
echo "HOSTNAME=$CMD_HOSTNAME" > /localdisk/finalenv
echo "TAG=$CMD_TAG" >> /localdisk/finalenv
echo "MAC=$CMD_MAC" >> /localdisk/finalenv
cp /var/run/initialenv /localdisk/initialenv
Data stored earlier by an initialize script can be copied over in this way by a finalize script, to the local hard drive alongside the output of a finalize script when a node is rebooted. So you get the files/i initialenv and finalenv in the root directory (/) of the local drive. This is useful for comparison purposes, for example, when debugging issues that come up between the initialize and finalize script runs, because it can be read after the node is fully running.
Watch out for these files getting overwritten during a node update
These files get rewritten during every reboot because that’s what the finalize script does. However, they can also get wiped if a node update (cmgui button) or imageupdate (cmsh) is run to sync the node to the disk image for a running node. To stop the files getting wiped out, their paths can be added to the second excludelistupdate sublist.