34 lines
813 B
Bash
34 lines
813 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 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
|