-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·102 lines (83 loc) · 1.67 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
DIR=`pwd`
DPATH=$DIR
# Shell colors
red='\e[0;31m'
green='\e[0;32m'
blue='\e[0;34m'
yellow='\e[0;33m'
NC='\e[0m'
# Define functions to print information in colorful
info ()
{
printf "[${blue} Info ${NC}] $1 \n"
}
query ()
{
printf "[${yellow} Input ${NC}] $1 "
}
success ()
{
printf "[${green} Success ${NC}] $1 \n"
}
fail ()
{
printf "[${red} Fail ${NC}] $1 \n"
echo ''
exit
}
# Configure git and mercurial
configure_version_control ()
{
# Git
info 'Configuring git and mercurial settings'
query 'Enter your git user name : '
read git_name
query 'Enter your git email : '
read git_email
sed -e "s/XXNAME/${git_name}/g; s/XXEMAIL/${git_email}/g" \
$DPATH/templates/gitconfig.template > $DPATH/.gitconfig
success 'Configured git settings'
}
# Linking and copying files
link_files ()
{
ln -s $1 $2
success "Linked $1 to $2"
}
copy_files ()
{
cp -r $1 $2
success "Copied $1 to $2"
}
cd "$(dirname "${BASH_SOURCE}")";
function copyfiles() {
configure_version_control
rsync --exclude ".git/" \
--exclude ".DS_Store" \
--exclude "bootstrap.sh" \
--exclude "README.md" \
--exclude "setup_osx.sh" \
--exclude "setup_linux.sh" \
--exclude "construction_zone/" \
--exclude "templates/" \
--exclude "*~" \
-avh --no-perms . ~/test-bootstrap
if [ -f $DPATH/.gitconfig ]
then
rm -rf $DPATH/.gitconfig
fi
source ~/.bashrc
}
if [ "$1" == "--force" ]
then
copyfiles
else
read -p "This may overwrite existing files. Are you sure? (y/n) " -n 1
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]
then
copyfiles
fi
fi
unset copyfiles