summaryrefslogtreecommitdiff
path: root/bin/insinuate-dotfiles
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2017-01-05 14:49:02 -0700
committerSean Whitton <spwhitton@spwhitton.name>2017-01-05 14:49:02 -0700
commitc47b71973feff378832f52edfe449cdffc4d5e62 (patch)
tree29e7d3421378c73e2397708cd49a5ba194a4262c /bin/insinuate-dotfiles
parent8b1bf012ae97d8445e07b4e7696128699c76d8c4 (diff)
downloaddotfiles-c47b71973feff378832f52edfe449cdffc4d5e62.tar.gz
new insinuate-dotfiles script
Diffstat (limited to 'bin/insinuate-dotfiles')
-rwxr-xr-xbin/insinuate-dotfiles38
1 files changed, 38 insertions, 0 deletions
diff --git a/bin/insinuate-dotfiles b/bin/insinuate-dotfiles
new file mode 100755
index 00000000..3513c689
--- /dev/null
+++ b/bin/insinuate-dotfiles
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Try to get my dotfiles onto a host
+
+# Intended for machines on which I don't have root -- otherwise I'd
+# just use propellor. The reason for using this script rather than
+# simply sshing in and running `git clone` is to avoid zsh's "first
+# run" screen on Debian hosts
+
+# Assumes ssh connection sharing
+
+. $HOME/.shenv
+. $HOME/lib/tputfs.sh
+
+status "trying to clone dotfiles to $1 using https"
+ssh "$1" 'cd $HOME && git clone https://git.spwhitton.name/dotfiles src/dotfiles'
+
+# https:// can fail for older ca-certificates, so try git://
+if ! [ $? = 0 ]; then
+ status "trying to clone dotfiles to $1 using git transport"
+ ssh "$1" 'cd $HOME && git clone git://spwhitton.name/dotfiles' src/dotfiles
+ if ! [ $? = 0 ]; then
+ status "couldn't clone dotfiles on $1"
+ exit 1
+ fi
+
+ # since we used an insecure transport, verify
+ hash=$(ssh "$1" 'cd $HOME/src/dotfiles && git show-ref -s master | head -n1')
+ if ! ( cd "$HOME/src/dotfiles" && git branch --contains "$hash" | grep master); then
+ status "couldn't find remote HEAD in local master branch"
+ status "nuking corrupted clone on $1"
+ ssh "$1" 'rm -rf $HOME/src/dotfiles'
+ exit 1
+ fi
+fi
+
+status "clone ok; running bootstrap script"
+ssh "$1" 'cd $HOME && sh src/dotfiles/bin/bstraph.sh'