Run script on first boot

You could start your script with systemd. Write a systemd unit like:

[Unit]
Description=yourscript
ConditionPathExists=/path/to/some/file

[Service]
Type=oneshot
ExecStart=/path/to/yourscript

[Install]
WantedBy=multi-user.target

After enabling this unit it should only start if the file in ConditionPathExists exists. You could write your script to remove that file after running. Check systemd.unit there are more such checks, for example ConditionFileNotEmpty or ConditionDirectoryNotEmpty which can also be handy.