$ cat  /usr/bin/editchangelog 
#!/bin/bash

# Package: changelog

PATH=/usr/local/adm/scripts:/usr/bin:/bin:/sbin:/usr/sbin

DEFAULT_EDITOR=vim
CHANGELOG=Changelog
CL_DIR=/etc
HEADER="# Please use 'editchangelog' to maintain this file"
# to clean up old versions
OLD_HEADER="# Please use 'sudo editchangelog' to maintain this file"
CL_CFG=/etc/editchangelog.cfg
#WRITE_GROUP=staff

TZ=$(date +%Z)
DATE="$(date -R) $TZ"
USER_NAME=$USER

MYSELF=$0

func_sudo_call(){
#  echo 
#  echo " Calling myself with sudo"
  sudo $MYSELF || echo "  sudo not possible, please check your permissions"
  exit 0
}

if [ "_$SUDO_USER" = "_" ]; then
  func_sudo_call
else
    if [ ! "_$USER" = "_root" ]; then
      func_sudo_call
    fi
  USER_NAME=$SUDO_USER
fi

REAL_NAME=$(getent passwd $USER_NAME | awk -F: '{ print $5 }')


# read configuration
if [ -e $CL_CFG ]; then
  . $CL_CFG
fi

TMPFILE=/tmp/${CHANGELOG}.$USER_NAME

func_apply_cl(){
cp $TMPFILE $CL_DIR/$CHANGELOG && rm $TMPFILE
if [ _$SUDO = "_true" ]; then
  chown root:staff $CL_DIR/$CHANGELOG
  chmod 640 $CL_DIR/$CHANGELOG
fi
logger -t editchangelog "${USER_NAME}: md5sum $(md5sum $CL_DIR/$CHANGELOG)"
}

func_edit_cl() {
$EDITOR $TMPFILE
}

func_remove_header() {
cat $TMPFILE | sed -e "s/$HEADER//g" > $TMPFILE.$$ && mv $TMPFILE.$$ $TMPFILE
cat $TMPFILE | sed -e "s/$OLD_HEADER//g" > $TMPFILE.$$ && mv $TMPFILE.$$ $TMPFILE
cat $TMPFILE | egrep -v "^#$" > $TMPFILE.$$ && mv $TMPFILE.$$ $TMPFILE
}

func_build_cl() {
cp $CL_DIR/$CHANGELOG $TMPFILE
func_remove_header


echo "
$CL_LINE" > $TMPFILE.$$
cat $TMPFILE >> $TMPFILE.$$ && mv $TMPFILE.$$ $TMPFILE
}

# do it

if [ "_$EDITOR" = "_" ]; then
#echo " Using Vi as default editor."
#echo " Set EDITOR="your_preferred_editor" next time to use another one"

EDITOR=$DEFAULT_EDITOR
fi

if [ ! -e $CL_DIR/$CHANGELOG ]; then

# first time
echo $HEADER > $CL_DIR/$CHANGELOG
echo "#" >> $CL_DIR/$CHANGELOG

func_build_cl

MD5SUM_CL=$(md5sum $TMPFILE)

else

# if changelog exists


func_build_cl

MD5SUM_CL=$(md5sum $TMPFILE)



fi

func_edit_cl

if [ ! "$MD5SUM_CL" = "$(md5sum $TMPFILE)"  ]; then

#echo
#echo " Thank you for maintaining the changelog. Have a nice day."
#echo

echo $HEADER > $TMPFILE.$$
echo "#" >> $TMPFILE.$$
cat $TMPFILE >> $TMPFILE.$$ && mv $TMPFILE.$$ $TMPFILE

func_apply_cl

else

rm -f $TMPFILE
echo
echo " No changes written. Are you sure? [y|n]"
echo

while true; do
read INPUT > /dev/null
    case "$INPUT" in
                n | N)
      $0
      break
                ;;
                y | j | Y | J)
      echo
      echo " You know what you do"
      echo
                break
                ;;
      *)
                ;;
   esac
done


fi