I have a bash script, which im using on a handful machines. On all machines, its the same script. Sometimes i need to adjust/update the script. With that, i need to copy the script to all this machines again.
Is there some way to update the script only on one central location and if this is done, the script checks itself, if there is a updated/changed variant on this central location and if so, copy the new version and restart itself after copy?


Syncthing helps with syncing the bash script across all of your devices. However, as for restarting itself after the update/change, you might want to setup a daemon/service (or something) that restarts the bash script whenever Syncthing does its bidding.
Syncthing is blocked, or better the ports are blocked on 3 of the hosts (and i cant open them). I can use scp, to copy files. Ports 22 and 443 are the only ports, i can use on all hosts. Additionally, i cant install new software there.
For the restart, i have found the line
exec "$(realpath $0)" "$@". Using the script directly works with that. But since the script is called from a systemd service unit, i don’t know if this break the logic. The service unit is from type oneshot and calls the script multiple times (but different parameters), like this:ExecStart=/home/username/.local/bin/script.sh variant1 ExecStart=/home/username/.local/bin/script.sh variant2 ExecStart=/home/username/.local/bin/script.sh variant3script.sh does different things, when changing the first parameter. It starts the other variants, when the current variant finishes. Now i don’t know, if restarting
/home/username/.local/bin/script.sh variant1will break the logic and the other variants will either not executed or in some unexpected schedule.