cfg/bin/ensure-config.sh

30 lines
752 B
Bash
Raw Normal View History

#!/bin/bash
PUB_CONFIG="git@github.com:Luzifer/cfg.git"
SEC_CONFIG="git@gitlab.com:luzifer/cfg.git"
if ! [ -d ${HOME}/.cfg/public ]; then
git clone --bare ${PUB_CONFIG} ${HOME}/.cfg/public
fi
if ! [ -d ${HOME}/.cfg/secret ]; then
git clone --bare ${SEC_CONFIG} ${HOME}/.cfg/secret
fi
function config {
git --git-dir=${HOME}/.cfg/${REPO}/ --work-tree=${HOME} $@
}
for REPO in public secret; do
config checkout
if [ $? = 0 ]; then
echo "Checked out config.";
else
echo "Backing up pre-existing dot files.";
config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} .config-backup/{}
fi;
config checkout
config config status.showUntrackedFiles no
2016-08-11 17:12:25 +00:00
config submodule update --init --recursive
done