42 lines
1.0 KiB
Bash
Executable File
42 lines
1.0 KiB
Bash
Executable File
#!/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
|
|
git-home config status.showUntrackedFiles no
|
|
git-home submodule update --init --recursive
|
|
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
|
|
|
|
touch $HOME/.bashrc
|
|
SRC_LINE="source ~/.mgr_config/.bashrc"
|
|
if ! grep "$SRC_LINE" $HOME/.bashrc > /dev/null; then
|
|
echo "$SRC_LINE" >> ~/.bashrc
|
|
fi
|
|
|
|
echo "Installed successfully! Restart this session or source ~/.bashrc"
|
|
exit 0
|