Last active
May 23, 2019 23:19
-
-
Save zevisert/f3e3b698ad09637b071e394671e7896a to your computer and use it in GitHub Desktop.
Initialize from my private dotfiles repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Call this using curl: | |
# curl -Lks https://bit.do/zevisert-dots | /bin/bash | |
# Fallback to MD5(zevisert-ssh) if no hash is specified | |
MD5_KEY=${1:-d2:68:da:ce:5c:d8:d1:30:19:6c:63:b8:e9:fa:38:d1} | |
# Check for an ssh-agent | |
if [ -n "$SSH_AGENT_PID" -a -e /proc/$SSH_AGENT_PID ]; | |
then | |
matching_hashes=$(ssh-add -E MD5 -l | grep -c $MD5_KEY); | |
if [[ $matching_hashes -le 0 ]]; | |
then | |
echo "[zevisert-dots]: SSH-Agent does not have key MD5: $MD5_KEY, cloning aborted."; | |
exit 1; | |
fi | |
else | |
echo "[zevisert-dots]: No SSH-Agent found, needed to secure clone dot files."; | |
exit 1; | |
fi | |
# Clone the repo | |
git clone --bare [email protected]:zevisert/dots.git $HOME/.cfg | |
if [ $? -ne 0 ]; | |
then | |
echo "[zevisert-dots]: Aborting"; | |
exit 1; | |
fi | |
# Temporary config 'alias' | |
function config { | |
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@ | |
} | |
config checkout | |
if [ $? = 0 ]; | |
then | |
echo "[zevisert-dots]: Checked out config."; | |
else | |
mkdir -p $HOME/.dots-conflicts | |
echo "[zevisert-dots]: Backing up pre-existing dot files."; | |
config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} sh -c "mkdir --parents $HOME/.dots-conflicts/{}; mv {} $HOME/.dots-conflicts/{}" | |
fi; | |
config checkout | |
config config status.showUntrackedFiles no | |
echo "[zevisert-dots]: Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment