-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·130 lines (111 loc) · 2.99 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
#!/bin/bash
function splash {
echo ""
echo -e "\e[0;32m\e[40m \e[0m"
echo -e "\e[0;32m\e[40m GAPI - Graph Application Programming Interface \e[0m"
echo -e "\e[0;32m\e[40m version: 1.0a \e[0m"
echo -e "\e[0;32m\e[40m \e[0m"
}
function msg {
echo -ne "\e[0;37m\e[40m >>> \e[m "
if [[ $1 == "n" ]] ; then
echo -ne "$2"
else
echo -e "$1"
fi
}
function err {
echo -ne "\e[0;91m\e[40m >>> \e[m "
echo $1
}
function ask {
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
default=Y
elif [ "${2:-}" = "N" ]; then
prompt="y/N"
default=N
else
prompt="y/n"
default=
fi
# Ask the question
msg n "$1 [$prompt] "
read REPLY
# Default?
if [ -z "$REPLY" ]; then
REPLY=$default
fi
# Check if the reply is valid
case "$REPLY" in
Y*|y*) return 0 ;;
N*|n*) return 1 ;;
esac
done
}
splash
IPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #"
IDIR="$IPATH/core"
# check arguments
if [ ! -z "$1" ]; then
IDIR="$1"
fi
# absolute path test
if [[ $IDIR != /* ]] ; then
IDIR="$IPATH/$IDIR"
fi
# create target directory and cd there
msg "Create install directory... $IDIR"
if mkdir -p "$IDIR" ; then
cd $IDIR
else
err "Creating directory failed."
exit 1
fi
# clone base
msg "Cloning install base repository..."
if ! git clone https://github.com/pirati-cz/gapi.git $IDIR ; then
err "Cloning failed."
exit 1
fi
# build Docker gapi image?
if ask "Do you want build gapi Docker image?" Y; then
cd $IDIR
./build_image.sh
fi
# system user
msg "In GAPI we use user 'app' (uid: 9999) and group 'app' (gid: 9999)."
if ask "Do you want create group 'app' with gid 9999?" Y; then
groupadd -g 9999 app
fi
if ask "Do you want create user 'app' with uid 9999?" Y; then
useradd -u 9999 app
fi
if ask "Do you want add your user $(whoami) into 'app' gorup?" Y; then
usermod -G app -a $(whoami)
fi
# components
msg "Install GAPI components. For information visit GAPI webpage (https://github.com/pirati-cz/gapi)."
if ask "Do you install gapi-sparql component?" Y; then
msg "Cloning repository..."
if ! git clone https://github.com/pirati-cz/gapi-sparql.git $IDIR/app/gapi-sparql ; then
err "Cloning failed."
exit 1
fi
fi
if ask "Do you install gapi-web component?" Y; then
msg "Cloning repository..."
if ! git clone https://github.com/pirati-cz/gapi-web.git $IDIR/app/gapi-web ; then
err "Cloning failed."
exit 1
fi
fi
# run
if ask "Do you run gapi-web component?" Y; then
echo "./gapi-web/bin/gapi-web.js" >> $IDIR/app/gapi.sh
fi
echo "exit 0" >> $IDIR/app/gapi.sh
msg "You can now run gapi Docker container via 'gapi.sh' bash script. Run ./gapi.sh for usage."
msg "Have a nice graphing!"
exit 0