-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
executable file
·170 lines (128 loc) · 5.16 KB
/
install.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#! /usr/bin/env bash
###################################################################################################
###################################################################################################
### Install script for Happy-Dude's dotfiles repository
###
### Author: Stanley Chan
### Github: https://github.com/Happy-Dude/dotfiles.git
### Version: Sat 21 Feb 2015
###
###################################################################################################
###################################################################################################
# Check if Git is installed and clone the repository and all submodules
`which git` --version 2>&1 >/dev/null # improvement by tripleee
GIT_IS_AVAILABLE=$?
if [ $GIT_IS_AVAILABLE -eq 0 ]; then
GIT_PATH=`which git`
GIT_OPTS="clone --recursive https://github.com/Happy-Dude/dotfiles.git $HOME/dotfiles"
GIT_UPDATE_OPTS="submodule update --init --recursive"
GIT_SUB_CHECKOUT="submodule foreach $GIT_PATH checkout master"
echo "Git found: cloning dotfiles repository into $HOME/dotfiles"
$GIT_PATH $GIT_OPTS
$GIT_PATH $GIT_SUB_OPTS
$GIT_PATH $GIT_UPDATE_OPTS
$GIT_PATH $GIT_SUB_CHECKOUT
else
echo "Git not found; please install git or download the zip archive of repo"
fi
`which vim` --version 2>&1 >/dev/null
VIM_IS_AVAILABLE=$?
if [ $VIM_IS_AVAILABLE -eq 0 ]; then
echo "vim found"
if [ -f $HOME/.vimrc ]; then
echo "Backing up existing .vimrc file to .vimrc.bak"
mv $HOME/.vimrc $HOME/.vimrc.bak
fi
if [ -d $HOME/.cache ]; then
if [ -d $HOME/.cache/vim ]; then
echo "Backing up existing vim cache directory in .cache"
mv $HOME/.cache/vim $HOME/.cache/vim.bak
fi
fi
echo "Creating vim backup, cache, undo, and view directories in $HOME/.cache/vim"
mkdir -p $HOME/.cache/vim $HOME/.cache/vim/backup $HOME/.cache/vim/swap $HOME/.cache/vim/undo $HOME/.cache/vim/view
echo "Linking $HOME/dotfiles/vim to $HOME/.vim"
ln -s $HOME/dotfiles/vim $HOME/.vim
echo "Linking $HOME/dotfiles/vim/vimrc to $HOME/.vimrc"
ln -s $HOME/dotfiles/vim/vimrc $HOME/.vimrc
fi
`which nvim` --version 2>&1 >/dev/null
NVIM_IS_AVAILABLE=$?
if [ $NVIM_IS_AVAILABLE -eq 0 ]; then
echo "nvim found"
if [ -f $HOME/.nvimrc ]; then
echo "Backing up existing .nvimrc file to .nvimrc.bak"
mv $HOME/.nvimrc $HOME/.nvimrc.bak
fi
echo "Linking $HOME/dotfiles/vim to $HOME/.nvim"
ln -s $HOME/dotfiles/vim $HOME/.nvim
echo "Linking $HOME/dotfiles/vim/vimrc to $HOME/.nvimrc"
ln -s $HOME/dotfiles/vim/vimrc $HOME/.nvimrc
fi
`which tmux` -V 2>&1 >/dev/null
TMUX_IS_AVAILABLE=$?
if [ $TMUX_IS_AVAILABLE -eq 0 ]; then
echo "tmux found"
if [ -f $HOME/.tmux.conf ]; then
echo "Backing up existing .tmux.conf file to .tmux.conf.bak"
mv $HOME/.tmux.conf $HOME/.tmux.conf.bak
fi
echo "Linking $HOME/dotfiles/tmux/tmux.conf to $HOME/.tmux.conf"
ln -s $HOME/dotfiles/tmux/tmux.conf $HOME/.tmux.conf
fi
`which zsh` --version 2>&1 >/dev/null
ZSH_IS_AVAILABLE=$?
if [ $ZSH_IS_AVAILABLE -eq 0 ]; then
echo "zsh found"
if [ -f $HOME/.zshrc ]; then
echo "Backing up existing .zshrc file to .zshrc.bak"
mv $HOME/.zshrc $HOME/.zshrc.bak
fi
echo "Linking Sorin's zsh-prezto"
ln -s ~/dotfiles/zsh/prezto-sorin ~/.zprezto;
setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done
echo "Changing default shell to zsh"
chsh -s `which zsh`
fi
`which iptables` -V 2>&1 >/dev/null
IPTABLES_IS_AVAILABLE=$?
if [ $IPTABLES_IS_AVAILABLE -eq 0 ]; then
echo "iptables found"
if [ -f "/etc/iptables/iptables.rules" ]; then
echo "Backing up existing IPTables ruleset"
mv /etc/iptables/iptables.rules /etc/iptables/iptables.rules.bak
fi
echo "Linking $HOME/dotfiles/iptables/iptables.rules to /etc/iptables/iptables.rules"
ln -s $HOME/dotfiles/iptables/iptables.rules /etc/iptables/iptables.rules
echo "Enabling iptables systemd unit"
systemctl enable iptables.service
fi
`which ip6tables` -V 2>&1 >/dev/null
IP6TABLES_IS_AVAILABLE=$?
if [ $IP6TABLES_IS_AVAILABLE -eq 0 ]; then
echo "IP6Tables found"
if [ -f "/etc/iptables/ip6tables.rules" ]; then
echo "Backing up existing IP6Tables ruleset"
mv /etc/iptables/ip6tables.rules /etc/iptables/ip6tables.rules.bak
fi
echo "Linking $HOME/dotfiles/iptables/ip6tables.rules to /etc/ip6tables/iptables.rules"
ln -s $HOME/dotfiles/iptables/ip6tables.rules /etc/ip6tables/iptables.rules
echo "Enabling ip6tables systemd unit"
systemctl enable ip6tables.service
fi
`which slim` -v 2>&1 >/dev/null
SLIM_IS_AVAILABLE=$?
if [ $SLIM_IS_AVAILABLE -eq 0 ]; then
echo "slim found"
if [ -f "/etc/slim.conf" ]; then
echo Backing up existing slim configuration"
mv /etc/slim.conf /etc/slim.conf.bak
fi
echo "Linking $HOME/dotfiles/slim/slim.conf to /etc/slim/slim.conf"
ln -s $HOME/dotfiles/slim/slim.conf /etc/slim/slim.conf
echo "Enabling slim systemd unit"
systemctl enable slim.service
fi