Simplify sync script to use single archive
This commit is contained in:
parent
36526cd87f
commit
ef69a25e0f
1 changed files with 10 additions and 27 deletions
|
|
@ -6,37 +6,20 @@ set -e
|
|||
|
||||
REMOTE="${1:?Usage: $0 user@host}"
|
||||
LOCAL_HOME="$HOME"
|
||||
TMPDIR="/tmp/dotfiles-sync-$$"
|
||||
|
||||
echo "Creating archives..."
|
||||
chezmoi archive --output=/tmp/dotfiles.tar.gz
|
||||
tar -czf /tmp/claude-marketplaces.tar.gz -C ~/.claude/plugins marketplaces
|
||||
echo "Creating combined dotfiles archive..."
|
||||
mkdir -p "$TMPDIR/.claude/plugins"
|
||||
chezmoi archive --output=- | tar -xzf - -C "$TMPDIR"
|
||||
cp -r ~/.claude/plugins/marketplaces "$TMPDIR/.claude/plugins/"
|
||||
|
||||
# Combine into single archive
|
||||
echo "Combining archives..."
|
||||
mkdir -p /tmp/dotfiles-sync
|
||||
tar -xzf /tmp/dotfiles.tar.gz -C /tmp/dotfiles-sync
|
||||
mkdir -p /tmp/dotfiles-sync/.claude/plugins
|
||||
tar -xzf /tmp/claude-marketplaces.tar.gz -C /tmp/dotfiles-sync/.claude/plugins
|
||||
|
||||
echo "Syncing to $REMOTE (single connection)..."
|
||||
tar -czf - -C /tmp/dotfiles-sync . | ssh "$REMOTE" "
|
||||
set -e
|
||||
|
||||
echo 'Extracting dotfiles...'
|
||||
echo "Syncing to $REMOTE..."
|
||||
tar -czf - -C "$TMPDIR" . | ssh "$REMOTE" "
|
||||
cd ~ && tar -xzf -
|
||||
|
||||
echo 'Fixing paths for home directory...'
|
||||
for f in ~/.claude/plugins/installed_plugins.json ~/.claude/plugins/known_marketplaces.json; do
|
||||
if [ -f \"\$f\" ]; then
|
||||
sed -i.bak 's|$LOCAL_HOME|'\$HOME'|g' \"\$f\"
|
||||
rm -f \"\$f.bak\"
|
||||
fi
|
||||
[ -f \"\$f\" ] && sed -i.bak 's|$LOCAL_HOME|'\$HOME'|g' \"\$f\" && rm -f \"\$f.bak\"
|
||||
done
|
||||
|
||||
echo 'Done!'
|
||||
"
|
||||
|
||||
# Cleanup local temp files
|
||||
rm -rf /tmp/dotfiles-sync /tmp/dotfiles.tar.gz /tmp/claude-marketplaces.tar.gz
|
||||
|
||||
echo "Dotfiles and Claude marketplaces synced to $REMOTE"
|
||||
rm -rf "$TMPDIR"
|
||||
echo "Done!"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue