useful little script

5 views
Skip to first unread message

Gabor Laszlo

unread,
Sep 24, 2009, 9:58:16 AM9/24/09
to we...@googlegroups.com
Hello,

I thought I'd share this: I wrote a function into root's .bashrc on
the vz-server that will run its parameters on every container, or
return the list of running containers if called without parameters.
I called it clusterfuck, because that's what you get if you're not
very very careful with it:

clusterfuck(){
running=`vzlist| grep running| awk '{print $1}'`
if [ -z "$*" ]
then echo $running;
else for i in $running; do
echo "### $i ###"
vzctl exec2 $i "$*"
done
fi
}

so you could do
vz-server# clusterfuck "apt-get update -qq && apt-get upgrade -s |
grep Inst | sed -e 's/^Inst //' -e 's/ .*$//'"
and get a list of available updates for each container.

or copy a certain file to every machine:
vz-server# for i in $(clusterfuck); do cp foo.txt /vz/private/$i/dev/null; done

Regards
Gabor Laszlo
--
We are born wet, naked and hungry.
Then things get worse.

Reply all
Reply to author
Forward
0 new messages