-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·94 lines (81 loc) · 2.44 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
#!/bin/bash
if [[ "$BASH_SOURCE[0]" == "" ]]; then
export _COMMANDER_HOME=$(cd $(dirname $0) 2>&1 >/dev/null; pwd)
else
export _COMMANDER_HOME=$(cd $(dirname $BASH_SOURCE[0]) 2>&1 >/dev/null; pwd)
fi
. $_COMMANDER_HOME/libs/util.sh
#_debug_on_
# configs
if [[ ! -d $_COMMANDER_HOME/configs ]]; then
_exec_ mkdir -p $_COMMANDER_HOME/configs
echo "directory created[$_COMMANDER_HOME/configs]"
fi
# scripts
if [[ ! -d $_COMMANDER_HOME/scripts ]]; then
_exec_ mkdir -p $_COMMANDER_HOME/scripts
echo "directory created[$_COMMANDER_HOME/scripts]"
fi
# editor
read -p "please input your editor [default: vi]: " editor
if [[ $editor == "" ]]; then
editor=vi
fi
# configs/setup.sh
_cf_var_write_ "setup.sh" "editor" $editor
echo -n "git user name: "
read name
if [[ "$name" == "" ]]; then
echo "name can't empty"
return
fi
echo -n "git user email: "
read email
if [[ "$email" == "" ]]; then
echo "email can't empty"
return
fi
# configs/setup.cf
_cf_append_ "setup.cf" "git config --local user.name "\"$name\"
_cf_append_ "setup.cf" "git config --local user.email "\"$email\"
# volumns
read -p "please input your data root directory [default: $_COMMANDER_HOME/volumns]: " data_dir
if [[ $data_dir == "" ]]; then
data_dir=$_COMMANDER_HOME/volumns
fi
# symbol link
if [[ ! -d $_COMMANDER_HOME/volumns ]]; then
if [[ $data_dir != "$_COMMANDER_HOME/volumns" ]]; then
if [[ ! -d $data_dir ]]; then
_exec_ mkdir -p $data_dir
echo "directory created [$data_dir]."
fi
_exec_ ln -s $data_dir $_COMMANDER_HOME/volumns
echo "symbol linked the directory [$_COMMANDER_HOME/volumns] to [$data_dir]."
else
_exec_ mkdir -p $_COMMANDER_HOME/volumns
echo "directory created [$data_dir]."
fi
fi
# brew
_check_ "brew"
ret=$?
if [[ "$ret" == "1" ]]; then
echo "install [brew]..."
_exec_ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo "install [brew]...ok"
fi
# note
echo
echo "============================================================"
echo " NOTE "
echo "============================================================"
echo "please execute: "
echo " echo 'source $_COMMANDER_HOME/command.sh' >> ~/.bash_profile"
echo " source ~/.bash_profile"
echo "or for zsh: "
echo " echo 'autoload bashcompinit' >> ~/.zshrc"
echo " echo 'bashcompinit' >> ~/.zshrc"
echo " echo 'source $_COMMANDER_HOME/command.sh' >> ~/.zshrc"
echo " source ~/.zshrc"
echo "run \"cmd help\" to print all available functions"