diff --git a/el/rtpengine-recording.init b/el/rtpengine-recording.init deleted file mode 100644 index bd0539c4e..000000000 --- a/el/rtpengine-recording.init +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# -# rtpengine-recording Startup script for NGCP rtpengine-recording -# -# chkconfig: 345 84 16 -# description: NGCP rtpengine-recording -# -# processname: rtpengine-recording -# config: /etc/sysconfig/rtpengine-recording -# pidfile: /run/rtpengine-recording.pid -# -### BEGIN INIT INFO -# Provides: rtpengine -# Required-Start: $local_fs $network -# Short-Description: NGCP rtpengine-recording -# Description: NGCP rtpengine-recording -### END INIT INFO - -# Source function library. -# shellcheck disable=SC1091 -. /etc/rc.d/init.d/functions - -if [ -f /etc/sysconfig/rtpengine-recording ] -then - # shellcheck source=./rtpengine-recording.sysconfig - . /etc/sysconfig/rtpengine-recording -else - echo "Error: /etc/sysconfig/rtpengine-recording not present" >&2 - exit 6 -fi - -prog=rtpengine-recording -runfile=/usr/bin/${prog} -pidfile=${PIDFILE-/run/rtpengine-recording.pid} -lockfile=${LOCKFILE-/var/lock/subsys/rtpengine-recording} - -RETVAL=0 -OPTS="" - -[ -z "$CONFIG_FILE" ] || OPTS+=" --config-file=$CONFIG_FILE" -[ -z "$PIDFILE" ] || OPTS+=" --pidfile=$PIDFILE" - -start() { - echo -n $"Starting $prog: " - if [[ -n "$RE_USER" ]] - then - # shellcheck disable=SC2086 - daemon --user "$RE_USER" --pidfile="${pidfile}" "$runfile" $OPTS - else - # shellcheck disable=SC2086 - daemon --pidfile="${pidfile}" "$runfile" $OPTS - fi - RETVAL=$? - echo - [ $RETVAL = 0 ] && touch "${lockfile}" - return $RETVAL -} - -stop() { - echo -n $"Stopping $prog: " - killproc -p "${pidfile}" "$runfile" - RETVAL=$? - [ $RETVAL = 0 ] && rm -f "${lockfile}" "${pidfile}" -} - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - status) - status -p "${pidfile}" "$runfile" - RETVAL=$? - ;; - restart) - stop - start - ;; - condrestart|try-restart) - if status -p "${pidfile}" "$runfile" >&/dev/null; then - stop - start - fi - ;; - *) - echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|status}" - RETVAL=2 -esac - -exit $RETVAL diff --git a/el/rtpengine.init b/el/rtpengine.init deleted file mode 100644 index 4033f7a9d..000000000 --- a/el/rtpengine.init +++ /dev/null @@ -1,178 +0,0 @@ -#!/bin/bash -# -# rtpengine Startup script for NGCP rtpengine -# -# chkconfig: 345 84 16 -# description: NGCP rtpengine -# -# processname: rtpengine -# config: /etc/sysconfig/rtpengine -# pidfile: /run/rtpengine.pid -# -### BEGIN INIT INFO -# Provides: rtpengine -# Required-Start: $local_fs $network -# Short-Description: NGCP rtpengine -# Description: NGCP rtpengine -### END INIT INFO - -# Source function library. -# shellcheck disable=SC1091 -. /etc/rc.d/init.d/functions - -# defaults - -if [ -f /etc/sysconfig/rtpengine ] -then - # shellcheck source=./rtpengine.sysconfig - . /etc/sysconfig/rtpengine -else - echo "Error: /etc/sysconfig/rtpengine not present" >&2 - exit 6 -fi - -rtpengine=/usr/bin/rtpengine -prog=rtpengine -pidfile=${PIDFILE-/run/rtpengine.pid} -lockfile=${LOCKFILE-/var/lock/subsys/rtpengine} -cachefile=/var/lib/ngcp-rtpengine/rtpengine.cfg -TABLE=$(/usr/sbin/rtpengine-get-table --config-file="${CONFIG_FILE-/etc/rtpengine/rtpengine.conf}") -PIDFILE=${pidfile} -RETVAL=0 -OPTS="" - -build_opts() { - # kernel table - MODULE=0 - # the variable from the config is the source of truth - if [[ -n "$TABLE" ]];then - if [[ $TABLE -ge 0 ]];then - MODULE=1 - fi - fi - - # options - [[ "$FORK" == "no" ]] && OPTS+=" --foreground" - [ -z "$CONFIG_FILE" ] || OPTS+=" --config-file=$CONFIG_FILE" - [ -z "$CONFIG_SECTION" ] || OPTS+=" --config-section=$CONFIG_SECTION" - [ -z "$PIDFILE" ] || OPTS+=" --pidfile=$PIDFILE" -} - -start() { - build_opts - if [[ $MODULE == 1 ]];then - echo "Loading module for in-kernel packet forwarding" - rmmod nft_rtpengine 2> /dev/null - if [[ -n "$SET_USER" ]];then - if [[ -n "$SET_GROUP" ]];then - proc_gid="$(grep "^$SET_GROUP:" /etc/group | cut -f3 -d:)" - else - proc_gid="$(id "$SET_USER" -g)" - fi - modprobe nft_rtpengine proc_uid="$(id "$SET_USER" -u)" proc_gid="$proc_gid" - else - modprobe nft_rtpengine - fi - if firewall-cmd --state 2>/dev/null ; then - # Using firewalld - # Need to check if the INPUT_prefilter chain is present (permanently) - if ! firewall-cmd --permanent --direct --query-chain ipv4 filter INPUT_prefilter > /dev/null; then - firewall-cmd --permanent --direct --add-chain ipv4 filter INPUT_prefilter - firewall-cmd --permanent --direct --passthrough ipv4 -t filter -I INPUT -j INPUT_prefilter - firewall-cmd --reload - fi - - firewall-cmd --direct --add-chain ipv4 filter rtpengine - firewall-cmd --direct --add-rule ipv4 filter INPUT_prefilter 0 -j rtpengine - firewall-cmd --direct --add-rule ipv4 filter rtpengine 0 -p udp -j RTPENGINE --id "$TABLE" - firewall-cmd --direct --add-rule ipv6 filter rtpengine 0 -p udp -j RTPENGINE --id "$TABLE" - firewall-cmd --reload - else - for fw in iptables ip6tables;do - # We insert the rtpengine rule at the top of the input chain - if ! $fw -t filter -C INPUT -j rtpengine 2> /dev/null; then - $fw -N rtpengine - $fw -t filter -I INPUT -j rtpengine - fi - if ! $fw -I rtpengine -p udp -j RTPENGINE --id "$TABLE" 2> /dev/null; then - $fw -I rtpengine -p udp -j RTPENGINE --id "$TABLE" - fi - done - fi - - cat < "$cachefile" -CUR_TABLE=$TABLE -EOF - fi - echo -n $"Starting $prog: " - if [[ -n "$SET_USER" ]];then - # shellcheck disable=SC2086 - daemon --user "$SET_USER" --pidfile="${pidfile}" "$rtpengine" $OPTS - else - # shellcheck disable=SC2086 - daemon --pidfile="${pidfile}" "$rtpengine" $OPTS - fi - RETVAL=$? - echo - [ $RETVAL = 0 ] && touch "${lockfile}" - return $RETVAL -} - -stop() { - echo -n $"Stopping $prog: " - killproc -p "${pidfile}" "$rtpengine" - RETVAL=$? - echo - if [ -f "$cachefile" ];then - # shellcheck disable=SC1090 - . "$cachefile" - echo "Unloading module for in-kernel packet forwarding" - echo "del $TABLE" > /proc/rtpengine/control - if firewall-cmd --state 2>/dev/null; then - firewall-cmd --direct --remove-rules ipv4 filter rtpengine - firewall-cmd --direct --remove-rules ipv6 filter rtpengine - firewall-cmd --direct --remove-rule ipv4 filter INPUT_prefilter 0 -j rtpengine - firewall-cmd --direct --remove-chain ipv4 filter rtpengine - firewall-cmd --reload - else - for fw in iptables ip6tables;do - $fw -D rtpengine -p udp -j RTPENGINE --id "$CUR_TABLE" - $fw -t filter -D INPUT -j rtpengine - $fw -X rtpengine - done - fi - rmmod nft_rtpengine - rm -f "$cachefile" - fi - - [ $RETVAL = 0 ] && rm -f "${lockfile}" "${pidfile}" -} - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - status) - status -p "${pidfile}" "$rtpengine" - RETVAL=$? - ;; - restart) - stop - start - ;; - condrestart|try-restart) - if status -p "${pidfile}" "$rtpengine" >&/dev/null; then - stop - start - fi - ;; - *) - echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|status}" - RETVAL=2 -esac - -exit $RETVAL diff --git a/el/rtpengine.spec b/el/rtpengine.spec index 66f0aeef3..b4ed86747 100644 --- a/el/rtpengine.spec +++ b/el/rtpengine.spec @@ -9,7 +9,6 @@ Source0: https://github.com/sipwise/rtpengine/archive/refs/tags/mr%{version}.tar Conflicts: %{name}-kernel < %{version}-%{release} %global with_transcoding 1 -%{?_unitdir:%define has_systemd_dirs 1} %if 0%{?openEuler} >= 1 %define redhat_rpm_config openEuler-rpm-config @@ -37,9 +36,7 @@ BuildRequires: gcc make pkgconfig %{redhat_rpm_config} BuildRequires: glib2-devel libcurl-devel openssl-devel BuildRequires: pcre2-devel BuildRequires: zlib-devel hiredis-devel -%if 0%{?has_systemd_dirs} BuildRequires: systemd-devel -%endif BuildRequires: libpcap-devel libevent-devel json-glib-devel BuildRequires: mosquitto-devel BuildRequires: gperf perl-IPC-Cmd @@ -171,21 +168,11 @@ RTPENGINE_VERSION="\"%{version}-%{release}\"" make DESTDIR=%{buildroot} with_tra %endif ## Install the init.d script and configuration file -%if 0%{?has_systemd_dirs} install -D -p -m644 el/%{binname}.service \ %{buildroot}%{_unitdir}/%{binname}.service -%else -install -D -p -m755 el/%{binname}.init \ - %{buildroot}%{_initrddir}/%{name} -%endif %if 0%{?with_transcoding} > 0 -%if 0%{?has_systemd_dirs} install -D -p -m644 el/%{binname}-recording.service \ %{buildroot}%{_unitdir}/%{binname}-recording.service -%else -install -D -p -m755 el/%{binname}-recording.init \ - %{buildroot}%{_initrddir}/%{name}-recording -%endif %endif install -D -p -m644 el/%{binname}.sysconfig \ %{buildroot}%{_sysconfdir}/sysconfig/%{binname} @@ -235,11 +222,7 @@ getent passwd %{name} >/dev/null || /usr/sbin/useradd -r -g %{name} \ %post if [ $1 -eq 1 ]; then -%if 0%{?has_systemd_dirs} systemctl daemon-reload -%else - /sbin/chkconfig --add %{name} || : -%endif fi @@ -276,14 +259,8 @@ true %preun if [ $1 = 0 ] ; then -%if 0%{?has_systemd_dirs} systemctl stop %{binname}.service systemctl disable %{binname}.service - -%else - /sbin/service %{name} stop >/dev/null 2>&1 - /sbin/chkconfig --del %{name} -%endif fi %preun dkms @@ -299,11 +276,7 @@ true %{_bindir}/%{binname}-ctl # CLI table helper # init.d script and configuration file -%if 0%{?has_systemd_dirs} %{_unitdir}/%{binname}.service -%else -%{_initrddir}/%{name} -%endif %config(noreplace) %{_sysconfdir}/sysconfig/%{binname} # default config %config(noreplace) %{_sysconfdir}/%{binname}/%{binname}.conf @@ -335,11 +308,7 @@ true # Recording daemon %{_bindir}/%{binname}-recording # Init script -%if 0%{?has_systemd_dirs} %{_unitdir}/%{binname}-recording.service -%else -%{_initrddir}/%{name}-recording -%endif # Sysconfig %config(noreplace) %{_sysconfdir}/sysconfig/%{binname}-recording # Default config