Skip to content

Commit

Permalink
CentOS Installation Updates
Browse files Browse the repository at this point in the history
  - add stable support back to centos7
  - fix various dependency issues
  - bump kamailio/rtpengine versino on centos7
  - fix dnsmasq support
  • Loading branch information
devopsec committed May 31, 2024
1 parent 6921574 commit bcdcf17
Show file tree
Hide file tree
Showing 9 changed files with 333 additions and 191 deletions.
16 changes: 13 additions & 3 deletions dnsmasq/centos/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ function install() {
# mask the service before running package manager to avoid faulty startup errors
systemctl mask dnsmasq.service

dnf install -y dnsmasq
if (( ${DISTRO_VER} >= 8 )); then
dnf install -y dnsmasq
else
yum install -y dnsmasq
fi

if (( $? != 0 )); then
printerr 'Failed installing required packages'
Expand All @@ -36,7 +40,9 @@ function install() {

# make dnsmasq the DNS provider
# centos uses a static resolv.conf by default, which dnsmasq will use for its upstream DNS servers
cp -df /etc/resolv.conf /etc/dnsmasq_resolv.conf
[[ ! -e /etc/dnsmasq_resolv.conf ]] && {
cp -df /etc/resolv.conf /etc/dnsmasq_resolv.conf
}
rm -f /etc/resolv.conf
cp -f ${DSIP_PROJECT_DIR}/dnsmasq/configs/resolv.conf /etc/resolv.conf

Expand All @@ -60,7 +66,11 @@ function uninstall {
systemctl stop dnsmasq

# uninstall packages
dnf remove -y dnsmasq
if (( ${DISTRO_VER} >= 8 )); then
dnf remove -y dnsmasq
else
yum remove -y dnsmasq
fi

# remove our NetworkManager configurations
rm -f /etc/NetworkManager/conf.d/99-dsiprouter.conf
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Debian 10 (buster) STABLE
Debian 9 (stretch) DEPRECATED
CentOS 9 (stream) STABLE
CentOS 8 (stream) STABLE
CentOS 7 DEPRECATED
CentOS 7 STABLE
RedHat Linux 8 ALPHA
Alma Linux 8 ALPHA
Rocky Linux 8 ALPHA
Expand Down
7 changes: 3 additions & 4 deletions dsiprouter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# - Debian 9 (stretch) - DEPRECATED
# - CentOS 9 (stream) - STABLE
# - CentOS 8 (stream) - STABLE
# - CentOS 7 - DEPRECATED
# - CentOS 7 - STABLE
# - RedHat Linux 8 - ALPHA
# - Alma Linux 8 - ALPHA
# - Rocky Linux 8 - ALPHA
Expand Down Expand Up @@ -437,9 +437,8 @@ function validateOSInfo() {
RTPENGINE_VER=${RTPENGINE_VER:-"mr11.5.1.11"}
;;
7)
printwarn "Your Operating System Version is DEPRECATED. To ask for support open an issue https://github.com/dOpensource/dsiprouter/"
KAM_VERSION=${KAM_VERSION:-55}
RTPENGINE_VER=${RTPENGINE_VER:-"mr9.5.5.1"}
KAM_VERSION=${KAM_VERSION:-57}
RTPENGINE_VER=${RTPENGINE_VER:-"mr11.5.1.11"}
;;
*)
printerr "Your Operating System Version is not supported yet. Please open an issue at https://github.com/dOpensource/dsiprouter/"
Expand Down
133 changes: 51 additions & 82 deletions dsiprouter/centos/7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,63 @@ if [[ "$DSIP_LIB_IMPORTED" != "1" ]]; then
fi

function install {
local NPROC

# Get the default version of python enabled
VER=`python -V 2>&1`
VER=`echo $VER | cut -d " " -f 2`
# Uninstall 3.6 and install a specific version of 3.6 if already installed
if [[ "$VER" =~ 3.6 ]]; then
yum remove -y rs-epel-release
yum remove -y python36 python36-libs python36-devel python36-pip
yum install -y https://centos7.iuscommunity.org/ius-release.rpm
yum install -y python36u python36u-libs python36u-devel python36u-pip python36u-virtualenv
elif [[ "$VER" =~ 3 ]]; then
yum remove -y rs-epel-release
yum remove -y python3* python3*-libs python3*-devel python3*-pip
yum install -y https://centos7.iuscommunity.org/ius-release.rpm
yum install -y python36u python36u-libs python36u-devel python36u-pip python36u-virtualenv
else
yum install -y https://centos7.iuscommunity.org/ius-release.rpm
yum install -y python36u python36u-libs python36u-devel python36u-pip python36u-virtualenv
# Install dependencies for dSIPRouter
yum install -y yum-utils &&
yum groupinstall -y "Development Tools" &&
yum install -y firewalld logrotate rsyslog perl libev-devel util-linux postgresql-devel \
bzip2-devel libffi-devel zlib-devel curl openldap-devel

if (( $? != 0 )); then
printerr 'Failed installing required packages'
return 1
fi

# Install dependencies for dSIPRouter
yum install -y yum-utils
yum --setopt=group_package_types=mandatory,default,optional groupinstall -y "Development Tools"
yum install -y firewalld nginx sudo
yum install -y python36 python36-libs python36-devel python36-pip MySQL-python
yum install -y logrotate rsyslog perl libev-devel util-linux postgresql-devel mariadb-devel
NPROC=$(nproc)

# python 3.8 or higher is required
# if not installed already, install it now
if [[ "$(python3 -V 2>/dev/null | cut -d ' ' -f 2)" != "3.9.18" ]]; then
# installation / compilation never completed, start it now
if [[ ! -d "${SRC_DIR}/Python-3.9.18" ]]; then
(
cd ${SRC_DIR} &&
curl -s -o Python-3.9.18.tgz https://www.python.org/ftp/python/3.9.18/Python-3.9.18.tgz &&
tar -xf Python-3.9.18.tgz &&
rm -f Python-3.9.18.tgz
)
fi
(
cd ${SRC_DIR} &&
cd Python-3.9.18/ &&
./configure --enable-optimizations CFLAGS=-I${SRC_DIR}/openssl/include LDFLAGS=-L${SRC_DIR}/openssl &&
make -j $NPROC &&
make -j $NPROC install
) || {
printerr 'Failed to compile and install required python version'
return 1
}
python3 -m pip install -U pip setuptools || {
printerr 'Failed to update pip and setuptools'
return 1
}
fi

# create dsiprouter and nginx user and group
# create dsiprouter user and group
# sometimes locks aren't properly removed (this seems to happen often on VM's)
rm -f /etc/passwd.lock /etc/shadow.lock /etc/group.lock /etc/gshadow.lock
rm -f /etc/passwd.lock /etc/shadow.lock /etc/group.lock /etc/gshadow.lock &>/dev/null
userdel dsiprouter &>/dev/null; groupdel dsiprouter &>/dev/null
useradd --system --user-group --shell /bin/false --comment "dSIPRouter SIP Provider Platform" dsiprouter
useradd --system --user-group --shell /bin/false --comment "nginx HTTP Service Provider" nginx

# make sure the nginx user has access to dsiprouter directories
usermod -a -G dsiprouter nginx
# make dsiprouter user has access to kamailio files
usermod -a -G kamailio dsiprouter

# setup runtime directorys for dsiprouter and nginx
mkdir -p ${DSIP_RUN_DIR} /run/nginx
# setup runtime directorys for dsiprouter
mkdir -p ${DSIP_RUN_DIR}
chown -R dsiprouter:dsiprouter ${DSIP_RUN_DIR}
chown -R nginx:nginx /run/nginx

# give dsiprouter permissions in SELINUX
semanage port -a -t http_port_t -p tcp ${DSIP_PORT} ||
Expand All @@ -60,14 +75,6 @@ function install {
systemctl enable firewalld
systemctl start firewalld

if (( $? != 0 )); then
# fix for bug: https://bugzilla.redhat.com/show_bug.cgi?id=1575845
systemctl restart dbus
systemctl restart firewalld
# fix for ensuing bug: https://bugzilla.redhat.com/show_bug.cgi?id=1372925
systemctl restart systemd-logind
fi

# Setup Firewall for DSIP_PORT
firewall-cmd --zone=public --add-port=${DSIP_PORT}/tcp --permanent
firewall-cmd --reload
Expand All @@ -79,31 +86,12 @@ function install {
return 1
fi

# Configure nginx
# determine available TLS protocols (try using highest available)
OPENSSL_VER=$(openssl version 2>/dev/null | awk '{print $2}' | perl -pe 's%([0-9])\.([0-9]).([0-9]).*%\1\2\3%')
if (( ${OPENSSL_VER} < 101 )); then
TLS_PROTOCOLS="TLSv1"
elif (( ${OPENSSL_VER} < 111 )); then
TLS_PROTOCOLS="TLSv1.1 TLSv1.2"
else
TLS_PROTOCOLS="TLSv1.2 TLSv1.3"
fi
mkdir -p /etc/nginx/sites-enabled /etc/nginx/sites-available /etc/nginx/nginx.conf.d/
# remove the defaults
rm -f /etc/nginx/sites-enabled/* /etc/nginx/sites-available/* /etc/nginx/nginx.conf.d/*
# setup our own nginx configs
perl -e "\$tls_protocols='${TLS_PROTOCOLS}';" \
-pe 's%TLS_PROTOCOLS%${tls_protocols}%g;' \
${DSIP_PROJECT_DIR}/nginx/configs/nginx.conf >/etc/nginx/nginx.conf
# setup dsiprouter nginx configs
perl -e "\$dsip_port='${DSIP_PORT}'; \$dsip_unix_sock='${DSIP_UNIX_SOCK}'; \$dsip_ssl_cert='${DSIP_SSL_CERT}'; \$dsip_ssl_key='${DSIP_SSL_KEY}';" \
-pe 's%DSIP_UNIX_SOCK%${dsip_unix_sock}%g; s%DSIP_PORT%${dsip_port}%g; s%DSIP_SSL_CERT%${dsip_ssl_cert}%g; s%DSIP_SSL_KEY%${dsip_ssl_key}%g;' \
${DSIP_PROJECT_DIR}/nginx/configs/dsiprouter.conf >/etc/nginx/sites-available/dsiprouter.conf
ln -sf /etc/nginx/sites-available/dsiprouter.conf /etc/nginx/sites-enabled/dsiprouter.conf

systemctl enable nginx
systemctl restart nginx

# Configure rsyslog defaults
if ! grep -q 'dSIPRouter rsyslog.conf' /etc/rsyslog.conf 2>/dev/null; then
cp -f ${DSIP_PROJECT_DIR}/resources/syslog/rsyslog.conf /etc/rsyslog.conf
Expand Down Expand Up @@ -135,27 +123,7 @@ function install {


function uninstall {
# Uninstall dependencies for dSIPRouter
PIP_CMD="pip"

cat ${DSIP_PROJECT_DIR}/gui/requirements.txt | xargs -n 1 $PYTHON_CMD -m ${PIP_CMD} uninstall --yes
if [ $? -eq 1 ]; then
printerr "dSIPRouter uninstall failed or the libraries are already uninstalled"
exit 1
else
printdbg "DSIPRouter uninstall was successful"
exit 0
fi

yum remove -y python36u\*
yum remove -y ius-release
yum remove -y nginx
yum groupremove -y "Development Tools"

# Remove the repos
rm -f /etc/yum.repos.d/ius*
rm -f /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY
yum clean all
rm -rf ${PYTHON_VENV}

# Remove Firewall for DSIP_PORT
firewall-cmd --zone=public --remove-port=${DSIP_PORT}/tcp --permanent
Expand All @@ -168,6 +136,7 @@ function uninstall {
rm -f /etc/logrotate.d/dsiprouter

# Remove dSIProuter as a service
systemctl stop dsiprouter.service
systemctl disable dsiprouter.service
rm -f /lib/systemd/system/dsiprouter.service
systemctl daemon-reload
Expand All @@ -176,14 +145,14 @@ function uninstall {
}

case "$1" in
install)
install && exit 0 || exit 1
;;
uninstall)
uninstall && exit 0 || exit 1
;;
install)
install && exit 0 || exit 1
;;
*)
printerr "Usage: $0 [install | uninstall]"
printerr "usage $0 [install | uninstall]"
exit 1
;;
esac
2 changes: 1 addition & 1 deletion dsiprouter/centos/8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function install {
dnf install -y yum-utils &&
dnf groupinstall -y "Development Tools" &&
dnf install -y firewalld logrotate rsyslog perl libev-devel util-linux postgresql-devel \
bzip2-devel libffi-devel zlib-devel curl
bzip2-devel libffi-devel zlib-devel curl openldap-devel

if (( $? != 0 )); then
printerr 'Failed installing required packages'
Expand Down
2 changes: 1 addition & 1 deletion dsiprouter/centos/9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fi
function install {
# Install dependencies for dSIPRouter
dnf install -y firewalld logrotate rsyslog perl curl python3 python3-devel libpq-devel \
libev-devel
libev-devel openldap-devel

if (( $? != 0 )); then
printerr 'Failed installing required packages'
Expand Down
Loading

0 comments on commit bcdcf17

Please sign in to comment.