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}"
|
REMOTE="${1:?Usage: $0 user@host}"
|
||||||
LOCAL_HOME="$HOME"
|
LOCAL_HOME="$HOME"
|
||||||
|
TMPDIR="/tmp/dotfiles-sync-$$"
|
||||||
|
|
||||||
echo "Creating archives..."
|
echo "Creating combined dotfiles archive..."
|
||||||
chezmoi archive --output=/tmp/dotfiles.tar.gz
|
mkdir -p "$TMPDIR/.claude/plugins"
|
||||||
tar -czf /tmp/claude-marketplaces.tar.gz -C ~/.claude/plugins marketplaces
|
chezmoi archive --output=- | tar -xzf - -C "$TMPDIR"
|
||||||
|
cp -r ~/.claude/plugins/marketplaces "$TMPDIR/.claude/plugins/"
|
||||||
|
|
||||||
# Combine into single archive
|
echo "Syncing to $REMOTE..."
|
||||||
echo "Combining archives..."
|
tar -czf - -C "$TMPDIR" . | ssh "$REMOTE" "
|
||||||
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...'
|
|
||||||
cd ~ && tar -xzf -
|
cd ~ && tar -xzf -
|
||||||
|
|
||||||
echo 'Fixing paths for home directory...'
|
|
||||||
for f in ~/.claude/plugins/installed_plugins.json ~/.claude/plugins/known_marketplaces.json; do
|
for f in ~/.claude/plugins/installed_plugins.json ~/.claude/plugins/known_marketplaces.json; do
|
||||||
if [ -f \"\$f\" ]; then
|
[ -f \"\$f\" ] && sed -i.bak 's|$LOCAL_HOME|'\$HOME'|g' \"\$f\" && rm -f \"\$f.bak\"
|
||||||
sed -i.bak 's|$LOCAL_HOME|'\$HOME'|g' \"\$f\"
|
|
||||||
rm -f \"\$f.bak\"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo 'Done!'
|
|
||||||
"
|
"
|
||||||
|
|
||||||
# Cleanup local temp files
|
rm -rf "$TMPDIR"
|
||||||
rm -rf /tmp/dotfiles-sync /tmp/dotfiles.tar.gz /tmp/claude-marketplaces.tar.gz
|
echo "Done!"
|
||||||
|
|
||||||
echo "Dotfiles and Claude marketplaces synced to $REMOTE"
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue