-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
55 lines (46 loc) · 1.22 KB
/
bootstrap.sh
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
#!/bin/bash
#
# Basic script to clone this repository to $HOME/.repos/configs
#
function info {
echo "--" $*
}
function exit_if_command_not_available {
if [ -z $(which $1) ]; then
echo "Installation requires the $1 command to be available"
exit 1
fi
}
exit_if_command_not_available git
exit_if_command_not_available curl
# fix home
if [ $(whoami) = "root" ]; then
home="/root"
else
home=$HOME
fi
# clone the repository
local_repos_dir=$home/.repos
repo_name=configs
local_clone_dir=$home/.repos/$repo_name
remote_repo="https://[email protected]/martyngigg/configs.git"
info "home is" $home
info "configs folder is" $local_clone_dir
[ -d $local_repos_dir ] || mkdir $local_repos_dir
if [ ! -d $local_clone_dir ]; then
info "trying clone from remote '$remote_repo' into '$local_clone_dir'"
git clone --recursive $remote_repo $local_clone_dir
if [ $? -ne 0 ]; then
info "cloning from remote failed. unable to continue"
exit 1
fi
else
info "local clone exists at '$local_clone_dir'. updating from origin master"
cd $local_clone_dir
git pull origin master
if [ $? -ne 0 ]; then
info "error updating local copy in '$local_clone_dir'"
info "continuing with current state"
fi
fi
info "done!"