-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·83 lines (68 loc) · 2.45 KB
/
install.sh
File metadata and controls
executable file
·83 lines (68 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
case $(uname -s) in
Darwin*)
git >/dev/null
;;
esac
# Create personal Repos folder and cd into it
mkdir -p ~/Documents/Thiago/Repos
cd ~/Documents/Thiago/Repos || exit
# Check if git is installed
if ! git --version; then
echo "Git needs to be installed before. Please follow system instructions to install git and try again"
exit 1
fi
GITHUB_URL="https://github.com/trystan2k/dotfiles.git"
echo "Do you want to use SSH to clone the repo (y/n) ? (No will use HTTPS)"
read -r action
case "$action" in
y|Y )
if [ ! -f "$HOME/.ssh/id_rsa.pub" ] ; then
echo "The SSH key does not exist. Let´s create it."
echo "Press enter to start"
# shellcheck disable=SC2034
read -r response
ssh-keygen -t rsa -f "$HOME/.ssh/id_rsa" -q -P ""
fi
if [ ! -f "$HOME/.ssh/id_rsa.pub" ] ; then
echo "There was an error creating or reading your SSH key at $HOME/.ssh/id_rsa.pub."
echo "Please check if everything is ok and try again"
exit 2
fi
echo "Now, copy the SSH and add to your GitHub account, to be able to clone the repository via SSH"
echo "Once you have the key added, press enter to continue"
echo ""
cat "$HOME/.ssh/id_rsa.pub"
echo "Press enter to start"
# shellcheck disable=SC2034
read -r response
GITHUB_URL="git@github.com:trystan2k/dotfiles.git"
;;
* )
;;
esac
# Clone dotfiles repo and cd into it
git clone $GITHUB_URL
cd dotfiles || exit
echo "Which branch should be used to install the dotfiles ? (Default: main)"
read -r branch2Use
branch2Use="${branch2Use:=main}"
# Check if branch exist
git ls-remote --exit-code --heads --quiet origin refs/heads/"$branch2Use" > /dev/null
result=$?
if [ ! "$result" -eq 0 ] ; then
echo "Branch $branch2Use does not exist. Fallback to main branch"
echo "Press any key to continue"
# shellcheck disable=SC2034
read -r temp
branch2Use="main"
fi
# Go to branch
git checkout "$branch2Use"
# Ensure Terminal has right permissions
echo "Add Terminal to have App Management permissions (System > Privacy & Security > App Management). Press any key to continue"
# shellcheck disable=SC2034
read -r temp
# Cd into scripts folder and execute bootstrap
cd scripts || exit
bash bootstrap.sh