-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·60 lines (49 loc) · 1.84 KB
/
setup
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
#!/bin/bash
# get path
DOTS_PATH=`pwd`
echo "Home path at: $DOTS_PATH"
# update submodule
#git submodule init --
#git submodule update --
# make profile
if [ ! -f profile ]; then
echo "#!/bin/bash">profile
echo "# This file is generated by setup!">>profile
echo "">>profile
echo "# Set the DOTS_PATH!">>profile
echo "DOTS_PATH=\"$DOTS_PATH\"">>profile
echo "">>profile
echo "# Include the dotfiles">>profile
echo "[ -f \"$DOTS_PATH/public\" ] && source \"$DOTS_PATH/public\"">>profile
echo "[ -f \"$DOTS_PATH/local\" ] && source \"$DOTS_PATH/local\"">>profile
echo "[ -f \"$DOTS_PATH/alias\" ] && source \"$DOTS_PATH/alias\"">>profile
fi
# link files
# [ ! -d ~/.bin ] && ln -s $DOTS_PATH/bin ~/.bin
# [ ! -d ~/.vim ] && ln -s $DOTS_PATH/vim ~/.vim
# [ ! -f ~/.vimrc ] && ln -s $DOTS_PATH/vimrc ~/.vimrc
# [ ! -f ~/.profile ] && ln -s $DOTS_PATH/profile ~/.profile
# make shell
function make_python_bin
{
__PY_FILE__="$DOTS_PATH/$1"
__TO_FILE__="$DOTS_PATH/$2"
if [ ! -f "$__TO_FILE__" ]; then
__CH_PARA__=""
echo "Make shell at: $__TO_FILE__"
echo "#!/bin/bash" > "$__TO_FILE__"
[ $# -gt 2 ] && [ "$3" = "true" ] && __CH_PARA__="&& [ ! -z "\$*" ] "
echo "[ -f \"$__PY_FILE__\" ] $__CH_PARA__&& python \"$__PY_FILE__\" \"\$*\"">>"$__TO_FILE__"
chmod u+x $__TO_FILE__
fi
}
[ ! -d "$DOTS_PATH/bin" ] && mkdir "$DOTS_PATH/bin"
make_python_bin "libs/ydcv/ydcv.py" "bin/dict" "true"
make_python_bin "libs/Tiny-HTTP-Proxy/TinyHTTPProxy.py" "bin/proxy"
# link hosts file
if [ ! -f /etc/hosts.bak ] && [ -f "$DOTS_PATH/libs/smarthosts/trunk/hosts" ]; then
echo "Backup hosts at: /etc/hosts.bak"
sudo mv /etc/hosts /etc/hosts.bak
echo "Link hosts with: $DOTS_PATH/libs/smarthosts/trunk/host"
sudo ln -s "$DOTS_PATH/libs/smarthosts/trunk/hosts" /etc/hosts
fi