mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-07 22:58:58 +08:00
fix install.sh
This commit is contained in:
150
install.sh
150
install.sh
@@ -130,89 +130,90 @@ if [[ "$MIGRATE" == "y" || "$MIGRATE" == "Y" ]]; then
|
|||||||
echo "2. Remote migration"
|
echo "2. Remote migration"
|
||||||
read -p "Enter your choice (1 or 2): " MIGRATION_TYPE
|
read -p "Enter your choice (1 or 2): " MIGRATION_TYPE
|
||||||
|
|
||||||
if [[ "$MIGRATION_TYPE" == "1" ]]; then
|
case "$MIGRATION_TYPE" in
|
||||||
echo "Proceeding with local migration..."
|
1)
|
||||||
|
echo "Proceeding with local migration..."
|
||||||
|
|
||||||
# Default paths for local migration
|
# Default paths for local migration
|
||||||
SRC_DEFAULT="$HOME/.openclaw/workspace"
|
SRC_DEFAULT="$HOME/.openclaw/workspace"
|
||||||
DST_DEFAULT="$HOME/.clawgo/workspace"
|
DST_DEFAULT="$HOME/.clawgo/workspace"
|
||||||
SRC="${SRC_DEFAULT}"
|
SRC="${SRC_DEFAULT}"
|
||||||
DST="${DST_DEFAULT}"
|
DST="${DST_DEFAULT}"
|
||||||
|
|
||||||
# Prompt user about overwriting existing data
|
# Prompt user about overwriting existing data
|
||||||
echo "Warning: Migration will overwrite the contents of $DST"
|
echo "Warning: Migration will overwrite the contents of $DST"
|
||||||
read -p "Are you sure you want to continue? (y/n): " CONFIRM
|
read -p "Are you sure you want to continue? (y/n): " CONFIRM
|
||||||
if [[ "$CONFIRM" != "y" && "$CONFIRM" != "Y" ]]; then
|
if [[ "$CONFIRM" != "y" && "$CONFIRM" != "Y" ]]; then
|
||||||
echo "Migration canceled."
|
echo "Migration canceled."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
|
||||||
|
|
||||||
echo "[INFO] source: $SRC"
|
|
||||||
echo "[INFO] target: $DST"
|
|
||||||
|
|
||||||
mkdir -p "$DST" "$DST/memory"
|
|
||||||
TS="$(date -u +%Y%m%dT%H%M%SZ)"
|
|
||||||
BACKUP_DIR="$DST/.migration-backup-$TS"
|
|
||||||
mkdir -p "$BACKUP_DIR"
|
|
||||||
|
|
||||||
# Backup existing key files if present
|
|
||||||
for f in AGENTS.md SOUL.md USER.md IDENTITY.md TOOLS.md MEMORY.md HEARTBEAT.md; do
|
|
||||||
if [[ -f "$DST/$f" ]]; then
|
|
||||||
cp -a "$DST/$f" "$BACKUP_DIR/$f"
|
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
if [[ -d "$DST/memory" ]]; then
|
|
||||||
cp -a "$DST/memory" "$BACKUP_DIR/memory" || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Migrate core persona/context files
|
echo "[INFO] source: $SRC"
|
||||||
for f in AGENTS.md SOUL.md USER.md IDENTITY.md TOOLS.md MEMORY.md HEARTBEAT.md; do
|
echo "[INFO] target: $DST"
|
||||||
if [[ -f "$SRC/$f" ]]; then
|
|
||||||
cp -a "$SRC/$f" "$DST/$f"
|
|
||||||
echo "[OK] migrated $f"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Merge memory directory
|
mkdir -p "$DST" "$DST/memory"
|
||||||
if [[ -d "$SRC/memory" ]]; then
|
TS="$(date -u +%Y%m%dT%H%M%SZ)"
|
||||||
rsync -a "$SRC/memory/" "$DST/memory/"
|
BACKUP_DIR="$DST/.migration-backup-$TS"
|
||||||
echo "[OK] migrated memory/"
|
mkdir -p "$BACKUP_DIR"
|
||||||
fi
|
|
||||||
|
|
||||||
# Optional: sync into embedded workspace template used by clawgo builds
|
# Backup existing key files if present
|
||||||
echo "[INFO] Syncing embed workspace template..."
|
|
||||||
if [[ -d "$DST" ]]; then
|
|
||||||
mkdir -p "$DST"
|
|
||||||
for f in AGENTS.md SOUL.md USER.md IDENTITY.md TOOLS.md MEMORY.md HEARTBEAT.md; do
|
for f in AGENTS.md SOUL.md USER.md IDENTITY.md TOOLS.md MEMORY.md HEARTBEAT.md; do
|
||||||
if [[ -f "$DST/$f" ]]; then
|
if [[ -f "$DST/$f" ]]; then
|
||||||
cp -a "$DST/$f" "$DST/$f"
|
cp -a "$DST/$f" "$BACKUP_DIR/$f"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ -d "$DST/memory" ]]; then
|
if [[ -d "$DST/memory" ]]; then
|
||||||
mkdir -p "$DST/memory"
|
cp -a "$DST/memory" "$BACKUP_DIR/memory" || true
|
||||||
rsync -a "$DST/memory/" "$DST/memory/"
|
|
||||||
fi
|
fi
|
||||||
echo "[OK] synced embed workspace template"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "[DONE] migration complete"
|
# Migrate core persona/context files
|
||||||
|
for f in AGENTS.md SOUL.md USER.md IDENTITY.md TOOLS.md MEMORY.md HEARTBEAT.md; do
|
||||||
|
if [[ -f "$SRC/$f" ]]; then
|
||||||
|
cp -a "$SRC/$f" "$DST/$f"
|
||||||
|
echo "[OK] migrated $f"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
elif [[ "$MIGRATION_TYPE" == "2" ]]; then
|
# Merge memory directory
|
||||||
echo "Proceeding with remote migration..."
|
if [[ -d "$SRC/memory" ]]; then
|
||||||
|
rsync -a "$SRC/memory/" "$DST/memory/"
|
||||||
|
echo "[OK] migrated memory/"
|
||||||
|
fi
|
||||||
|
|
||||||
read -p "Enter remote host (e.g., user@hostname): " REMOTE_HOST
|
# Optional: sync into embedded workspace template used by clawgo builds
|
||||||
read -p "Enter remote port (default 22): " REMOTE_PORT
|
echo "[INFO] Syncing embed workspace template..."
|
||||||
REMOTE_PORT="${REMOTE_PORT:-22}"
|
if [[ -d "$DST" ]]; then
|
||||||
read -sp "Enter remote password: " REMOTE_PASS
|
mkdir -p "$DST"
|
||||||
echo
|
for f in AGENTS.md SOUL.md USER.md IDENTITY.md TOOLS.md MEMORY.md HEARTBEAT.md; do
|
||||||
|
if [[ -f "$DST/$f" ]]; then
|
||||||
|
cp -a "$DST/$f" "$DST/$f"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ -d "$DST/memory" ]]; then
|
||||||
|
mkdir -p "$DST/memory"
|
||||||
|
rsync -a "$DST/memory/" "$DST/memory/"
|
||||||
|
fi
|
||||||
|
echo "[OK] synced embed workspace template"
|
||||||
|
fi
|
||||||
|
|
||||||
# Create a temporary SSH key for non-interactive SSH authentication (assuming sshpass is installed)
|
echo "[DONE] migration complete"
|
||||||
SSH_KEY=$(mktemp)
|
;;
|
||||||
sshpass -p "$REMOTE_PASS" ssh-copy-id -i "$SSH_KEY" "$REMOTE_HOST -p $REMOTE_PORT"
|
2)
|
||||||
|
echo "Proceeding with remote migration..."
|
||||||
|
|
||||||
# Prepare migration script
|
read -p "Enter remote host (e.g., user@hostname): " REMOTE_HOST
|
||||||
MIGRATION_SCRIPT="$TMPDIR/openclaw2clawgo.sh"
|
read -p "Enter remote port (default 22): " REMOTE_PORT
|
||||||
cat << 'EOF' > "$MIGRATION_SCRIPT"
|
REMOTE_PORT="${REMOTE_PORT:-22}"
|
||||||
|
read -sp "Enter remote password: " REMOTE_PASS
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Create a temporary SSH key for non-interactive SSH authentication (assuming sshpass is installed)
|
||||||
|
SSH_KEY=$(mktemp)
|
||||||
|
sshpass -p "$REMOTE_PASS" ssh-copy-id -i "$SSH_KEY" -p "$REMOTE_PORT" "$REMOTE_HOST"
|
||||||
|
|
||||||
|
# Prepare migration script
|
||||||
|
MIGRATION_SCRIPT="$TMPDIR/openclaw2clawgo.sh"
|
||||||
|
cat << 'EOF' > "$MIGRATION_SCRIPT"
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -256,15 +257,16 @@ fi
|
|||||||
echo "[DONE] migration complete"
|
echo "[DONE] migration complete"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Copy migration script to remote server and execute it
|
# Copy migration script to remote server and execute it
|
||||||
sshpass -p "$REMOTE_PASS" scp -P "$REMOTE_PORT" "$MIGRATION_SCRIPT" "$REMOTE_HOST:/tmp/openclaw2clawgo.sh"
|
sshpass -p "$REMOTE_PASS" scp -P "$REMOTE_PORT" "$MIGRATION_SCRIPT" "$REMOTE_HOST:/tmp/openclaw2clawgo.sh"
|
||||||
sshpass -p "$REMOTE_PASS" ssh -p "$REMOTE_PORT" "$REMOTE_HOST" "bash /tmp/openclaw2clawgo.sh"
|
sshpass -p "$REMOTE_PASS" ssh -p "$REMOTE_PORT" "$REMOTE_HOST" "bash /tmp/openclaw2clawgo.sh"
|
||||||
|
|
||||||
echo "[INFO] Remote migration completed."
|
echo "[INFO] Remote migration completed."
|
||||||
|
;;
|
||||||
else
|
*)
|
||||||
echo "Invalid choice. Skipping migration."
|
echo "Invalid choice. Skipping migration."
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Cleaning up..."
|
echo "Cleaning up..."
|
||||||
|
|||||||
Reference in New Issue
Block a user