TLDR: I want to selfupdate service from git. Bash script needs to stop this service. But it kills selfupdate. How to start bash script from Python that it will finish even if Python script is killed?
I want to run selfupdate bash script (update.sh) from Python script running as service to selfupdate service. Problem is I need to stop service, because I need to pull new data from git. Without stopping service I endup with corrupted data.
This is part Python script, which is run as service. This part should handle selfupdate of service:
import subprocess
subprocess.call('sudo /home/pi/myproject/update.sh', shell=True)
This is the update.sh script (100% working if I run it in terminal):
#!/bin/bash
systemctl stop myproject.service
su - pi -c "cd /home/pi/myproject; git reset --hard; git pull;"
su - pi -c "cd /home/pi/myproject; chmod +x update.sh"
systemctl start myproject.service
When systemctl stop myproject.service command is executed, service is killed and next lines aren't executed.
Is it possible to start update.sh in some environment which will be finished even if myproject.service is killed?