Skip to content

Instantly share code, notes, and snippets.

@ChatchaiJ
Created December 8, 2015 07:00
Show Gist options
  • Save ChatchaiJ/4b076d6bc3c30ca5dd7b to your computer and use it in GitHub Desktop.
Save ChatchaiJ/4b076d6bc3c30ca5dd7b to your computer and use it in GitHub Desktop.
Install changetrack on debian/ubuntu host
#!/bin/bash
# --------------------------------------------------------------------- #
# install-changetrack - Install changetrack on debian/ubuntu host. #
# #
# version 0.1 - cj (2010-08-24) init. #
# --------------------------------------------------------------------- #
ADMIN="sysadmin@localhost"
CONF="/etc/changetrack.conf"
DEFAULT="/etc/default/changetrack"
# Install package changetrack, if it is already install, then reinstall
# I just too lazy to check that whether we already had it install or not.
sudo apt-get -y --reinstall install changetrack rcs
# First change default config to track all default config files of debian
# packages. And set the email address of system admin.
# We replace the original /etc/default/changetrack file
sudo sed -i -e "s/^PARAMS=.*$/PARAMS=\"-q -u -o $ADMIN\"/" \
-e "s/^AUTO_TRACK_ALL_CONFFILES=no/AUTO_TRACK_ALL_CONFFILES=yes/" \
$DEFAULT
# But we save the /etc/changetrack.conf file to /etc/changetrack.conf.old
sudo mv $CONF ${CONF}.old
# Next get the list of config files in /etc
T=$(tempfile)
C=$(tempfile)
LIST1=$(sudo find /etc -type f -print)
find /var/lib/dpkg/info -name \*.conffiles > $T
for i in $LIST1; do
[ -z "$(grep $i $T)" ] && echo "$i"
done |\
egrep -v '\.schema$' |\
egrep -v '\.tgz$|\.gz$|\.bz2|\.Z$|\.z$|\.zip$' |\
egrep -v '~$|-$|/README$|\.lock$|\.cache$|\.swp$' |\
egrep -v '.new$|.old$|.bak$|-dist$|.[0-9]+$' |\
egrep -v '/etc/gnome' |\
egrep -v '/etc/gconf' |\
egrep -v '/etc/defoma' |\
egrep -v '/etc/openoffice' |\
egrep -v '/etc/cups/ppd' |\
egrep -v '/etc/lvm/archive' |\
egrep -v '/etc/xml' |\
egrep -v '/etc/sgml' |\
egrep -v '/etc/sgml' |\
egrep -v '/etc/texmf' |\
egrep -v '/etc/shadow' |\
egrep -v '/etc/console-setup' |\
sort > $C
rm -f $T
cat << EOT >> $C
/root/.aptitude/config
/root/.bash*
/root/.profile
/root/.ssh/*
/root/bin/*
/boot/grub/menu.lst
/boot/grub/grub.conf
/var/spool/cron/crontabs/root
EOT
sudo cp -f $C $CONF
rm -f $C
# --------------------------------------------------------------------- #
# end of file. #
# --------------------------------------------------------------------- #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment