aboutsummaryrefslogtreecommitdiffstats
path: root/templates/root_clone.sh
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-10-07 15:51:43 +0300
committerJan Tuomi <jan@jantuomi.fi>2025-10-07 15:51:43 +0300
commite037ecfa8cc0133a84fbed791b7658c474c3e748 (patch)
tree5305efc6c4b51caeeade79b172a1faab915a1d4e /templates/root_clone.sh
parent1b9ed1426e93c335c3ffa7836813cb109b89ee22 (diff)
Add hommabot jail
Diffstat (limited to 'templates/root_clone.sh')
-rw-r--r--templates/root_clone.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/templates/root_clone.sh b/templates/root_clone.sh
new file mode 100644
index 0000000..7f92c5f
--- /dev/null
+++ b/templates/root_clone.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+REPO="$1"
+TARGET="$2"
+
+set -eux
+
+# Exits with 100 if the directory was changed
+
+if [ ! -d "$TARGET" ]; then
+ git clone --depth=1 --branch main --single-branch "$REPO" "$TARGET"
+ exit 100
+fi
+
+cd "$TARGET"
+before=$(git rev-parse HEAD)
+git fetch --depth=1 --prune origin main
+git reset --hard origin/main
+after=$(git rev-parse HEAD)
+
+if [ "$before" != "$after" ]; then exit 100; fi