From 11282d69529bb7cf1e29a6cd6893b992fb221a9b Mon Sep 17 00:00:00 2001
From: Dmitriy Safronov <zimniy@cyberbrain.pw>
Date: Sat, 22 Jan 2022 22:23:09 +0300
Subject: [PATCH] >_<

---
 Dockerfile        | 21 +++++++++++++++++++++
 ha-rsync          |  7 +++++++
 ha-rsync.excludes | 16 ++++++++++++++++
 3 files changed, 44 insertions(+)
 create mode 100644 Dockerfile
 create mode 100644 ha-rsync
 create mode 100644 ha-rsync.excludes

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..804723e
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,21 @@
+FROM k8s.gcr.io/git-sync/git-sync:v3.3.5
+
+ENV GIT_SYNC_ROOT='/tmp/git' GIT_SYNC_DEST='config' GIT_SYNC_EXECHOOK_COMMAND='/ha-rsync' GIT_SYNC_ADD_USER='true'
+
+USER root:root
+
+RUN set -ex \
+    && apt update -y \
+    && apt install -y rsync \
+    && apt clean \
+    && rm -rf /var/lib/apt/lists/* \
+    && chmod -Rv 0777 "${GIT_SYNC_ROOT:-/tmp/git}/"
+
+COPY ha-rsync* /
+
+RUN set -ex \
+    && chmod a+x /ha-rsync
+
+VOLUME ["/config"]
+
+USER git-sync:git-sync
diff --git a/ha-rsync b/ha-rsync
new file mode 100644
index 0000000..b424cca
--- /dev/null
+++ b/ha-rsync
@@ -0,0 +1,7 @@
+#!/usr/bin/env sh
+
+rsync -a \
+    --exclude-from='/ha-rsync.excludes' \
+    --delete-after \
+    "${GIT_SYNC_ROOT:-/tmp/git}/${GIT_SYNC_DEST:-config}/" \
+    /config
diff --git a/ha-rsync.excludes b/ha-rsync.excludes
new file mode 100644
index 0000000..0db410c
--- /dev/null
+++ b/ha-rsync.excludes
@@ -0,0 +1,16 @@
+/.git
+/.gitignore
+/README.md
+
+/deps
+/image
+/tts
+
+.HA_VERSION
+
+/.cloud/*
+/.storage/*
+
+/automations.yaml
+/scenes.yaml
+/scripts.yaml
-- 
GitLab