Posted by Alec on 17 January 2009
After some information from jim mcnamara I developed a script to compare two directory trees. I needed something that worked on Solaris 8 so it uses basic UNIX tools (and dircmp was not very useful). If you are using a more modern system then try this
#!/bin/ksh
# Compare 2 directories for differences (e.g. current release and new release)
CURRENT=$1 ; shift
NEW=$1; shift
CURRENTDIFFFILE=/tmp/$(echo $CURRENT | sed -e 's/[/.][/.]*/_/g')
NEWDIFFFILE=/tmp/$(echo $NEW | sed -e 's/[/.][/.]*/_/g')
# File pattens not to be included in compare
cat << 'EOF' > /tmp/patternFile
^.git/
^.*\.log
^logs/.*
^.*\.tmp
^.*\.err
EOF
for i in $CURRENT $NEW ; do
cd $i
# cut removed ./ that find puts at start of path name
find . -type f -print |cut -b3- |egrep -v -f /tmp/patternFile | sort > /tmp/$(echo $i | sed -e 's/[/.][/.]*/_/g')
cd -
done
echo New files
comm -13 $CURRENTDIFFFILE $NEWDIFFFILE
echo
echo Deleted files
comm -23 $CURRENTDIFFFILE $NEWDIFFFILE
echo
echo files that are different
# xargs has limitations so must pipe into a second shell
comm -12 $CURRENTDIFFFILE $NEWDIFFFILE | xargs -i echo cmp -s \"$CURRENT/{}\" \"$NEW/{}\" \|\| echo {} changed | sh
Posted in Change Audit, Linux, Software Configuration Management, Software Development | 1 Comment »
Posted by Alec on 10 January 2009
Updated 6/Feb/09
I’m currently working on on a project to deploy some complex banking systems and we have some somewhere in the region of 40 environments (various testing, production and development instances)
I’ve written some Perl to automatically configure environments using Text::Template. Now I’d like to automate deployment and have some form of change auditing (c.f.AIDE or Tripwire).
So a new project (which I hope will also have some useful ideas for others):
- Project Outline and User stories
- General Approach using git (other tools could probably be used)
- Define a staging repo
- Create a remote branch of each deployment environment
- Create a repo on each environment
- Define a custom merge driver that overwrites (old files with new releases)
- For each release
- Create a new branch (overkill?)
- Add new release to new branch
- tag
- To deploy
- Merge (using new driver) onto environment branch
- tag
- Push to remote
- On remote perform
git reset --hard HEAD
- configure
- add and commit configuration changes
- on staging pull config changes from remote repo
- Now use git status etc. on environments to track any changes
- Staging should have historical record of changes
Posted in Change Audit, Git, Open Source Software, Perl | Leave a Comment »