SmurfCB
Posts: 2
Joined: Mon May 27, 2019 4:46 pm

Best method for remote binary deployment

Mon May 11, 2020 1:24 pm

My question is not really directly connected to the Raspberry Pi, but I am using it in this case. I am not exactly a veteran when it comes to software development on Linux. I am using my PC with an ARM x86 cross compiler to compile the binaries, now I want to automatically deploy them on the Raspberry Pi.
I created a Makefile which compiles the source, copies the binaries to the Pi via SCP, SSH's into the Pi and executes the binary. This works fine for some basic stuff. But the main issue arises when I want to add a GUI. The Pi has a small touchscreen attached to it so I can see the desktop on one session. So what I want to do is compile on PC, transfer to the Pi and execute it in the session which has a desktop so a GUI opens. Suggestions are much appreciated as I am kind of lost on what to do to get this working. I heard that Eclipse CDT has some features for remote deployment, but I am unsure if it can do exactly what I want.

User avatar
RamaSpaceShip
Posts: 30
Joined: Sun Apr 26, 2020 12:19 pm

Y

Mon May 11, 2020 5:31 pm

You can define a systemd service that you restart once the software update is done.
This service has to run as the user of the desktop (set the USER property in the service file).
Inside the script of your service, set the display ( eg export DISPLAY=:0)

Don't forget to allow your user to do 'sudo systemctl restart your_service' in the sudoer file for your user. Other systemctl commands like stop may also be added to the sudoer file..

The deployment itself may be done using: rsync -avz -e ssh ....
and the restart by: ssh [email protected] sudo systemctl restart my_service

SmurfCB
Posts: 2
Joined: Mon May 27, 2019 4:46 pm

Re: Y

Mon May 11, 2020 7:22 pm

RamaSpaceShip wrote:
Mon May 11, 2020 5:31 pm
You can define a systemd service that you restart once the software update is done.
This service has to run as the user of the desktop (set the USER property in the service file).
Inside the script of your service, set the display ( eg export DISPLAY=:0)

Don't forget to allow your user to do 'sudo systemctl restart your_service' in the sudoer file for your user. Other systemctl commands like stop may also be added to the sudoer file..

The deployment itself may be done using: rsync -avz -e ssh ....
and the restart by: ssh [email protected] sudo systemctl restart my_service
Thanks, I was thinking about making a service, but it still seemed too complicated. Guess there really is no straight forward way to do it. I'll give this a shot!

User avatar
RamaSpaceShip
Posts: 30
Joined: Sun Apr 26, 2020 12:19 pm

Re: Best method for remote binary deployment

Tue May 12, 2020 4:28 pm

That's quite simple, unless you have very complicated needs. An example service file can be:
[Unit]
Description=MySuper Service
After=multi-user.target
DefaultDependencies=no

[Service]
User=myuser
ExecStart=/home/myuser/bin/mySuperService.sh
Restart=always
RestartSec=10

[Install]


Put this file in /etc/systemd/system as mySuperService.service

Write the service script in /home/myuser/bin/mySuperService.sh and make it executable. It is wise that your main program is run with exec as the last line of the script.

You then use sudo systemctl commands to control it, providing that you allow this in the sudoer file for your user.

Chris Watson
Posts: 1
Joined: Tue May 19, 2020 11:49 am

Re: Best method for remote binary deployment

Thu May 21, 2020 1:08 pm

Thanks for this helpful thread. The code that you suggest in this thread is so helpful. :)

Return to “General programming discussion”