From f163b5c034a22d72d24b5d30768522856e357eab Mon Sep 17 00:00:00 2001
From: Sebastian 'gonX' Jensen <gonx@gonx.dk>
Date: Mon, 25 Dec 2023 05:30:20 +0100
Subject: [PATCH] Add script for importing TABLETS.md

It expects the OpenTabletDriver driver repository to be checked out
at either '../opentabletdriver/' or '../OpenTabletDriver' respectively.

Down the line this should probably be changed to a submodule and/or a GitHub action

Also see OpenTabletDriver/opentabletdriver.github.io#3
---
 import-tabletsmd.sh | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100755 import-tabletsmd.sh

diff --git a/import-tabletsmd.sh b/import-tabletsmd.sh
new file mode 100755
index 0000000..fefd275
--- /dev/null
+++ b/import-tabletsmd.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+BASEDIR="$(dirname "$0")"
+TABLETS_MD_LOC="${TABLETS_MD_LOC:="${BASEDIR}/../opentabletdriver/TABLETS.md"}"
+
+if [ -z "$TABLETS_MD_LOC" ]; then
+  for reponame in opentabletdriver OpenTabletDriver; do
+    tmp="${reponame}"/TABLETS.md
+
+    if [ -f "$tmp" ]; then
+      TABLETS_MD_LOC="$tmp"
+      break
+    fi
+  done
+fi
+
+if [ -z "$TABLETS_MD_LOC" ] || [ ! -f "$TABLETS_MD_LOC" ]; then
+  echo "Can't find TABLETS.md, bailing"
+  exit 1
+fi
+
+cp -i "$TABLETS_MD_LOC" "${BASEDIR}"/site/_includes/tablets.md || exit $?