-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·159 lines (130 loc) · 4.21 KB
/
install
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
#!/bin/bash
set -o nounset -o pipefail -o errexit
function check_cmd {
if ! which $1 > /dev/null; then
echo "Needs $1"
exit 5
fi
}
function install_tpm {
home="$1"
if ! [ -d $home/.tmux/plugins/tpm ]; then
mkdir -p $home/.tmux/plugins
git clone https://github.com/tmux-plugins/tpm $home/.tmux/plugins/tpm
fi
chown -R `basename $home`: $home/.tmux
}
function install_nvim {
if ! [ -d /opt/nvim-linux64 ]; then
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz
rm -rf /opt/nvim-linux64
tar -C /opt -xzf nvim-linux64.tar.gz
rm -f nvim-linux64.tar.gz
fi
}
function install_nvim_profile {
home="$1"
if ! [ -d $home/.config/nvim ]; then
mkdir -p $home/.config
git clone https://github.com/julsemaan/nvim-profile $home/.config/nvim
fi
cd $home/.config/nvim
git config --global --add safe.directory $home/.config/nvim
git pull
cd -
chown `basename $home`: $home/.config
chown -R `basename $home`: $home/.config/nvim
}
function install_file {
src="$1"
dst="$2"
user="${3:-}"
echo "Installing $src in $dst"
cp -a $src $dst
if ! [ -z "$user" ]; then
chown -R $user: $dst
fi
}
check_cmd git
check_cmd make
check_cmd gawk
LOCAL_INSTALL=${LOCAL_INSTALL:-}
if [ -z "$LOCAL_INSTALL" ]; then
d=$(mktemp -d)
function finish {
rm -fr $d
}
trap finish EXIT
git clone https://github.com/julsemaan/profile $d
else
d=`pwd`
fi
install_file $d/profile/.bashrc_append /usr/local/etc/.bashrc_append
install_file $d/profile/.inputrc /usr/local/etc/.inputrc
install_file $d/profile/.tmux.conf /usr/local/etc/.tmux.conf
install_file $d/profile/.vimrc /usr/local/etc/.vimrc
install_file $d/profile/.gitignore /usr/local/etc/.gitignore
install_file $d/profile/.blerc /usr/local/etc/.blerc
rm -fr /usr/local/etc/tmuxifiers
install_file $d/tmuxifiers/ /usr/local/etc/tmuxifiers
install_nvim
if ! [ -f /etc/cron.d/jprofile ] || [ $(md5sum /etc/cron.d/jprofile $d/cron | awk '{print $1}' | uniq | wc -l) -ne 1 ]; then
if [ -d /etc/cron.d ]; then
install_file $d/cron /etc/cron.d/jprofile
else
echo "Skipping cron installation because /etc/cron.d doesn't exist"
fi
fi
VIMRC=""
if [ -f /etc/vimrc ]; then
VIMRC="/etc/vimrc"
elif [ -f /etc/vim/vimrc ]; then
VIMRC="/etc/vim/vimrc"
fi
if ! [ -z "$VIMRC" ]; then
if ! grep 'source /usr/local/etc/.vimrc' $VIMRC > /dev/null 2>&1 ; then
echo "Installing the sourcing of vimrc in vimrc"
echo 'source /usr/local/etc/.vimrc' >> $VIMRC
echo "" >> $VIMRC
fi
fi
git config --system core.excludesfile /usr/local/etc/.gitignore
homes=(/home/* /root /Users/*)
for home in "${homes[@]}"; do
if [ $home == "/home/*" ]; then
continue
fi
if (which dscl > /dev/null 2>&1 && dscl . list /Users | grep -v '^_' | grep `basename $home` >/dev/null) || grep ^`basename $home`: /etc/passwd >/dev/null; then
if [ -d "$home" ]; then
install_file /usr/local/etc/.tmux.conf $home/.tmux.conf `basename $home`
install_file /usr/local/etc/.inputrc $home/.inputrc `basename $home`
install_file /usr/local/etc/.blerc $home/.blerc `basename $home`
BASHRC="$home/.bashrc"
if ! grep 'source /usr/local/etc/.bashrc_append' $BASHRC > /dev/null 2>&1 ; then
echo "Installing the sourcing of bashrc_append in $BASHRC"
echo 'source /usr/local/etc/.bashrc_append' >> $BASHRC
echo "" >> $BASHRC
fi
install_tpm $home
install_nvim_profile $home
fi
fi
done
if ! [ -d /usr/local/etc/.tmuxifier ]; then
git clone https://github.com/jimeh/tmuxifier.git /usr/local/etc/.tmuxifier
fi
if ! [ -d /usr/local/etc/.vim/bundle/Vundle.vim ]; then
git clone https://github.com/VundleVim/Vundle.vim.git /usr/local/etc/.vim/bundle/Vundle.vim
fi
if ! [ -f /usr/local/etc/ble.sh/out/ble.sh ]; then
rm -fr /usr/local/etc/ble.sh
git clone --depth 1 --recursive https://github.com/akinomyoga/ble.sh.git /usr/local/etc/ble.sh
make -C /usr/local/etc/ble.sh
chmod a+rw /usr/local/etc/ble.sh/out/
fi
if ! [ -f /usr/local/etc/.fzf.bash ]; then
rm -fr /usr/local/etc/fzf
git clone --depth 1 https://github.com/junegunn/fzf.git /usr/local/etc/fzf
/usr/local/etc/fzf/install --all --no-update-rc
mv $HOME/.fzf.bash /usr/local/etc/.fzf.bash
fi