#!/bin/sh # insinuate-dotfiles -- try to get my dotfiles onto a host, securely # Copyright (C) 2017-2019 Sean Whitton # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or (at # your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Replacement for COM.SILENTFLAME.CONSFIG::DOTFILES-INSINUATED for when I # can't access my consfig locally. Possible additional functionality would be # to do an update of what's already there, but this will be much slower over # sshfs than the following, which should copy files in just one direction # Enhancement: When don't have git on remote and src/dotfiles does not exist, # copy over .bashrc, .inputrc, .profile, .shinit, .emacs.d and maybe more, # unconditionally (i.e. overwrite what's there, in case want to update to a # newer version). Maybe confirm that I want to do that before copying, in # case what I would prefer is just to go and install git on the remote # machine. set -e # assume connection sharing is set up in ~/.ssh/config ssh -fN "$1" if ssh "$1" "test -d src/dotfiles"; then echo >&2 "src/dotfiles exists" exit 1 fi ssh "$1" "mkdir -p src/dotfiles" temp="$(mktemp -d -p $HOME/tmp insinuate.XXX)" git clone --no-hardlinks --depth 1 -o local -b master \ "file://$HOME/src/dotfiles" "$temp" ( cd "$temp" && git remote rm local && rm -r .git/refs/remotes/local ) tar -C"$temp/.." -zcf - "$(basename $temp)" \ | ssh "$1" 'tar --strip-components=1 -Csrc/dotfiles -zxf -' rm -rf "$temp" # copy my gpg key over there so I can use `mr up` to update dotfiles if ssh "$1" which gpg >/dev/null; then gpg --export-options export-minimal --export spwhitton@spwhitton.name \ | ssh "$1" gpg --import fi # stow dotfiles into $HOME ssh "$1" 'sh src/dotfiles/bin/bstraph'