Multiple Machines
Karl Vogel
vogelke+unix at pobox.com
Sat Sep 25 02:11:26 UTC 2010
>> On Fri, 24 Sep 2010 15:04:45 -0800,
>> David Allen <the.real.david.allen at gmail.com> said:
D> I'm wondering what folks are doing when setting up multiple (more than
D> 1, but less than 10) machines. Consider, for example, some ordinary
D> files such as the following:
D> /root/.cshrc /home/username/.bashrc
The first thing I'd recommend for root and home dotfiles is placing them
under revision control. I'm (slowly) moving to GIT, but for now RCS
does the trick just fine:
me% echo $RCSINIT
-zLT
me% ident .vimrc .zshrc
.vimrc:
$Revision: 1.40 $
$Date: 2010-08-16 15:02:52-04 $
$Source: /home/vogelke/RCS/.vimrc,v $
$Host: example.org $
$UUID: a4f4bf9d-514d-37c7-a0e1-04b41434e869 $
.zshrc:
$Revision: 1.21 $
$Date: 2010-09-24 20:13:04-04 $
$Source: /home/vogelke/RCS/.zshrc,v $
$Host: example.org $
$UUID: da56ec7f-14be-39b5-8583-d31b5afb80eb $
I use the RCSINIT environment variable to prepend "-zLT" to the argument
list for rcs commands so I get dates in localtime with the timezone
appended. A short script called "mkrcs" creates the RCS strings shown
above; I like including the FQDN of the host on which the file was
created, along with a random UUID.
After I get a set of dotfiles I'm happy with, I usually make separate
tarballs for regular users and root.
D> /etc/fstab /etc/resolv.conf
/etc files go under revision control with an extra step; just after
installation, back up /etc.
root# cd /etc
root# mkdir /etc.orig
root# find . -depth -print | pax -rwd -pe /etc.orig
I also get a signature of all installed files:
root# cd /
root# find . -type f -print | grep -v '^./proc/' | sort | xargs md5 -r
This goes in /root/orig.md5 after stripping out /tmp, /var/tmp, /var/log,
/var/run, etc.
D> Some files are identical, some require different permissions, and some
D> (like fstab) consist of customizations that need to be added. Short of
D> enabling root ssh logins or writing makefiles, what would be the best
D> approach to handing the above?
Any system I maintain gets a directory called "/doc/sitelog/hostname".
Tarballs, patches, etc. all go under that directory. If I upgrade a
system or install a similar one, the tarballs and patches handle most of
the gruntwork.
I use a script like the one below to figure out what files I've added to
(or removed from) /etc and make patches for the modified files. Patches
go in their own /tmp/work$$ directory and look like this:
root# cat /tmp/work81394/etc-shells
*** /etc.orig/shells Sun May 7 00:00:23 2006
--- /etc/shells Wed Sep 9 21:06:04 2009
***************
*** 6,9 ****
--- 6,13 ----
/bin/sh
/bin/csh
+ /bin/ksh
/bin/tcsh
+ /bin/bash
+ /usr/local/bin/ksh
+ /usr/local/bin/zsh
--
Karl Vogel I don't speak for the USAF or my company
Hopefully digesting of this tasty post would not cause too much of farting.
--Yaroslav Halchenko, after reading a good debian-users message
---------------------------------------------------------------------------
#!/bin/sh
#<etc-patches: find modified /etc files
PATH=/usr/local/bin:/usr/local/sbin:/bin:/usr/bin:/sbin:/usr/sbin
export PATH
textfiles () {
find . -print | xargs file | grep ' text' | cut -f1 -d:
}
flist=/tmp/flist$$
work=/tmp/work$$
mkdir $work || exit 1
( cd /etc && textfiles; cd /etc.orig && textfiles ) |
cut -c3- | sort -u > $flist
echo "results in $work" >$2
for x in `cat $flist`
do
cur="/etc/$x"
orig="/etc.orig/$x"
if test -f "$cur" -a -f "$orig"; then
patch=`echo $cur | sed -e 's!^/!!' -e 's!/!-!g'`
cmp -s $orig $cur || diff -c $orig $cur > $work/$patch
elif test -f "$cur"; then
echo ADD: $cur
elif test -f "$orig"; then
echo DEL: $cur
fi
done
rm $flist
exit 0
More information about the freebsd-questions
mailing list