[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: I'm searching for a network wide system update tool



On Sun, Jan 19, 2003 at 02:18:16PM +0100, Ivo Marino wrote:
> I've setup apt-proxy server in my network, all Debian packages for each
> server in this network are downloaded from there.
> 
> I think using a cron-job like cron-apt for updating security related
> packages automaticly on the servers not only could be a problem considering
> the securtiy point of view but also this could corrupt a server configuration
> and leave the system/service out of function.
> 
> I prefer to launch manually a script which logs via ssh into each server
> and performs the packages update procedure.
> 
> Anyone has allready written a script like the one described above or
> maybe knows an allready existing application which could perform this
> task? Thanks.

 Here's a bash script I wrote that starts a given command on all workstations
at school (on Solaris):

#!/bin/bash
# copyright Peter Cordes 1999.  License: GPL
# wscmd : run a given command on all workstations.

hostlist=~cordes/etc/wscmd.hosts

if [ 0 = $# ];then echo 'usage: wscmd args for rsh'; exit 1; fi

hosts=$(grep -v '^#' "$hostlist" | awk '{print $2}' )

for i in $hosts;do
# echo to keep output from a machine together
	if ping $i 2|grep -v 'alive'; then continue;fi
	echo "$i: $( ssh 2>&1 -n $i $@ )" &
	~cordes/bin/usleep 100000
done

echo waiting for bg jobs 1>&2
jobs  1>&2

wait



 Solaris ping is different from GNU/Linux ping, but fping is king.  
You can probably just change the loop to  for i in $( fping -a < $hosts )
and drop the  if ...; continue.

usleep sleeps for x microseconds:
#include <stdio.h>
#include <unistd.h>

int main( int argc, char ** argv )
{
	int us = atoi( argv[1] );
	sleep( us );
	return 0;
}


 If you don't use usleep, you can end up with a huge number of ssh
connections open at once, and a huge number of processes running on the
machine you run wscmd on.

 For using this script, it's probably easiest to specify a command that is a
shell script, instead of having a really complicated command as an argument
to wscmd.  This is most convenient if you have a network filesystem set up,
but you could use wscmd to copy a shell script to every computer if you
wanted to.

-- 
#define X(x,y) x##y
Peter Cordes ;  e-mail: X(peter@llama.nslug. , ns.ca)

"The gods confound the man who first found out how to distinguish the hours!
 Confound him, too, who in this place set up a sundial, to cut and hack
 my day so wretchedly into small pieces!" -- Plautus, 200 BC



Reply to: