-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddScripts.sh
44 lines (37 loc) · 972 Bytes
/
addScripts.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
#!/usr/bin/env bash
set -ex
: ${MYSCRIPTS:=${HOME}/scripts}
function ifInstall() {
if [ ! -z "$(which apt-get)" ]
then
if [ -z $(which ${1}) ]
then
sudo apt-get -q -y install ${1} || echo ${1} not found to install
fi
fi
}
ifInstall jq
ifInstall vim
ifInstall git
ifInstall curl
ifInstall net-tools
[[ -z $(which git) ]] && echo You need git installed! && exit 1
if [ -d "${MYSCRIPTS}" ]
then
pushd ${MYSCRIPTS}
git pull -r origin master
popd
else
git clone --recursive https://github.com/hibooboo2/scripts.git ${MYSCRIPTS}
fi
if [ ! -f "~/.bashrc" ]
then
echo "if tty -s; then . ${MYSCRIPTS}/scripts/.profile; fi" >> ~/.bashrc
elif [ ! -f "~/.profile" ]
then
echo "if tty -s; then . ${MYSCRIPTS}/scripts/.profile; fi" >> ~/.profile
else
echo Where do you want to source ${MYSCRIPTS}/.profile ?
read TOSOURCE
[[ -f "${TOSOURCE}" ]] && echo . ${MYSCRIPTS}/.profile >> ${TOSOURCE}
fi