init: seed framework reference content from agent-runtimes main repo
This commit is contained in:
29
harnesses/contexts/gitea-ssh-accelerators/v1/init.sh
Executable file
29
harnesses/contexts/gitea-ssh-accelerators/v1/init.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Extract SSH private key from decrypted env file for the accelerators identity.
|
||||
# The meta-init script generates ~/.ssh/config with
|
||||
# IdentityFile /home/agent/.ssh/gitea-oreillyit-nz-accelerators
|
||||
# matching the ssh_hosts alias in harness.yaml.
|
||||
|
||||
SSH_KEY_FILE="/home/agent/.ssh/gitea-oreillyit-nz-accelerators"
|
||||
|
||||
for env_file in /opt/harness/secrets/gitea-ssh-accelerators/*.decrypted.env /opt/harness/secrets/gitea-ssh-accelerators/*.env; do
|
||||
[ -f "$env_file" ] || continue
|
||||
while IFS='=' read -r key value; do
|
||||
[[ "$key" =~ ^[[:space:]]*# ]] && continue
|
||||
[[ -z "$key" ]] && continue
|
||||
if [ "$key" = "GITEA_SSH_KEY" ]; then
|
||||
mkdir -p /home/agent/.ssh
|
||||
echo "$value" | base64 -d > "$SSH_KEY_FILE"
|
||||
chmod 600 "$SSH_KEY_FILE"
|
||||
chown agent:agent "$SSH_KEY_FILE"
|
||||
echo "SSH key written to $SSH_KEY_FILE"
|
||||
break 2
|
||||
fi
|
||||
done < "$env_file"
|
||||
done
|
||||
|
||||
if [ ! -f "$SSH_KEY_FILE" ]; then
|
||||
echo "WARNING: GITEA_SSH_KEY not found in any env file under /opt/harness/secrets/gitea-ssh-accelerators/"
|
||||
fi
|
||||
Reference in New Issue
Block a user