2020-11-07 16:57:15 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-11-07 17:07:59 +01:00
|
|
|
# - Prerequesits -
|
2020-11-07 17:12:42 +01:00
|
|
|
if [ "$(which git)" = "" ]; then
|
2021-06-22 13:05:12 +02:00
|
|
|
echo "-- Installing git --"
|
2020-11-08 21:55:05 +01:00
|
|
|
apt-get install git -y >/dev/null
|
2020-11-07 16:52:35 +01:00
|
|
|
fi
|
2020-11-07 16:40:23 +01:00
|
|
|
|
2020-11-08 21:55:05 +01:00
|
|
|
# - Cloning Repo -
|
2023-10-11 15:52:30 +02:00
|
|
|
cd $HOME
|
2023-10-11 16:47:27 +02:00
|
|
|
if [ -d ".git" ] || git rev-parse --git-dir > /dev/null 2>&1; then
|
|
|
|
# Get the remote URL
|
|
|
|
remote_url=$(git config --get remote.origin.url)
|
|
|
|
|
|
|
|
# Check if the remote URL contains a certain word
|
|
|
|
if [[ $remote_url != *jim-fx/.dotfiles* ]]; then
|
|
|
|
echo "Error: There is already a git repository setup at $HOME that is not pointing to the dotfiles"
|
|
|
|
else
|
|
|
|
echo "-- updating dotfiles --"
|
|
|
|
git fetch
|
|
|
|
git checkout -f main
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "-- initializing dotfiles --"
|
|
|
|
git init
|
|
|
|
git remote add origin https://github.com/jim-fx/.dotfiles.git
|
|
|
|
git fetch
|
|
|
|
git checkout -f main
|
|
|
|
fi
|
2020-11-07 16:40:23 +01:00
|
|
|
|
2020-11-07 17:07:59 +01:00
|
|
|
# - Executing the script -
|
2023-10-11 16:47:27 +02:00
|
|
|
echo "-- starting setup script --"
|
2020-11-08 21:55:05 +01:00
|
|
|
~/.dotfiles/setup.sh
|