1111function install() {
1212 local KAM_SOURCES_LIST=" /etc/apt/sources.list.d/kamailio.list"
1313 local KAM_PREFS_CONF=" /etc/apt/preferences.d/kamailio.pref"
14+ local NPROC=$( nproc)
1415
1516 # nf_tables is the default fw on ubuntu but it has too many bugs at this time
1617 # instead we will use legacy iptables until these issues are ironed out
@@ -21,6 +22,30 @@ function install() {
2122 apt-get install -y curl wget sed gawk vim perl uuid-dev libssl-dev logrotate rsyslog \
2223 libcurl4-openssl-dev libjansson-dev cmake firewalld python3 python3-venv
2324
25+ if (( $? != 0 )) ; then
26+ printerr ' Failed installing required packages'
27+ exit 1
28+ fi
29+
30+ # # compile and install openssl v1.1.1 (workaround for amazon linux repo conflicts)
31+ # # we must overwrite system packages (openssl/openssl-devel) otherwise python's openssl package is not supported
32+ if [[ " $( openssl version 2> /dev/null | awk ' {print $2}' ) " != " 1.1.1w" ]]; then
33+ if [[ ! -d ${SRC_DIR} /openssl ]]; then
34+ ( cd ${SRC_DIR} &&
35+ curl -sL https://www.openssl.org/source/openssl-1.1.1w.tar.gz 2> /dev/null |
36+ tar -xzf - --transform ' s%openssl-1.1.1w%openssl%' ; )
37+ fi
38+ (
39+ cd ${SRC_DIR} /openssl &&
40+ ./Configure --prefix=/usr linux-$( uname -m) &&
41+ make -j $NPROC &&
42+ make -j $NPROC install
43+ ) || {
44+ printerr ' Failed to compile openssl'
45+ return 1
46+ }
47+ fi
48+
2449 # we need a newer version of certbot than the distro repos offer
2550 apt-get remove -y * certbot*
2651 python3 -m venv /opt/certbot/
@@ -37,26 +62,25 @@ function install() {
3762 chown -R kamailio:kamailio /var/run/kamailio
3863
3964 # add repo sources to apt
40- # TODO: note that kamailio has only published a DEB for bookworm (debian upstream), not jammmy (ubuntu downstream)
4165 mkdir -p /etc/apt/sources.list.d
4266 (cat << EOF
4367# kamailio repo's
44- deb http ://deb.kamailio.org/kamailio${KAM_VERSION} bookworm main
45- #deb-src http ://deb.kamailio.org/kamailio${KAM_VERSION} bookworm main
68+ deb https ://deb-archive .kamailio.org/repos/ kamailio- ${KAM_VERSION} jammy main
69+ #deb-src https ://deb-archive .kamailio.org/repos/ kamailio- ${KAM_VERSION} jammy main
4670EOF
4771 ) > ${KAM_SOURCES_LIST}
4872
4973 # give higher precedence to packages from kamailio repo
5074 mkdir -p /etc/apt/preferences.d
5175 (cat << 'EOF '
5276Package: *
53- Pin: origin deb.kamailio.org
77+ Pin: origin deb-archive .kamailio.org
5478Pin-Priority: 1000
5579EOF
5680 ) > ${KAM_PREFS_CONF}
5781
5882 # Add Key for Kamailio Repo
59- wget -O- http ://deb.kamailio.org/kamailiodebkey.gpg | apt-key add -
83+ wget -O- https ://deb-archive .kamailio.org/kamailiodebkey.gpg | apt-key add -
6084
6185 # Update repo sources cache
6286 apt-get update -y
6690 kamailio-websocket-modules kamailio-presence-modules kamailio-json-modules kamailio-sctp-modules
6791
6892 # get info about the kamailio install for later use in script
69- KAM_VERSION_FULL=$( kamailio -v 2> /dev/null | grep ' ^version:' | awk ' {print $3}' )
7093 KAM_MODULES_DIR=$( find /usr/lib{32,64,}/{i386* /* ,i386* /kamailio/* ,x86_64* /* ,x86_64* /kamailio/* ,* } -name drouting.so -printf ' %h' -quit 2> /dev/null)
7194
7295 # create kamailio defaults config
@@ -96,28 +119,14 @@ DBRWPW="${KAM_DB_PASS}"
96119DBROOTUSER="${ROOT_DB_USER} "
97120${ROOTPW_SETTING}
98121CHARSET=utf8
122+ EXTRA_MODULES="imc cpl siptrace domainpolicy carrierroute drouting userblocklist htable purple uac pipelimit mtree sca mohqueue rtpproxy rtpengine secfilter"
99123INSTALL_EXTRA_TABLES=yes
100124INSTALL_PRESENCE_TABLES=yes
101125INSTALL_DBUID_TABLES=yes
102126#STORE_PLAINTEXT_PW=0
103127EOF
104128 ) > ${SYSTEM_KAMAILIO_CONFIG_DIR} /kamctlrc
105129
106- # fix bug in kamilio v5.3.4 installer
107- if [[ " $KAM_VERSION_FULL " == " 5.3.4" ]]; then
108- (cat << 'EOF '
109- CREATE TABLE `secfilter` (
110- `id` INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
111- `action` SMALLINT DEFAULT 0 NOT NULL,
112- `type` SMALLINT DEFAULT 0 NOT NULL,
113- `data` VARCHAR(64) DEFAULT "" NOT NULL
114- );
115- CREATE INDEX secfilter_idx ON secfilter (`action`, `type`, `data`);
116- INSERT INTO version (table_name, table_version) values ("secfilter","1");
117- EOF
118- ) > /usr/share/kamailio/mysql/secfilter-create.sql
119- fi
120-
121130 # Execute 'kamdbctl create' to create the Kamailio database schema
122131 kamdbctl create
123132
166175 # setup STIR/SHAKEN module for kamailio
167176 # # compile and install libjwt (version in repos is too old)
168177 if [[ ! -d ${SRC_DIR} /libjwt ]]; then
169- git clone --depth 1 -c advice.detachedHead=false https://github.com/benmcollins /libjwt.git ${SRC_DIR} /libjwt
178+ git clone --depth 1 -c advice.detachedHead=false -b v2.1.1 https://github.com/devopsec /libjwt.git ${SRC_DIR} /libjwt
170179 fi
180+
171181 (
172182 cd ${SRC_DIR} /libjwt &&
173183 autoreconf -i &&
201211 # TODO: commit updates to upstream to fix EVP_PKEY_cmp being deprecated
202212 cd ${SRC_DIR} /libstirshaken &&
203213 ./bootstrap.sh &&
204- ./configure --prefix=/usr &&
205- make -j $NPROC CFLAGS= ' -Wno-deprecated-declarations ' &&
214+ ./configure --prefix=/usr CFLAGS= ' -Wno-deprecated-declarations ' LDFLAGS= ' -L/usr/lib ' &&
215+ make -j $NPROC &&
206216 make -j $NPROC install &&
207217 ldconfig
208218 ) || {
@@ -213,12 +223,12 @@ EOF
213223 # # compile and install STIR/SHAKEN module
214224 # # reuse repo if it exists and matches version we want to install
215225 if [[ -d ${SRC_DIR} /kamailio ]]; then
216- if [[ " $( getGitTagFromShallowRepo ${SRC_DIR} /kamailio) " != " ${KAM_VERSION_FULL } " ]]; then
226+ if [[ " $( getGitTagFromShallowRepo ${SRC_DIR} /kamailio) " != " ${KAM_VERSION } " ]]; then
217227 rm -rf ${SRC_DIR} /kamailio
218- git clone --depth 1 -c advice.detachedHead=false -b ${KAM_VERSION_FULL } https://github.com/kamailio/kamailio.git ${SRC_DIR} /kamailio
228+ git clone --depth 1 -c advice.detachedHead=false -b ${KAM_VERSION } https://github.com/kamailio/kamailio.git ${SRC_DIR} /kamailio
219229 fi
220230 else
221- git clone --depth 1 -c advice.detachedHead=false -b ${KAM_VERSION_FULL } https://github.com/kamailio/kamailio.git ${SRC_DIR} /kamailio
231+ git clone --depth 1 -c advice.detachedHead=false -b ${KAM_VERSION } https://github.com/kamailio/kamailio.git ${SRC_DIR} /kamailio
222232 fi
223233 (
224234 cd ${SRC_DIR} /kamailio/src/modules/stirshaken &&
0 commit comments