-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·104 lines (94 loc) · 2.22 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
#!/usr/bin/env bash
function error {
echo $*
exit 2
}
CURRENT=${0}
export DARING_CLI_TOOLS_DIR=$(cd $(dirname $CURRENT); pwd)
if type fish >/dev/null 2>&1
then
if ! test -e ~/.config/fish/conf.d/cli-tools.fish
then
if ! test -d ~/.config/fish/conf.d
then
mkdir -p ~/.config/fish/conf.d
fi
ln -s $DARING_CLI_TOOLS_DIR/etc/rc.fish ~/.config/fish/conf.d/cli-tools.fish
echo Linked ~/.config/fish/conf.d/cli-tools.fish
fi
fi
function add_line {
RCFILE=$1
LINE=$2
if ! test -e $RCFILE
then
touch $RCFILE
fi
if ! grep daringway-cli-tools $RCFILE >/dev/null 2>&1
then
echo $LINE "# daringway-cli-tools" >> $RCFILE
echo updated $RCFILE
fi
}
if type bash >/dev/null 2>&1
then
RCFILE=~/.bashrc
LINE="eval \"\$(${DARING_CLI_TOOLS_DIR}/etc/bash-init)\""
if ! test -e $RCFILE
then
touch $RCFILE
fi
if ! grep daringway-cli-tools $RCFILE >/dev/null 2>&1
then
echo $LINE "# daringway-cli-tools" >> $RCFILE
echo updated $RCFILE
fi
fi
if type zsh >/dev/null 2>&1
then
RCFILE=~/.zshenv
LINE="source \"${DARING_CLI_TOOLS_DIR}/etc/rc.zsh\""
if ! test -e $RCFILE
then
touch $RCFILE
fi
if ! grep daringway-cli-tools $RCFILE >/dev/null 2>&1
then
echo $LINE "# daringway-cli-tools" >> $RCFILE
echo updated $RCFILE
fi
fi
DIRENV_DIR=~/.config/direnv/lib
if ! test -f $DIRENV_DIR/cli-tools.sh
then
mkdir -p $DIRENV_DIR 2>/dev/null
ln -s $DARING_CLI_TOOLS_DIR/direnv.sh $DIRENV_DIR/cli-tools.sh
fi
function printWarning {
if [[ "${WARNING_PRINTED}" == "" ]]
then
WARNING_PRINTED=yes
echo "WARNING: not all applications and packages are installed for full cli-tools functionality"
echo " install missing appllications and packages and run install.sh again"
fi
echo " "$*
}
# Check if all the required applications are installed.
for P in direnv python3 pip3 jq git ssh env sh bash fish
do
if ! type $P >/dev/null 2>&1
then
printWarning ""\"${P}\" not installed""
fi
done
# Check for python libraries
if type pip3 >/dev/null 2>&1
then
for P in boto3 aws2-wrap ec2instanceconnectcli
do
if ! pip3 show $P >/dev/null 2>&1
then
printWarning "\"$P\" not installed, to install: \"sudo pip3 install ${P}\""
fi
done
fi