log_file.sh
author Bartha Mihai <mihai.bartha@ait.ac.at>
Tue, 13 Jan 2015 18:47:53 +0100
changeset 253 6c6931e1c6a0
parent 142 709cbb3b16de
permissions -rwxr-xr-x
merge
     1 #!/bin/bash
     2 
     3 # ------------------------------------------------------
     4 # sample test file for checking the logiing
     5 # ------------------------------------------------------
     6 
     7 FILE_TO_LOG=${1}
     8 if [ -z "${FILE_TO_LOG}" ]; then
     9     echo "please specify file name to log"
    10     exit 1
    11 fi
    12 FILE_TO_LOG=$(readlink -f ${FILE_TO_LOG})
    13 
    14 FILE_TIMESTAMP=$(date +"%s")                                # unix epoch timestamp
    15 FILE_CHECKSUM=$(md5sum < "${1}" | gawk '{ print $1; }')     # MD5-Checksum
    16 
    17 OPENSECURITY_URL="http://localhost:8090/log"
    18 
    19 # POST the log
    20 curl --data-urlencode "file=${FILE_TO_LOG}" --data-urlencode "checksum=${FILE_CHECKSUM}" --data-urlencode "timestamp=${FILE_TIMESTAMP}" --data-urlencode 'action=copy' --data-urlencode 'memo=copied to unsafe USB Drive G:\\' ${OPENSECURITY_URL}
    21