forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbootstrap-exclude.sh
executable file
·100 lines (89 loc) · 3.01 KB
/
bootstrap-exclude.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
#!/usr/bin/env bash -e
WORK_GIT_CONFIG=".gitconfig.work"
(
cd "$(dirname "${BASH_SOURCE}")"
#git pull origin master > /dev/null 2>&1
function printUsage() {
echo ""
echo "This is the bootstrap script."
echo ""
echo "${0} [OPTIONS]"
echo ""
echo "Options:"
echo " -f|--force When set, will not prompt the user for confirmation"
echo " --work When set, will synchronize work-related files"
echo ""
}
function doIt() {
INSTALL_WORK=${1}
echo "Synchronizing files..."
rsync --exclude ".git/" \
--exclude ".DS_Store" \
--exclude ".osx" \
--exclude "README.md" \
--exclude "LICENSE-MIT.txt" \
--exclude ".gitignore" \
--exclude ".idea" \
--exclude "*.iml" \
--exclude "*-exclude.sh" \
--exclude "*work" \
--verbose --archive --human-readable . ~
#source ${HOME}/.bash_profile;
POST_BOOTSTRAP="./post-bootstrap-exclude.sh"
if [ -f "${POST_BOOTSTRAP}" ]; then
source "${POST_BOOTSTRAP}"
fi
if [ "${INSTALL_WORK}" == "true" ]; then
echo "Synchronizing work realted files..."
set -x
rsync --verbose --archive --human-readable --no-perms "bin/work" ~/bin
rsync --verbose --archive --human-readable --no-perms "${WORK_GIT_CONFIG}" ~
POST_BOOTSTRAP_WORK="./post-bootstrap-work-exclude.sh"
if [ -f "${POST_BOOTSTRAP_WORK}" ]; then
source "${POST_BOOTSTRAP_WORK}"
fi
set +x
echo "****************************"
echo "* Update git user for work *"
echo "****************************"
read -p "Enter work name: "
work_name=$(echo "${REPLY}" | xargs) # trim leading and trailing spaces
git config --file ~/${WORK_GIT_CONFIG} user.name "${work_name}"
read -p "Enter work email address: "
work_email_address=$(echo "${REPLY}" | xargs) # trim leading and trailing spaces
git config --file ~/${WORK_GIT_CONFIG} user.email "${work_email_address}"
echo "Work git configuraiton file setup"
echo " - Name : '${work_name}'"
echo " - email: '${work_email_address}'"
set -x
fi
}
while [[ $# > 0 ]]; do
case $1 in
--force | -f)
FORCE=true
shift
;;
--work)
WORK=true
shift
;;
*)
# unknown option
echo "Unknown Option: $1"
printUsage
exit 1
;;
esac
done
if [ "${FORCE}" == "true" ]; then
doIt ${WORK}
else
read -p "This may overwrite existing files in your home directory. Are you sure? [y/N] " -n 1
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
doIt ${WORK}
fi
fi
unset doIt
)