#!/bin/bash
# Copyright 2017 Lucid Networks sloeckle
# Package Version 1.11-2 - Script Version 4

source /etc/nexp-tools/nexp-tools.conf

if [ $APPNOTIFICATION == false ]; then
   exit 1
fi
. /opt/nexp-tools/nexp-tools.lib
systeminfo
export DISPLAY=:0
export EMAIL=$HOSTNAME'@lucidnetworks.net'
time=$(date +"%m-%d-%Y_%T")
rand=$(od -N 4 -t uL -An /dev/urandom | tr -d " ")
dir=/tmp/$rand
mkdir $dir &>/dev/null
scrot -q 100 $dir/$HOSTNAME-$time.jpg &>/dev/null
convert $dir/$HOSTNAME-$time.jpg -fill white  -undercolor '#00000080' -pointsize 20 -gravity South -annotate +5+5 "$systeminfobrief" $dir/$HOSTNAME-$time-annotated.jpg
key="$1"
case $key in
    -m)
       curl -F "pic=@$dir/$HOSTNAME-$time-annotated.jpg" http://172.25.0.30/dailystatus/upload.php?subdir=annotated\&mode=manual
       curl -F "pic=@$dir/$HOSTNAME-$time.jpg" http://172.25.0.30/dailystatus/upload.php?subdir=original\&mode=manual
       ;;
    *)
       curl -F "pic=@$dir/$HOSTNAME-$time-annotated.jpg" http://172.25.0.30/dailystatus/upload.php?subdir=annotated
       curl -F "pic=@$dir/$HOSTNAME-$time.jpg" http://172.25.0.30/dailystatus/upload.php?subdir=original
       ;;
esac
rm -rf $dir &>/dev/null
