#!/bin/bash

MACHINE_ID=$1
FILE=$2
DESC=$3

if [ "$FILE" = "" ] || [ "$MACHINE_ID" = "" ]; then
  echo "Usage: $0 <machine_id> <file_to_upload>"
  exit
fi

LIC_FILE="/opt/pos/etc/$MACHINE_ID.lic"

if [ -e "$LIC_FILE" ]; then
  curl -F "file_upload=@$FILE" "http://releases.ptcert.com/dealers/export?machine_id=$MACHINE_ID&desc=$DESC"

  if [ "$?" = "0" ]; then
    echo "OK"
  else
    echo "KO"
  fi
else
  echo "KO"
fi

