Simple solution:
Script is hosted on git somewhere. (Doesn't have to be public, you can also pretty easily make git run over a small http or ssh solution). Or you can host a small http server or whatever.
Script runs git pull (or curl or etc). Sets an env variable to declare that git pull has been ran. Then reruns itself. The script sees the env variable and skips the pull/download/update + rerun phase, and carries on.
Also worth looking into, although they are probably overkill:
Ansible, chef, or similar configuration management tools. Chef mostly follows a pull based model. You have a central config somewhere and it pulls it onto machines.
Ansible mostly follows a push based model. You write a "playbook" on your local machine and it is executed on remote (maybe more than one remote machine) over ssh. Ansible is cool because the only thing you need on remote machines is python, which is usually preinstalled.
Both can be inverted however, to do push/pull instead but that'a how they work by default.
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 variant3
script.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 variant1 will break the logic and the other variants will either not executed or in some unexpected schedule.
The way to do this would be use got have a repo on one machine and do a git pull on the other machines on a cron
Linux Questions
Linux questions Rules (in addition of the Lemmy.zip rules)
- stay on topic
- be nice (no name calling)
- do not post long blocks of text such as logs
- do not delete your posts
- only post questions (no information posts)
Tips for giving and receiving help
- be as clear and specific
- say thank you if a solution works
- verify your solutions before posting them as facts.
Any rule violations will result in disciplinary actions