Ryback
Posts: 2
Joined: Wed Nov 27, 2019 6:07 am

Shell script to edit /boot/config.txt & reboot

Wed Nov 27, 2019 6:58 am

Hi!

I use a raspbian buster light with a service that start a start.sh script on boot, which launches xinit.

In the start.sh script i make a curl download to a server which has a /boot/config.txt

Code: Select all

var=$(curl "SERVERURL" -G)

if [[ $var ]]; then
    echo "$var" > /boot/config.txt;
    sleep 5;
    sudo reboot;
fi
The curl download and writing to the config.txt works perfect.

But the "sudo reboot" afterwards didn`t work.
The screen goes blank and the raspi is not reachable anymore.
If i unplug the power and plug it back, the raspi boots normal with the new config.txt.
So the new config.txt can`t be the problem.

If i comment out the "sudo reboot" and do the reboot with a SSH-Login after the start.sh script it works.

So somehow the reboot command within my start.sh script makes a problem.

Maybe someone has a tip what could be the problem?

epoch1970
Posts: 3864
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Shell script to edit /boot/config.txt & reboot

Wed Nov 27, 2019 1:41 pm

Did you try without "sudo"?
If the script is launched at init I guess it runs as root, no need to sudo.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Ryback
Posts: 2
Joined: Wed Nov 27, 2019 6:07 am

Re: Shell script to edit /boot/config.txt & reboot

Tue Dec 03, 2019 2:40 pm

Thank you for the tip, without sudo the script works.

Strange is only that the reboot takes very long, ca. 90 seconds.

I think thats some kind of timeout because my script is started through a service with the following settings.
Or maybe it`s a problem that the script try to do the reboot command while it`s stille active.

Code: Select all

[Unit]
Description=Test
After=network.target

[Service]
Type=idle
RemainAfterExit=no
ExecStart=/usr/bin/test.sh start
ExecStop=/usr/bin/test.sh stop
ExecRestart=/usr/bin/test.sh restart
ExecReload=/usr/bin/test.sh reload
Restart=always

[Install]
WantedBy=multi-user.target

epoch1970
Posts: 3864
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Shell script to edit /boot/config.txt & reboot

Tue Dec 03, 2019 3:30 pm

There is a systemctl-something command to do reboot (...) Maybe you need to use that instead?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Other programming languages”