In this post we will be configuring the raspberry pi to start up a script we created when it boots, this is more of a reminder for me for when I will want to do it again in the future.
Now we will be launching a python script, what the script does is that it starts up udp server that sits and waits for a client to send a specific message, If it receives that message it will give back a reply and then exit, or else it will ignore the message and then go back to waiting for another message. Now you will need access to the raspberry pi. The script is hosted on github. So you will need to install git. Open terminal and type in the command below.
sudo apt-get install git
After the the git installation, clone the script from github by typing the command below.
Inside the folder we just clone the is a script called launcher.sh, copy that script to the pi folder. Then make it executable then execute the script.
chmod 755 launcher.sh
press CTRL-C to stop the script. Now add the luncher script to cron tab for it to run when the pi boots up.
create a folder that will hold the logs if anything goes wrong.
sudo crontab -e
after opening the file at the end of the of it add there the line below.
@reboot sh /home/pi/launcher.sh >/home/pi/logs/cronlog 2>&1
Now reboot the pi. And lets test it. On another computer download the script that will be use to find our pi, cd into the directory then execute the script.
git clone https://github.com/Michael-Jalloh/find-pi.git
Now just enter an ip that the network is using, for instance if your network is using ip 192.168.1.1 enter 192.168.1.1, make sure that both the computer you are using the raspberry are on the same network.