diff --git a/.mgr_config/install.sh b/.mgr_config/install.sh new file mode 100644 index 0000000..fdecf80 --- /dev/null +++ b/.mgr_config/install.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +git-home() { + git --git-dir=$HOME/.git_home/ --work-tree=$HOME $@ +} + +command -v git > /dev/null 2>&1 +if [[ $? != 0 ]]; then + echo "\"git\" does not appear to be installed. Install before continuing." + exit 1 +fi + +mkdir -p $HOME/.git_home + +git-home status > /dev/null 2>&1 +NEEDS_GIT_DIR=$? + +if [[ $NEEDS_GIT_DIR != 0 ]]; then + echo "Setting up git repository." + git init --bare ~/.git_home/ + git-home remote add origin https://gitlab.maxregan.me/max/configs.git + git-home pull origin master +fi + +echo "Checking out configs." +git-home checkout -b master origin/master +if [[ $? != 0 ]]; then + echo "Failed to checkout sources, there may be a conflicting file from the distribution. Fix and try again" + exit 1 +fi + +echo "Installed successfully! Restart this session or source ~/.bashrc" +exit 0