Wednesday, March 17, 2010

Update a config on multiple servers

I've updated the /etc/updatedb.conf on multiple servers by two small scripts:
First script (slocate.sh) located on a management server calls second ~/slocate/updatedb.sh located on a common drive of the target servers which replaces updated /etc/updatedb.conf file.
1) slocate.sh listing
#!/bin/ksh
for machine in $(cat epdtw_srvs.lst)
do
if ping -c 3 $machine >/dev/null 2>&1
then
echo "==== $machine ================="
ssh root@$machine ~/slocate/updatedb.sh
else
echo "==== $machine not available ==="
fi
done
2) ~/slocate/updatedb.sh listing
#!/bin/bash
# Set new /etc/updatedb.conf by Change #...
cp /etc/updatedb.conf /etc/updatedb.conf.bak
cp ~/slocate/updatedb.conf.new /etc/updatedb.conf

No comments: