So there's a program I am developing and in order to use its full intended functionality, I need it to run with root privileges - otherwise it can't access /dev/spidev0.0. I have to get it to run on system startup with root privileges.
I have created a script that changes into the directory that contains my executable, and runs a terminal instance, passing the command to run the executable as an argument, as in
#!/bin/bash
cd /home/username/app/build
gnome-terminal -- "sudo ./app"
and placed it in Startup Applications. Upon rebooting the board, I get a terminal instance with an error message reading "no such file or directory". Everything runs smoothly, though, should I remove the "sudo" part. The problem is, I need the "sudo".
sudo ./app works just fine if used in terminal when the system has already started. I also tried placing a copy of my executable in /usr/bin and /sbin, and launch them via the script with a gnome-terminal -- "sudo app", to no avail.
How do I properly run an executable on startup with root privileges, if it is at all possible? My version of Ubuntu is 18.04 LTS, if that is of any substance.