config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

cameras (995B)


      1 #!/usr/bin/env bash
      2 
      3 cameras=(
      4   "https://kitchen.516.dwrz.net:$(pass kitchen.516.dwrz.net/motion/port)/0"
      5   "https://living.516.dwrz.net:$(pass living.516.dwrz.net/motion/port)/0"
      6   "https://bedroom.516.dwrz.net:$(pass bedroom.516.dwrz.net/motion/port)/0"
      7 )
      8 
      9 auth=(
     10   "$(pass kitchen.516.dwrz.net/motion/user):\
     11 $(pass kitchen.516.dwrz.net/motion/pw)"
     12   "$(pass living.516.dwrz.net/motion/user):\
     13 $(pass living.516.dwrz.net/motion/pw)"
     14   "$(pass bedroom.516.dwrz.net/motion/user):\
     15 $(pass bedroom.516.dwrz.net/motion/pw)"
     16 )
     17 
     18 url="detection/status"
     19 
     20 main() {
     21   case "$1" in
     22     "capture"|"c") url="detection/snapshot" ;;
     23     "pause"|"p") url="detection/pause" ;;
     24     "quit"|"q") url="action/quit" ;;
     25     "restart"|"r") url="action/restart" ;;
     26     "start"|"s") url="detection/start" ;;
     27     "status"|"") url="detection/status" ;;
     28     *) err "unrecognized command: $1"; exit 1
     29   esac
     30 
     31   for i in "${!cameras[@]}"; do
     32     curl --digest --user "${auth[i]}" "${cameras[i]}/${url}"
     33   done
     34 }
     35 
     36 main "$@"