Run a script only at the very first boot

No. But you might want to place your script in /etc/init.d/script, and self-delete it:

#!/bin/bash

echo "Bump! I'm your first-boot script."

# Delete me
rm $0

Create a tracking file when the script runs. If the file already exists, exit the script.


Combining the first two answers Assuming you name your script /usr/local/bin/firstboot.sh put it at the end of /etc/rc.local (this scripts runs on every boot) the scripts goes like this

#!/bin/bash

FLAG="/var/log/firstboot.log"
if [ ! -f $FLAG ]; then
   #Put here your initialization sentences
   echo "This is the first boot"

   #the next line creates an empty file so it won't run the next boot
   touch $FLAG
else
   echo "Do nothing"
fi