#!/bin/bash # Written by Ewan Leith 2011 # Version Tracking done quickly and simply # The ec script needs a directory called /var/echange to exist and be writeable by anyone using the script # or for the per-user directory /var/echange/USERNAME to exist already and be owned by that user CURRENTDIR=`pwd` TIMESTAMP=`date "+%Y%m%d%H%M"` ECHANGEDIR=/var/echange/`whoami` if [ ! -d ${ECHANGEDIR} ] then mkdir ${ECHANGEDIR} if [ $? -ne 0 ] then echo "Unable to create ${ECHANGEDIR}, exiting" exit fi chmod 700 ${ECHANGEDIR} fi if [ $# -eq 0 ] then echo "No files passed, exiting" exit fi echo "echange Tracking Message:" read MESSAGE for ARG in "$@" do #echo $ARG if [ -e $ARG ] then BASEFILE=`basename $ARG` #echo $BASEFILE if [ -e ${ECHANGEDIR}/${BASEFILE}.${TIMESTAMP} ] then BASEFILE=${BASEFILE}.$$ fi echo "$ARG is a file, copying to ${ECHANGEDIR}/${BASEFILE}.${TIMESTAMP}" cp "$ARG" "${ECHANGEDIR}/${BASEFILE}.${TIMESTAMP}" echo "echange original file: $ARG" >> "${ECHANGEDIR}/${BASEFILE}.${TIMESTAMP}.echange" echo "echange tracking message: ${MESSAGE}" >> "${ECHANGEDIR}/${BASEFILE}.${TIMESTAMP}.echange" else echo "$ARG is not a file, can't track it!" fi done