#!/bin/sh
if [ "$1" = "frontyard" ]; then
  host="loge.local"
  port=8081
fi
if [ "$1" = "basement_table" ]; then
  host="loge.local"
  port=8082
fi
if [ "$1" = "mailbox" ]; then
  host="loge.local"
  port=8083
fi
if [ "$1" = "basement_tv" ]; then
  port=8081
  host="polydeuces.local"
fi
if [ "$1" = "bulkhead" ]; then
  port=8081
  host="mimas.local"
fi
if [ "$1" = "basement_cape" ]; then
  port=8082
  host="mimas.local"
fi
if [ "$1" = "firewood" ]; then
  port=8083
  host="mimas.local"
fi
if [ "$1" = "backyard" ]; then
  port=8081
  host="mundilfari.local"
fi
if [ "$1" = "backyard_low" ]; then
  port=8082
  host="mundilfari.local"
fi
if [ "$1" = "basement_extension" ]; then
  port=8083
  host="mundilfari.local"
fi
if [ "$1" = "backyard_north" ]; then
  port=8084
  host="mundilfari.local"
fi
if [ "$1" = "barn" ]; then
  port=8081
  host="iapetus.local"
fi
if [ "$1" = "garage" ]; then
  port=8082
  host="iapetus.local"
fi
if [ "$1" = "porch" ]; then
  port=8083
  host="iapetus.local"
fi
if [ "$1" = "birds" ]; then
  port=8081
  host="siarnaq.local"
fi
if [ "$1" = "clouds" ]; then
  port=8082
  host="siarnaq.local"
fi
if [ "$1" = "garden" ]; then
  port=8083
  host="siarnaq.local"
fi
if [ "$1" = "diningroom" ]; then
  port=8081
  host="kari.local"
fi

ROOT="/media/photos/misc/webcams"
filepath="$1/$(date +%Y)/$(date +%m)/$(date +%d)/$(date +%Y%m%d%H%M%S).jpg"
mkdir -p /$ROOT/$1/$(date +%Y)/$(date +%m)/$(date +%d)/
curl $host:$port/snapshot -o /$ROOT/$filepath
url="https://files.lab.unbl.ink/webcams/$filepath"
#curl -H prio:low -H "click:$url" -d "Captured photo from $1 successfully" https://ntfy.unbl.ink/webcams
