7

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?

you are viewing a single comment's thread
view the rest of the comments
[-] moonpiedumplings@programming.dev 2 points 5 hours ago* (last edited 5 hours ago)

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.

this post was submitted on 07 Jun 2026
7 points (100.0% liked)

Linux Questions

3943 readers
18 users here now

Linux questions Rules (in addition of the Lemmy.zip rules)

Tips for giving and receiving help

Any rule violations will result in disciplinary actions

founded 2 years ago
MODERATORS