Add install.sh
This commit is contained in:
33
.mgr_config/install.sh
Normal file
33
.mgr_config/install.sh
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user