summaryrefslogtreecommitdiff
path: root/bin/insinuate-dotfiles
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-07-31 09:57:05 +0100
committerSean Whitton <spwhitton@spwhitton.name>2019-07-31 10:49:52 +0100
commita365609bddc8d574d23d47e5e46f90ab6c22416f (patch)
tree766faa92b3ae22e4c20ccf9307ef10ded817c8d9 /bin/insinuate-dotfiles
parent4d369316ea7319f7ade1dd2c205592ef4a73b56a (diff)
downloaddotfiles-a365609bddc8d574d23d47e5e46f90ab6c22416f.tar.gz
use a new technique to simplify insinuate-dotfiles
Diffstat (limited to 'bin/insinuate-dotfiles')
-rwxr-xr-xbin/insinuate-dotfiles75
1 files changed, 41 insertions, 34 deletions
diff --git a/bin/insinuate-dotfiles b/bin/insinuate-dotfiles
index 8d169436..cf3c5e29 100755
--- a/bin/insinuate-dotfiles
+++ b/bin/insinuate-dotfiles
@@ -1,47 +1,54 @@
#!/bin/sh
-# Try to get my dotfiles onto a host, securely
+# insinuate-dotfiles -- try to get my dotfiles onto a host, securely
-# Intended for machines on which I don't have root -- otherwise I'd
-# just use propellor
+# 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 <http://www.gnu.org/licenses/>.
-# Assumes ssh connection sharing
-# TODO use technique in verifyOriginBranch from propellor
-# TODO make a git bundle and SSH it to the host rather than cloning
-# over the network (don't even create an origin remote: leave that to
-# be added if we actually need to pull updates)
+# Intended for machines on which I don't have root -- otherwise I'd
+# just use propellor. 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
-# TODO also allow updating a remote by sending a git bundle and
-# cloning from it. or pushing remote branches to the repo from here?
+set -e
. $HOME/.shenv
-. $HOME/lib/tputfs.sh
-
-status "trying to clone dotfiles to $1 using git daemon protocol"
-
-# post-end of support for jessie (git-verify-commit on jessie does not support --raw)
-# ssh "$1" 'wget -O- https://spwhitton.name/spwhitton.asc | gpg --import'
-ssh "$1" 'cd $HOME && git clone --depth 1 git://spwhitton.name/dotfiles src/dotfiles'
+# assume connection sharing is set up in ~/.ssh/config
+ssh -fCN "$1"
-# pre-end of support for jessie
-hash=$(ssh "$1" 'cd $HOME/src/dotfiles && git show-ref -s master | head -n1')
-( cd "$HOME/src/dotfiles" && git branch --contains "$hash" | grep master)
-# post-end of support for jessie
-# ssh "$1" 'cd $HOME/src/dotfiles && git verify-commit --raw master 2>&1 | grep "VALIDSIG .* 8DC2487E51ABDD90B5C4753F0F56D0553B6D411B"'
-
-if [ $? = 0 ]; then
- status "clone ok; running bootstrap script"
- ssh "$1" 'cd $HOME && sh src/dotfiles/bin/bstraph.sh'
-else
- # pre-end of support for jessie
- status "couldn't find remote HEAD in local master branch"
- # post-end of support for jessie
- # status "couldn't verify PGP signature on dotfiles commit"
-
- status "nuking corrupted clone on $1"
- ssh "$1" 'rm -rf $HOME/src/dotfiles'
+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)"
+sshfs -C "$1:src/dotfiles" "$temp"
+git clone --no-hardlinks --local --depth 1 -o local "$HOME/src/dotfiles" "$temp"
+( cd "$temp" && git remote rm local)
+fusermount -u "$temp"
+rm -rf "$temp"
+
+# copy my gpg key over there so I can use `mr up` to update dotfiles
+if ssh "$1" which gpg; 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.sh'