-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·197 lines (147 loc) · 3.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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
# Colors
GREEN='\e[1;32m'
RED='\e[0;31m'
CYAN='\e[0;36m'
NC='\e[0m'
YELLOW='\e[1;33m'
# LIBRE Location
LIBRE_VERSION='re-0.4.7'
LIBRE_SOURCE="http://www.creytiv.com/pub/${LIBRE_VERSION}.tar.gz"
# LIBREM Location
LIBREM_VERSION='rem-0.4.5'
LIBREM_SOURCE="http://www.creytiv.com/pub/${LIBREM_VERSION}.tar.gz"
RUBY_VERSION='2.1.1'
RUBY_SOURCE="http://cache.ruby-lang.org/pub/ruby/stable/ruby-${RUBY_VERSION}.tar.gz"
root_check () {
echo -en "Checking for root... "
if [[ `whoami` == 'root' ]] ; then
echo -e "[ ${GREEN}OK${NC} ]"
else
echo -e "[${RED}FAIL${NC}]"
echo "Please 'su' to root and re-run this script"
exit 1
fi
}
install_libre () {
echo -e "Installing libre..."
pushd .
cd dependencies
wget $LIBRE_SOURCE
tar xvzf ${LIBRE_VERSION}.tar.gz
cd $LIBRE_VERSION
make
make install
popd
echo -e "Installing libre... [ ${GREEN}OK${NC} ]"
}
install_librem () {
echo -e "Installing librem..."
pushd .
cd dependencies
wget $LIBREM_SOURCE
tar xvzf ${LIBREM_VERSION}.tar.gz
cd $LIBREM_VERSION
make
make install
popd
echo -e "Installing librem... [ ${GREEN}OK${NC} ]"
}
install_baresip () {
echo -e "Installing baresip..."
pushd .
cd dependencies/baresip
make
make install
popd
echo -e "Installing baresip... [ ${GREEN}OK${NC} ]"
}
link_urix () {
echo -en "Linking URIx libraries..."
mkdir -p lib
pushd .
cd lib
ln -s ../dependencies/URIx-Util/urix/urix.rb
ln -s ../dependencies/URIx-Util/urix/urix
echo -e " [ ${GREEN}OK${NC} ]"
}
install_ruby_gems () {
echo -e "Running bundle install... "
bundle install
echo -e "Running bundle install... [ ${GREEN}OK${NC} ]"
}
install_build_tools () {
if which yum > /dev/null ; then
yum -y groupinstall 'Development Tools'
yum -y install libusb libusb-devel
return
fi
if which apt-get > /dev/null ; then
apt-get -y install build-essential libusb-dev libusb
return
fi
}
check_ruby () {
echo -en "Checking for ruby... "
if which ruby > /dev/null ; then
echo -e "[ ${GREEN}OK${NC} ]"
echo -en "Checking ruby for version ${CYAN}${RUBY_VERSION}${NC}... "
if ruby --verion | grep "^ruby ${RUBY_VERSION}" > /dev/null 2> /dev/null ; then
echo -e "[ ${GREEN}OK${NC} ]"
return
else
echo -e "[${RED}FAIL${NC}]"
install_ruby
return
fi
else
echo -e "[${RED}FAIL${NC}]"
install_ruby
return
fi
}
install_ruby () {
echo -e "Installing ruby... "
pushd .
cd dependencies
wget $RUBY_SOURCE
tar xvzf ruby-${RUBY_VERSION}.tar.gz
cd ruby-${RUBY_VERSION}
./configure
make
make install
popd
echo -e "Installing ruby... [ ${GREEN}OK${NC} ]"
}
install_init_scripts () {
echo -en "Installing baresip init script... "
cp init-scripts/baresip /etc/init.d/baresip
echo -e "[ ${GREEN}OK${NC} ]"
echo -en "Setting baresip to start on boot... "
if which update-rc.d > /dev/null ; then
update-rc.d baresip enable
echo -e "[ ${GREEN}OK${NC} ]"
elif which chkconfig > /dev/null ; then
chkconfig baresip on
echo -e "[ ${GREEN}OK${NC} ]"
else
echo -e "[${RED}FAIL${NC}]"
fi
}
install_dependencies () {
install_build_tools
check_ruby
install_ruby_gems
install_libre
install_librem
ldconfig
install_baresip
ldconfig
link_urix
}
main () {
root_check
install_dependencies
install_init_scripts
}
main