forked from LiamBindle/bashdatacatalog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·51 lines (43 loc) · 1.58 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
#!/usr/bin/env bash
read -e -p "> Enter install prefix [$HOME]: " INSTALL_PREFIX
INSTALL_PREFIX=${INSTALL_PREFIX:-$HOME}
while [ ! -d $INSTALL_PREFIX ]; do
read -e -p "> Invalid path. Enter install prefix [$HOME]: " INSTALL_PREFIX
INSTALL_PREFIX=${INSTALL_PREFIX:-$HOME}
done
cd $INSTALL_PREFIX
if [ -d .bashdatacatalog ]; then
echo "An installation already exists. Updating it ..."
cd .bashdatacatalog
git pull
cd ..
else
echo "Downloading ..."
git clone https://github.com/LiamBindle/bashdatacatalog.git .bashdatacatalog
fi
while true; do
read -p "> Do you want to add this installation to your \$PATH? [Y/n]: " YESNO
YESNO=${YESNO:-Y}
case $YESNO in
[Yy])
read -e -p "> Enter your environment file [$HOME/.bashrc]: " ENVIRONMENT_FILE
ENVIRONMENT_FILE=${ENVIRONMENT_FILE:-$HOME/.bashrc}
while [ ! -f $ENVIRONMENT_FILE ]; do
read -p "> Invalid path. Enter your environment file [$HOME/.bashrc]: " ENVIRONMENT_FILE
ENVIRONMENT_FILE=${ENVIRONMENT_FILE:-$HOME/.bashrc}
done
ENTRY='export PATH=$PATH:'$INSTALL_PREFIX/.bashdatacatalog/bin
grep -F "$ENTRY" $ENVIRONMENT_FILE || echo "$ENTRY" >> $ENVIRONMENT_FILE
echo 'USER ACTION: bashdatacatalog is now available. Please restart your terminal.'
break
;;
[Nn])
echo "USER ACTION: You should manually add '$INSTALL_PREFIX/.bashdatacatalog' to \$PATH in your environment set up."
break
;;
* )
echo "> Please answer Y or N."
;;
esac
done
echo "Installation complete."