Compare commits
1 commit
6100722c1e
...
46336142ee
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46336142ee |
1 changed files with 12 additions and 6 deletions
|
|
@ -95,14 +95,14 @@ ensure_profile_repo() {
|
||||||
# Define cache directory: /home/agent/data/.profile/{agent-name}
|
# Define cache directory: /home/agent/data/.profile/{agent-name}
|
||||||
PROFILE_REPO_PATH="${HOME:-/home/agent}/data/.profile/${agent_identity}"
|
PROFILE_REPO_PATH="${HOME:-/home/agent}/data/.profile/${agent_identity}"
|
||||||
|
|
||||||
# Build clone URL from FORGE_URL and agent identity
|
# Check if already cached and up-to-date
|
||||||
|
if [ -d "${PROFILE_REPO_PATH}/.git" ]; then
|
||||||
|
# Pull latest changes
|
||||||
local forge_url="${FORGE_URL:-http://localhost:3000}"
|
local forge_url="${FORGE_URL:-http://localhost:3000}"
|
||||||
local auth_url
|
local auth_url
|
||||||
auth_url=$(printf '%s' "$forge_url" | sed "s|://|://$(whoami):${FORGE_TOKEN}@|")
|
auth_url=$(printf '%s' "$forge_url" | sed "s|://|://$(whoami):${FORGE_TOKEN}@|")
|
||||||
local clone_url="${auth_url}/${agent_identity}/.profile.git"
|
local clone_url="${auth_url}/${agent_identity}/.profile.git"
|
||||||
|
|
||||||
# Check if already cached and up-to-date
|
|
||||||
if [ -d "${PROFILE_REPO_PATH}/.git" ]; then
|
|
||||||
log "Pulling .profile repo: ${agent_identity}/.profile"
|
log "Pulling .profile repo: ${agent_identity}/.profile"
|
||||||
if git -C "$PROFILE_REPO_PATH" fetch origin --quiet 2>/dev/null; then
|
if git -C "$PROFILE_REPO_PATH" fetch origin --quiet 2>/dev/null; then
|
||||||
git -C "$PROFILE_REPO_PATH" checkout main --quiet 2>/dev/null || \
|
git -C "$PROFILE_REPO_PATH" checkout main --quiet 2>/dev/null || \
|
||||||
|
|
@ -114,6 +114,12 @@ ensure_profile_repo() {
|
||||||
log "WARNING: failed to pull .profile repo, using cached version"
|
log "WARNING: failed to pull .profile repo, using cached version"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
# Clone fresh
|
||||||
|
local forge_url="${FORGE_URL:-http://localhost:3000}"
|
||||||
|
local auth_url
|
||||||
|
auth_url=$(printf '%s' "$forge_url" | sed "s|://|://$(whoami):${FORGE_TOKEN}@|")
|
||||||
|
local clone_url="${auth_url}/${agent_identity}/.profile.git"
|
||||||
|
|
||||||
log "Cloning .profile repo: ${agent_identity}/.profile -> ${PROFILE_REPO_PATH}"
|
log "Cloning .profile repo: ${agent_identity}/.profile -> ${PROFILE_REPO_PATH}"
|
||||||
if git clone --quiet "$clone_url" "$PROFILE_REPO_PATH" 2>/dev/null; then
|
if git clone --quiet "$clone_url" "$PROFILE_REPO_PATH" 2>/dev/null; then
|
||||||
log ".profile repo cloned: ${PROFILE_REPO_PATH}"
|
log ".profile repo cloned: ${PROFILE_REPO_PATH}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue