#!/bin/bash
#
# recordum_append
#
# v0.1 2013-06-25 RE
#
# appends a line to a file

MYSELF=$( basename $0 )

script_help() {
    cat <<EOF
${MYSELF} help:

This script appends a line to any file. It needs root privileges!

Usage: ${MYSELF} <TARGET> <LINE>

where:
    TARGET ... absolut path / target file
    LINE   ... line to append

EOF
}

if [[ $# -lt 2 || $# -gt 2 ]]
then
    echo "incorrect number of commandline parameters!"
    script_help
    exit 1
fi

if [[ $UID -gt 0 ]]
then
    echo "$MYSELF needs to be run as superuser. You are $USER."
    script_help
    exit 2
fi

TARGET=$1
LINE=$2

# clean out older tmp files
/bin/echo ${LINE} >> ${TARGET} || exit 3
exit 0
