Files
configs/.mgr_config/install.sh
2020-06-26 05:19:09 +00:00

34 lines
826 B
Bash

#!/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 branch master --set-upstream-to origin/master
fi
echo "Checking out configs."
git-home pull 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