#!/bin/bash

trap 'echo "Stopping sync"; exit 0'  EXIT SIGINT SIGTERM

function upload() {
  rsync -r images/  slides.zip *html *css *js vps.verleun.org:/docker/web-sites/site/
}

function commit() {
  git add *html *jpg
  git commit -m 'New HTML'
  git push
}

case "$1" in
once)
  commit
  ;;

forever)
  set +e
  # check if entr is installed
#  if ! command -v inotifywait >/dev/null; then
#    echo >&2 "First install 'inotifywait' with apt, brew, etc."
#    exit
#  fi

  while true; do
    fswatch -1 *html
    commit
  done
  ;;
esac
