-
Notifications
You must be signed in to change notification settings - Fork 0
/
wazo_install.sh
executable file
·227 lines (193 loc) · 6.15 KB
/
wazo_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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/bin/bash
# Copyright 2016-2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0+
# abort on error
set -eo pipefail
mirror="http://mirror.wazo.community"
update='apt-get update'
install='apt-get install --assume-yes'
download='apt-get install --assume-yes --download-only'
check_system() {
local version_file='/etc/debian_version'
if [ ! -f $version_file ]; then
echo "You must install Wazo on a Debian $debian_version (\"$debian_name\") system" 1>&2
echo "You do not seem to be on a Debian system" 1>&2
exit 1
else
version=$(cut -d '.' -f 1 "$version_file")
fi
if [ "$version" != "$debian_version" ]; then
echo "You must install Wazo on a Debian $debian_version (\"$debian_name\") system" 1>&2
echo "You are currently on a Debian $version system" 1>&2
exit 1
fi
}
add_apt_key() {
wget $mirror/wazo_current.key -O - | apt-key add -
}
add_mirror() {
echo "Add mirrors informations"
local deb_line="deb $mirror/$apt_repo $distribution main"
apt_dir="/etc/apt"
sources_list_dir="$apt_dir/sources.list.d"
if ! grep -qr "$deb_line" "$apt_dir"; then
echo "$deb_line" > $sources_list_dir/tmp-pf.sources.list
fi
add_apt_key
export DEBIAN_FRONTEND=noninteractive
$update
$install xivo-dist
xivo-dist "$distribution"
rm -f "$sources_list_dir/tmp-pf.sources.list"
$update
}
install_wazo () {
wget -q -O - $mirror/d-i/$debian_name/pkg.cfg | debconf-set-selections
kernel_release=$(uname -r)
$install --purge postfix
$download dahdi-linux-modules-$kernel_release xivo
$install dahdi-linux-modules-$kernel_release
$install xivo-base
if [ $gui -eq 1 ]; then
$install xivo
fi
xivo-service restart all
if [ $? -eq 0 ]; then
echo 'You must now finish the installation.'
if [ $gui -eq 1 ]; then
echo 'The installation wizard is available at:'
for ip_address in $(hostname -I); do
echo " https://$ip_address/"
done
fi
fi
}
get_ansible_installer() {
# Install git
apt-get update
apt-get install -yq git curl
# Setup Ansible directory
rm -rf /usr/src/wazo-ansible
cd /usr/src
# Get Ansible installer
git clone https://github.com/wazo-pbx/wazo-ansible
cd wazo-ansible
# Checkout requested Ansible installer version
git checkout $ansible_tag
}
install_wazo_with_ansible() {
# Setup Ansible environment
apt-get install -yq virtualenv python3-pip python
# Python 3 virtualenv encounters this bug:
# https://github.com/ansible/ansible/issues/21982
virtualenv /var/lib/wazo-ansible-venv
source /var/lib/wazo-ansible-venv/bin/activate
pip install 'ansible==2.7.9'
deactivate
# Run Ansible
echo "Installing $ansible_tag"
/var/lib/wazo-ansible-venv/bin/ansible-galaxy install -r requirements-postgresql.yml
/var/lib/wazo-ansible-venv/bin/ansible-playbook \
-i inventories/uc-engine \
--extra-vars wazo_debian_repo="$ansible_repo" \
--extra-vars wazo_distribution="$distribution" \
--extra-vars wazo_debian_repo_upgrade="$upgrade_repo" \
--extra-vars wazo_distribution_upgrade="$upgrade_dist" \
uc-engine.yml
# Cleanup Ansible
rm -rf /var/lib/wazo-ansible-venv
cd /usr/src
rm -rf /usr/src/wazo-ansible
apt-get purge --autoremove -yq python3-pip virtualenv
}
usage() {
cat << EOF
This script is used to install Wazo
usage : $(basename $0) [-c] [-o] {-p|-r|-d|-a version}
-c : install console mode (without web interface)
-o : install the old way (without ansible)
without arg (rda) : install production version
-p : install the new stable version 19.11+ (pelican)
-r : install release candidate version
-d : install development version
-a version : install archived version
EOF
exit 1
}
debian_name='buster'
debian_version='10'
# Installing without arguments
apt_repo='debian'
distribution='pelican-buster'
gui=1
use_ansible=0
while getopts ':crdpa:' opt; do
case ${opt} in
c)
gui=0
;;
p)
use_ansible=1
ansible_repo=main
distribution='pelican-buster'
upgrade_repo=main
upgrade_dist="$distribution"
ansible_tag=wazo-$(curl https://mirror.wazo.community/version/stable)
;;
r)
use_ansible=1
ansible_repo=main
distribution='wazo-rc-buster'
upgrade_repo=main
upgrade_dist="$distribution"
ansible_tag=origin/master
;;
d)
use_ansible=1
ansible_repo=main
distribution='wazo-dev-buster'
upgrade_repo=main
upgrade_dist="$distribution"
ansible_tag=origin/master
;;
a)
apt_repo='archive'
distribution="wazo-$OPTARG"
if [ "$OPTARG" \> "19.10" ]; then
use_ansible=1
ansible_repo=archive
ansible_tag="$distribution"
upgrade_repo=main
upgrade_dist=pelican-buster
fi
if [ "$OPTARG" \< "19.13" ]; then
debian_version='9'
debian_name='stretch'
upgrade_dist=pelican-stretch
fi
if [ "$OPTARG" \< "19.10" ]; then
echo "Ansible install not available for $OPTARG, defaulting to the former way." 1>&2
use_ansible=0
fi
if [ "$OPTARG" \< "18.01" ]; then
debian_version='8'
debian_name='jessie'
fi
if [ "$OPTARG" \< "16.16" ]; then
echo "This script only supports installing Wazo 16.16 or later." 1>&2
exit 1
fi
;;
*)
usage
;;
esac
done
check_system
if [ $use_ansible = 0 ]; then
add_mirror
install_wazo
else
get_ansible_installer
install_wazo_with_ansible
fi