#!/bin/bash # # etcupdate for slackware # # BEWARE THIS SCRIPT ASSUMES ANY CUSTOM CONFIG HAS A .dist FILE FOR IT # # special cases: # # /etc/rc.d/rc.inet1.new -- should not be executable # /etc/logrotate.d/syslog.new -- .dist should not remain there date=`date +%s` [[ -z `grep ^tabooext /etc/logrotate.conf` ]] && echo define tabooext + .dist in /etc/logrotate.conf first && exit 1 echo echo -n indexing ... updatedb && echo done echo tmp=`locate \.new | grep new$ | grep -v sbopkg | grep -v slackbuilds | grep -v /var/lib/filetraq/` [[ -z $tmp ]] && echo -e all good \\n && exit 1 for f in $tmp; do # CUSTOM THERE IS - CHECK THE CHANGES # compare new with dist # -- override if identical # -- otherwise show diff if [[ -f ${f%\.new}.dist ]]; then difftmp=`diff -bu ${f%\.new}.dist $f` [[ -z $difftmp ]] && mv -f $f ${f%\.new}.dist || \ echo -e defaults have changed \\n \ \\tdiff -bu ${f%\.new}.dist $f \\n \ \\tmv -f $f ${f%\.new}.dist \\n unset difftmp # NOTHING SPECIAL - WE DO NOT CARE ESP. IF THERE IS NO CHANGE # compare new with current # -- override if identical # -- otherwise backup and override elif [[ -f ${f%\.new} ]]; then difftmp=`diff -bu ${f%\.new} $f` if [[ -z $difftmp ]]; then mv -f $f ${f%\.new} else cp -pi ${f%\.new} ${f%\.new}.old.$date mv -f $f ${f%\.new} && \ echo -e file updated - no .dist file \\n \ \\tdiff -bu ${f%\.new}.old.$date ${f%\.new} \\n \ \\trm -f ${f%\.new}.old.$date \\n fi unset difftmp elif [[ -d $f/ ]]; then # happens with filetraq e.g. /var/lib/filetraq/etc/sshguard.conf echo warning: $f/ is a folder not a file else echo error: ${f%\.new} does not exist fi done; unset f tmp echo echo all done # TODO chmod -x on rc.d/ new/dist scripts?