-
Notifications
You must be signed in to change notification settings - Fork 5
/
install.sh
executable file
·155 lines (122 loc) · 4.2 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
#!/bin/bash
AST_VERSION=13
AST_TARBALL=asterisk-13.10.0-rc2
PJPROJECT_TARBALL=pjproject-2.4.5
CLEANUP=0
install_prereqs() {
echo "*** Installing System Libraries ***"
PACKAGES="build-essential python-pip vim apache2 ssh ccache pkg-config"
PACKAGES="${PACKAGES} libncurses-dev libssl-dev libxml2-dev libsqlite3-dev uuid-dev uuid"
PACKAGES="${PACKAGES} libspandsp-dev binutils-dev libsrtp-dev libedit-dev libjansson-dev"
PACKAGES="${PACKAGES} subversion git libxslt1-dev"
aptitude install -y ${PACKAGES}
easy_install -U pip
pip install ari
}
install_pjproject() {
if [ ! -d pjproject-${PJPROJECT_TARBALL} ]; then
echo "*** Grabbing PJPROJECT: ${PJPROJECT_TARBALL} ***"
# Go ahead and use our github repo. Who knows, maybe
# we fixed something.
sudo -u ${USERNAME} wget https://github.com/asterisk/pjproject/archive/${PJPROJECT_TARBALL}.tar.gz
sudo -u ${USERNAME} tar -zxvf ${PJPROJECT_TARBALL}.tar.gz
fi
sudo -u ${USERNAME} cp -v pjproject/config_site.h pjproject-${PJPROJECT_TARBALL}/pjlib/include/pj/config_site.h
pushd pjproject-${PJPROJECT_TARBALL}
sudo -u ${USERNAME} ./aconfigure CFLAGS="-g" --enable-shared --with-external-srtp --prefix=/usr
sudo -u ${USERNAME} make dep
sudo -u ${USERNAME} make
make install
popd
if [ ${CLEANUP} -eq 1 ]; then
echo " ==> Cleaning up PJPROJECT"
rm -fr pjproject-${PJPROJECT_TARBALL}
rm -f ${PJPROJECT_TARBALL}.tar.gz
fi
}
build_asterisk() {
if [ ! -d ${AST_TARBALL} ]; then
echo "*** Grabbing Asterisk: ${AST_TARBALL} ***"
sudo -u ${USERNAME} wget http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/${AST_TARBALL}.tar.gz
sudo -u ${USERNAME} tar -zxvf ${AST_TARBALL}.tar.gz
fi
pushd ${AST_TARBALL}
sudo -u ${USERNAME} ./configure --enable-dev-mode --with-pjproject
sudo -u ${USERNAME} make menuselect.makeopts
echo " ==> Enabling extra sounds"
sudo -u ${USERNAME} menuselect/menuselect --enable EXTRA-SOUNDS-EN-WAV menuselect.makeopts
echo " ==> Disabling app_voicemail; enabling external MWI"
sudo -u ${USERNAME} menuselect/menuselect --disable app_voicemail menuselect.makeopts
sudo -u ${USERNAME} menuselect/menuselect --enable res_mwi_external menuselect.makeopts
sudo -u ${USERNAME} menuselect/menuselect --enable res_stasis_mailbox menuselect.makeopts
sudo -u ${USERNAME} menuselect/menuselect --enable res_ari_mailboxes menuselect.makeopts
echo " ==> Enable debug build options (just in case!)"
sudo -u ${USERNAME} menuselect/menuselect --enable DONT_OPTIMIZE menuselect.makeopts
sudo -u ${USERNAME} menuselect/menuselect --enable BETTER_BACKTRACES menuselect.makeopts
quick_build_asterisk
popd
if [ ${CLEANUP} -eq 1 ]; then
echo " ==> Cleaning up Asterisk"
rm -fr ${AST_TARBALL}
rm -f ${AST_TARBALL}.tar.gz
fi
}
quick_build_asterisk() {
sudo -u ${USERNAME} make
if [ if /usr/sbin/asterisk ] ; then
make uninstall
fi
make install
chown -R ${USERNAME}:${GROUPNAME} /usr/lib/asterisk
chown -R ${USERNAME}:${GROUPNAME} /var/lib/asterisk
chown -R ${USERNAME}:${GROUPNAME} /var/spool/asterisk
chown -R ${USERNAME}:${GROUPNAME} /var/log/asterisk
chown -R ${USERNAME}:${GROUPNAME} /var/run/asterisk
chown -R ${USERNAME}:${GROUPNAME} /etc/asterisk
chown -R ${USERNAME}:${GROUPNAME} /usr/sbin/asterisk
}
wipe_asterisk_configs() {
echo "*** Removing old Asterisk configs ***"
rm -frv /etc/asterisk/*.conf
}
install_asterisk_configs() {
echo "*** Installing Asterisk configs ***"
sudo -u ${USERNAME} cp -v asterisk-${AST_VERSION}/*.conf /etc/asterisk/
}
# Option Flags
WIPE_ASTERISK_CONFIGS=0
INSTALL_ASTERISK_CONFIGS=1
INSTALL_ASTERISK=0
USERNAME=asterisk
GROUPNAME=asterisk
while [ "$#" -gt "0" ]; do
case ${1} in
-w|--wipe) WIPE_ASTERISK_CONFIGS=1;;
-i|--install) INSTALL_ASTERISK=1;;
-u|--user)
case "$2" in
"") USERNAME=asterisk; shift;;
*) USERNAME=$2; shift;;
esac ;;
-g|--group)
case "$2" in
"") GROUPNAME=asterisk; shift;;
*) GROUPNAME=$2; shift;;
esac ;;
esac
shift
done
echo "Executing as:"
echo " User: ${USERNAME}"
echo " Group: ${GROUPNAME}"
if [ ${INSTALL_ASTERISK} -eq 1 ]; then
install_prereqs
install_pjproject
build_asterisk
fi
if [ ${WIPE_ASTERISK_CONFIGS} -eq 1 ]; then
wipe_asterisk_configs
fi
install_asterisk_configs
echo "*** Done ***"
exit 0