This is the crowning achievement of my days at the MINT computer pool. Sadly, by the time I write this post, it will all be deleted. So here it is, archived for posterity.
The setting is a typical computer pool setting. 24 computers and one server. All computers load their home directories from the server (see here). Otherwise, each computer is totally independent. The idea is now, that updates to the pool computers can also be distributed from the server. So that I don’t have to sit down at each computer and execute a script which is a real pain. Again, a really common problem and many solutions exist – but I made my own, hacky, one.
Setting up the server side of things is easy. Basically, we create a few folders and put one shell script in the home of a special user called admin
. There is a folder /home/admin/poolsetup/script
into which we put a script poolupdate.sh
. You can get the script from my wkutils github repository. This script goes through all files in another folder, /home/admin/poolsetup/updates
, and executes any scripts it finds in there. It redirects the outputs of the execution into a log file in the folder /home/admin/poolsetup/logs
. We can use this file to check what happened. And the update script uses the log file to avoid executing scripts twice. If a log file for a given script exists, we don’t execute the script again.
Because the home directories are loaded from the server, each pool computer will have access to files in the home directory of admin
. We don’t have to do any copying to distribute the update script to the pool computers and any changes to the script will take effect right away.
So here are the commands for the server setup – basically just create the necessary folder structure with the correct permissions and put the update script there:
mkdir /home/admin/poolsetup/script
mkdir /home/admin/poolsetup/updates
mkdir /home/admin/poolsetup/logs
chmod o+rx /home/admin/poolsetup/script
chmod o+rx /home/admin/poolsetup/updates
chmod o+rwx /home/admin/poolsetup/logs
wget https://github.com/Kaffeedrache/wkutils/blob/master/admin/poolupdate.sh
mv poolupdate.sh /home/admin/poolsetup/script
chmod o+rx /home/admin/poolsetup/script/poolupdate.sh
On client side, we only have to make the computer execute the update script on a regular basis. We use cron
and therefor call crontab
which manages the cron jobs:
crontab -e
In the editor, we add these two lines:
00 17 * * 5 bash /home/admin/poolsetup/script/poolupdate.sh
@reboot bash -c "while [[ ! -d /home/admin/ ]] ; do sleep 5; done" ; bash /home/admin/poolsetup/script/poolupdate.sh
The first line will execute the update script every Friday at 5 PM. The second line will execute the script at every system start. We need the ugly loop with the sleep
to ensure that the home directories have been mounted, before trying to access them.
So how does making an update work now? Write a script that does what you want to do. Put this script into the folder /home/admin/poolsetup/updates
. When a pool computer starts up, it will execute the script. After that, look into the log folder and read the corresponding log to see what has happened. When all computers execute the update, usually you need to read only one log file and then check if all other log files have the same size. Done!