I need to run a program or script only once at next reboot of my Raspi.
For instance, if i would need to rename a file and change its permissions, the script
cp file.old file.new && chmod +rwx file.new && rm file.old
will do the trick, but... how do I make sure it runs only once at next reboot, and not at subsequents reboots?
Maybe doing some work on /etc/rc.local or /etc/crontab, but not sure how to implement it.
I´ve tried creating this file "runonce" in /etc/init.d, with chmod +x:
### BEGIN INIT INFO
# Provides: runonce
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: one-time script
# Description: hope it works
### END INIT INFO
echo 'Copying file' > /home/pi/runonce.log
sudo cp /home/pi/file.old /home/pi/file.new
sudo chmod +rwx /home/pi/file.new
sudo rm /home/pi/file.old
echo 'Deleting script' >> /home/pi/runonce.log
sudo rm /etc/init.d/runonce
echo 'Done!' >> /home/pi/runonce.log
but it seems it´s not in the required format. Nothing happens. Any ideas?
Thanks!