#!/bin/sh # http://mg.pov.lt/blog/sysadmin-diary.html is the closest this thing has to # documentation. version=1.0 changelog=/root/Changelog if [ x"$1" = x-h ] || [ x"$1" = x--help ]; then echo "Usage: $0 [filename] [message]" echo "Opens an admin change log file (default: /root/Changelog) in vi" echo "or appends a timestamped message to the end and prints it." exit fi if [ x"$1" = x--version ]; then echo "new-changelog-entry version $version" echo "Written by Marius Gedminas " exit fi if test -n "$1" && test -f "$1"; then changelog=$1 shift case "$changelog" in *hangelog*) ;; *) echo "Cowardly refusing to edit $changelog since it doesn't mention Changelog in the filename" 1>&2 exit 1 ;; esac fi swapfile="`dirname $changelog`/.`basename $changelog`.swp" if [ -f $swapfile ]; then echo "Someone is currently editing $changelog ($swapfile exists)" 1>&2 exit 1 fi if ! [ -w $changelog ] && [ `id -u` -ne 0 ]; then exec sudo "$0" "$changelog" "$@" fi if [ -f $changelog ]; then # append an empty line if it is not there test -n "`tail -n 1 $changelog`" && echo >> $changelog fi msg="$*" # append a header cat >> $changelog <