%global src_name turnserver %global src_ver 4.5.1.2 %global src_license BSD %global src_uri http://coturn.github.io %global src_download http://turnserver.open-sys.org/downloads/v%{src_ver}/%{src_name}-%{src_ver}.tar.gz %global pkg_name coturn %global pkg_ver %{src_ver} %global pkg_rel 1 %global pkg_summary Free open source implementation of TURN/STUN & ICE Server %define services stund turnd turnd-spreed %if 0%{?fedora} || 0%{?rhel} == 7 %define with_mongo 1 %else %define with_mongo 0 %endif Name: %{pkg_name} Version: %{pkg_ver} Release: %{pkg_rel}%{dist} Summary: %{pkg_summary} License: %{src_license} URL: %{src_uri} Source0: %{src_download} Source1: coturn-configs.tar.xz BuildRequires: gcc BuildRequires: pkgconfig(openssl) >= 1.0.2 BuildRequires: pkgconfig(libevent) >= 2.0.0 %if 0%{?with_mongo} BuildRequires: libbson-devel >= 1.0 BuildRequires: mongo-c-driver-devel >= 1.0 %endif BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(hiredis) BuildRequires: mariadb-devel BuildRequires: postgresql-devel BuildRequires: systemd Requires(pre): shadow-utils %if 0%{?fedora} || 0%{?rhel} >= 8 Recommends: perl-interpreter Recommends: perl(DBI) Recommends: perl(HTTP::Request::Common) Recommends: perl(strict) Recommends: perl(warnings) Recommends: telnet %else Requires: perl-interpreter Requires: perl(DBI) Requires: perl(HTTP::Request::Common) Requires: perl(strict) Requires: perl(warnings) Requires: telnet %endif Provides: turnserver = %{version} %{?systemd_requires} %description The TURN Server is a VoIP media traffic NAT traversal server and gateway. It can be used as a general-purpose network traffic TURN server/gateway, too. %package examples Summary: Examples of Coturn services implementations %description examples This package contains examples of inumerous ways to configure Coturn for a STUN/TURN server. %package utils Summary: TURN client utilities %description utils This package contains the TURN client utils. %package client-libs Summary: TURN client static library %description client-libs This package contains the TURN client static library. %package client-devel Summary: Coturn client development headers %description client-devel This package contains the TURN client development headers. %prep %setup -q -a 1 -n %{src_name}-%{src_ver} # NOTE: Use Fedora Default Ciphers %if 0%{?fedora} || 0%{?rhel} >= 8 sed -i \ -e 's|#define DEFAULT_CIPHER_LIST "DEFAULT"|#define DEFAULT_CIPHER_LIST "PROFILE=SYSTEM"|g' \ -e 's|/* "ALL:eNULL:aNULL:NULL" */|/* Fedora Defaults */|g' \ src/apps/relay/mainrelay.h sed -i \ -e 's|*csuite = "ALL"; //"AES256-SHA" "DH"|*csuite = "PROFILE=SYSTEM"; // Fedora Defaults|g' \ src/apps/uclient/mainuclient.c %endif %build %configure \ --confdir=%{_sysconfdir}/%{name} \ --docsdir=%{_docdir}/%{name} \ --examplesdir=%{_docdir}/%{name} \ --schemadir=%{_datadir}/%{name} \ --manprefix=%{_datadir} \ --turndbdir=%{_localstatedir}/lib/%{name} \ --disable-rpath %make_build %install %make_install mkdir -p %{buildroot}{%{_sysconfdir}/pki/%{name}/{public,private},%{_rundir}/%{name},%{_localstatedir}/{lib,log}/%{name}} # Adjust tmpfile.d file sed -i 's;turnserver;coturn;g' rpm/%{src_name}-tmpfiles.conf # Remove unpacked files rm %{buildroot}%{_sysconfdir}/%{name}/%{src_name}.conf.default rm %{buildroot}%{_docdir}/%{name}/etc/coturn.service find %{buildroot}%{_docdir}/%{name}/ -name ._\* -delete find %{buildroot}%{_docdir}/%{name}/ -type d -empty -delete # NOTE: Removing sqlite db, certs and keys rm %{buildroot}%{_localstatedir}/lib/%{name}/turndb rm %{buildroot}%{_docdir}/%{name}/etc/{cacert,turn_{client,server}_{cert,pkey}}.pem # Rename binaries %{__mv} %{buildroot}%{_bindir}/turnserver %{buildroot}%{_bindir}/%{name} ln -snf %{_bindir}/%{name} %{buildroot}%{_bindir}/turnadmin # Install services instances for s in %{services}; do %{__install} -Dp -m0644 rpm/$s.conf %{buildroot}%{_sysconfdir}/%{name}/conf.d/$s.conf done # Install firewalld rules %{__install} -dp -m0755 %{buildroot}/lib/firewalld/services/ %{__install} -Dp -m0644 rpm/*.xml %{buildroot}/lib/firewalld/services/ # Install systemd unit %{__install} -Dp -m0644 rpm/coturn@.service %{buildroot}%{_unitdir}/%{name}@.service # Install tmpfile.d config %{__install} -Dp -m0644 rpm/%{src_name}-tmpfiles.conf %{buildroot}%{_tmpfilesdir}/%{name}.conf # Install sysconfig file %{__install} -Dp -m0644 rpm/%{name}.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/%{name} # Create logs dir %{__install} -d -m0750 %{buildroot}%{_localstatedir}/log/%{name} # Install logrotate config file %{__install} -Dp -m0644 rpm/%{name}.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/%{name} %check make test %clean %{__rm} -rf %{buildroot} %pre getent group %{name} >/dev/null || groupadd -r %{name} getent passwd %{name} >/dev/null || \ useradd -r -g %{name} -d %{_datadir}/%{name} -s /sbin/nologin \ -c "Coturn STUN/TURN server daemon" %{name} exit 0 %preun if [ $1 = 0 ]; then for i in $(ls %{_sysconfdir}/%{name}/conf.d/*; do /bin/systemctl stop coturn@$i.service /bin/systemctl disable coturn@%i.service 2> /dev/null done /bin/systemctl stop coturn@.service /bin/systemctl disable coturn@.service 2> /dev/null fi %post /bin/systemctl --system daemon-reload %postun userdel %{name} 2> /dev/null || : groupdel %{name} 2> /dev/null || : %files %license LICENSE %{_bindir}/%{name} %{_bindir}/turnadmin %dir %{_docdir}/%{name} %{_datadir}/%{name}/schema.stats.redis %{_datadir}/%{name}/schema.userdb.redis %{_datadir}/%{name}/schema.sql %if 0%{?with_mongo} %{_datadir}/%{name}/schema.mongo.sh %{_datadir}/%{name}/testmongosetup.sh %else %exclude %{_datadir}/%{name}/schema.mongo.sh %exclude %{_datadir}/%{name}/testmongosetup.sh %endif %{_datadir}/%{name}/testredisdbsetup.sh %{_datadir}/%{name}/testsqldbsetup.sql %dir %{_docdir}/%{name} %{_docdir}/%{name}/README.* %exclude %{_docdir}/%{name}/README.turnutils %exclude %{_docdir}/%{name}/INSTALL %exclude %{_docdir}/%{name}/LICENSE %exclude %{_docdir}/%{name}/postinstall.txt %{_mandir}/man1/coturn.1* %{_mandir}/man1/turnserver.1.* %{_mandir}/man1/turnadmin.1* %dir %attr(0750,root,%{name}) %{_sysconfdir}/%{name} %dir %attr(0750,root,%{name}) %{_sysconfdir}/%{name}/conf.d %config(noreplace) %{_sysconfdir}/%{name}/conf.d/stund.conf %config(noreplace) %{_sysconfdir}/%{name}/conf.d/turnd-spreed.conf %config(noreplace) %{_sysconfdir}/%{name}/conf.d/turnd.conf %config(noreplace) %attr(0640,root,%{name}) %{_sysconfdir}/sysconfig/%{name}* %dir %{_sysconfdir}/pki/%{name} %dir %{_sysconfdir}/pki/%{name}/public %dir %attr(0750,root,%{name}) %{_sysconfdir}/pki/%{name}/private %{_unitdir}/%{name}@.service %{_tmpfilesdir}/%{name}.conf %dir %attr(0750,%{name},%{name}) %{_rundir}/%{name} %dir %attr(0750,%{name},%{name}) %{_localstatedir}/lib/%{name} %dir %attr(0750,%{name},%{name}) %{_localstatedir}/log/%{name} %config(noreplace) %{_sysconfdir}/logrotate.d/%{name} /lib/firewalld/services/* %files examples %license LICENSE %dir %{_docdir}/%{name}/etc %doc %{_docdir}/%{name}/etc/* %dir %{_docdir}/%{name}/scripts %doc %{_docdir}/%{name}/scripts/*.sh %doc %{_docdir}/%{name}/scripts/readme.txt %dir %{_docdir}/%{name}/scripts/basic %doc %{_docdir}/%{name}/scripts/basic/*.sh %dir %{_docdir}/%{name}/scripts/loadbalance %doc %{_docdir}/%{name}/scripts/loadbalance/*.sh %dir %{_docdir}/%{name}/scripts/longtermsecure %doc %{_docdir}/%{name}/scripts/longtermsecure/*.sh %dir %{_docdir}/%{name}/scripts/longtermsecuredb %doc %{_docdir}/%{name}/scripts/longtermsecuredb/*.sh %dir %{_docdir}/%{name}/scripts/mobile %doc %{_docdir}/%{name}/scripts/mobile/*.sh %dir %{_docdir}/%{name}/scripts/restapi %doc %{_docdir}/%{name}/scripts/restapi/*.sh %doc %{_docdir}/%{name}/scripts/restapi/shared_secret_maintainer.pl %dir %{_docdir}/%{name}/scripts/selfloadbalance %doc %{_docdir}/%{name}/scripts/selfloadbalance/*.sh # NOTE: These schema files are installed twice. Excluding copies in docs. %exclude %doc %{_docdir}/%{name}/schema.mongo.sh %exclude %doc %{_docdir}/%{name}/schema.sql %exclude %doc %{_docdir}/%{name}/schema.stats.redis %exclude %doc %{_docdir}/%{name}/schema.userdb.redis %files utils %license LICENSE %doc README.turnutils %{_bindir}/turnutils_peer %{_bindir}/turnutils_stunclient %{_bindir}/turnutils_uclient %{_bindir}/turnutils_oauth %{_bindir}/turnutils_natdiscovery %{_mandir}/man1/turnutils.1* %{_mandir}/man1/turnutils_peer.1* %{_mandir}/man1/turnutils_stunclient.1* %{_mandir}/man1/turnutils_uclient.1* %{_mandir}/man1/turnutils_oauth.1* %{_mandir}/man1/turnutils_natdiscovery.1* %files client-libs %license LICENSE %{_libdir}/libturnclient.a %files client-devel %license LICENSE %dir %{_includedir}/turn %{_includedir}/turn/ns_turn_defs.h %dir %{_includedir}/turn/client %{_includedir}/turn/client/ns_turn_ioaddr.h %{_includedir}/turn/client/ns_turn_msg_addr.h %{_includedir}/turn/client/ns_turn_msg_defs.h %{_includedir}/turn/client/ns_turn_msg_defs_experimental.h %{_includedir}/turn/client/ns_turn_msg.h %{_includedir}/turn/client/TurnMsgLib.h %changelog * Mon May 18 2020 Cpuhouse Development Team - 4.5.1.2 - Updated to 4.5.1.2 * Fri Sep 07 2018 Ekaaty BuildSystem - 4.5.0.7-2 - Created examples subpackage - Support for multiple instances - Pre-configured instances for: STUN,TURN,TURN for Spreed * Tue Sep 04 2018 Ekaaty BuildSystem - 4.5.0.7-1 - Initial import