g8gkq
Posts: 28
Joined: Thu Mar 30, 2017 10:25 am
Location: Southampton

Solved: Can't get Headless Buster Lite to Run a Bash Script on Boot

Tue Nov 19, 2019 5:00 pm

The Portsdown Digital Amateur TV transmitter uses a RPi 3/3b with a touchscreen running Raspbian Lite. The Stretch build uses autologin@.service to run /home/pi/.bashrc, which has been amended to source the bash script to start the touchscreen. The install file does this:

Code: Select all

# Create directory for Autologin link
sudo mkdir -p /etc/systemd/system/getty.target.wants

# Load new .bashrc to source the startup script at boot and log-on
cp /home/pi/rpidatv/scripts/configs/startup.bashrc /home/pi/.bashrc

# Always auto-logon and run .bashrc (and hence startup.sh)
sudo ln -fs /etc/systemd/system/autologin@.service\
 /etc/systemd/system/getty.target.wants/getty@tty1.service
I am trying to migrate the system to Buster Lite, but have hit a brick wall with migrating this feature.

Please could someone give me a clue as to how to run a bash script, as user pi, with all environment variables set at boot without any user intervention?

I have tried adding the script as a cron job, but that then appears unhappy to run fbcp (framebuffer copy), which I need to get the framebuffer (fb0) displayed on the 3.5 inch touchscreen (fb1).

Thanks

Dave, G8GKQ

g8gkq
Posts: 28
Joined: Thu Mar 30, 2017 10:25 am
Location: Southampton

Re: Solved: Can't get Headless Buster Lite to Run a Bash Script on Boot

Wed Nov 20, 2019 10:25 am

In writing the problem out logically, I answered my own question. I was not trying to run my script with the correct path. So, the solution I use is that crontab calls a script on boot, and then that script sets the user's path and calls the script to run as the user.

So the entry in crontab is:

Code: Select all

@reboot /home/pi/rpidatv/scripts/boot_startup.sh
and the lines in boot_startup.sh are:

Code: Select all

sudo -u pi PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
sudo -u pi /home/pi/rpidatv/scripts/startup.sh
Dave, G8GKQ

Return to “Troubleshooting”