Browse Source

entrypoint: assign public keys provided via env vars GITOLITE_USER_PUBLIC_KEY_[USER]

Fabian Peter Hammerle 3 years ago
parent
commit
ff19ec4b46
1 changed files with 10 additions and 0 deletions
  1. 10 0
      entrypoint.sh

+ 10 - 0
entrypoint.sh

@@ -13,6 +13,16 @@ if [ ! -d "$HOME/.gitolite" ]; then
     # > First run: either the pubkey or the admin name is *required*, [...]
     (set -x; gitolite setup --admin "$GITOLITE_INITIAL_ADMIN_NAME")
 fi
+unset GITOLITE_INITIAL_ADMIN_NAME
+
+printenv | cut -d = -f 1 | while IFS= read -r var_name; do
+    if [ "$(echo "$var_name" | cut -d _ -f -4)" = "GITOLITE_USER_PUBLIC_KEY" ]; then
+        user="$(echo "$var_name" | cut -d _ -f 5-)"
+        key_path="$HOME/container-entrypoint-user-public-keys/${user}.pub"
+        mkdir --parents "$(dirname "$key_path")"
+        (set -x; printenv "$var_name" > "$key_path"; gitolite setup --pubkey "$key_path")
+    fi
+done
 
 set -x