aboutsummaryrefslogtreecommitdiffstats
path: root/modules/security/gopass/gopass-sync-init.sh
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar+git@gmail.com>2026-09-02 22:08:57 +0530
committerArpit Chakladar <arpitchakladar+git@gmail.com>2026-09-02 22:08:57 +0530
commitf6ef02e1a420b0bc79c05a04e572eb47ec7e0203 (patch)
tree1442be6c6e475258248332cb35bbd7866551c7f0 /modules/security/gopass/gopass-sync-init.sh
parent627c1f723302f949e28d9df5a3acb380186b4c44 (diff)
parent5ac48b36e56d652d55272b77a6752558e630b3c7 (diff)
downloadhome-manager-config-f6ef02e1a420b0bc79c05a04e572eb47ec7e0203.tar.gz
home-manager-config-f6ef02e1a420b0bc79c05a04e572eb47ec7e0203.zip
Merge branch 'some-changes-to-git-usage'
Diffstat (limited to 'modules/security/gopass/gopass-sync-init.sh')
-rw-r--r--modules/security/gopass/gopass-sync-init.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/modules/security/gopass/gopass-sync-init.sh b/modules/security/gopass/gopass-sync-init.sh
new file mode 100644
index 0000000..c7767f9
--- /dev/null
+++ b/modules/security/gopass/gopass-sync-init.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+
+# gopass-sync-init
+#
+# Prepare the gopass password store directory for git-backed syncing.
+#
+# This runs during home-manager activation. It ensures the store directory
+# exists, initializes it as a git repository if it is not already one, and adds
+# the configured git remote as `origin` if no remote is set yet. It is a no-op
+# (and thus safe to rerun) when the store is already set up.
+
+STORE_DIR="@@PASSWORD_STORE_DIR@@"
+
+mkdir -p "$STORE_DIR"
+cd "$STORE_DIR" || { echo "Failed to enter $STORE_DIR"; exit 1; }
+
+# Check if the directory is already a git repository; initialize if not
+if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
+ echo "Initializing git repository in $STORE_DIR..."
+ git init
+fi
+
+# Check if the remote 'origin' is set; add it if not
+if ! git remote | grep -q "^origin$"; then
+ echo "Adding remote origin..."
+ git remote add origin "@@REMOTE_REPO_URL@@"
+fi
+
+echo "Password store git setup complete."