]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7495 Add systemd unit configuration file for CentOS 7
authorArtur Zaprzała <zapartur@gmail.com>
Fri, 22 May 2015 09:09:22 +0000 (11:09 +0200)
committerArtur Zaprzała <artur@artur.katowicka>
Thu, 9 Jul 2015 17:23:53 +0000 (19:23 +0200)
build/freeswitch-tmpfiles.conf [new file with mode: 0644]
build/freeswitch.service [new file with mode: 0644]
freeswitch.spec

diff --git a/build/freeswitch-tmpfiles.conf b/build/freeswitch-tmpfiles.conf
new file mode 100644 (file)
index 0000000..881873f
--- /dev/null
@@ -0,0 +1 @@
+d /run/freeswitch 0750 freeswitch daemon -
diff --git a/build/freeswitch.service b/build/freeswitch.service
new file mode 100644 (file)
index 0000000..ae6921b
--- /dev/null
@@ -0,0 +1,17 @@
+[Unit]
+Description=FreeSWITCH
+After=syslog.target network.target
+After=postgresql.service postgresql-9.3.service postgresql-9.4.service mysqld.service httpd.service
+
+[Service]
+User=freeswitch
+EnvironmentFile=-/etc/sysconfig/freeswitch
+# RuntimeDirectory is not yet supported in CentOS 7. A workaround is to use /etc/tmpfiles.d/freeswitch.conf
+#RuntimeDirectory=/run/freeswitch
+#RuntimeDirectoryMode=0750
+WorkingDirectory=/run/freeswitch
+ExecStart=/usr/bin/freeswitch -nc -nf $FREESWITCH_PARAMS
+ExecReload=/usr/bin/kill -HUP $MAINPID
+
+[Install]
+WantedBy=multi-user.target
index 8c9496f326455fca76542da15cfc89d6e85f8a2b..a532e6f71420b764959f3d5bb1731f30326eb937 100644 (file)
@@ -1670,8 +1670,14 @@ cd ../..
 %if 0%{?suse_version} > 100
 %{__install} -D -m 744 build/freeswitch.init.suse %{buildroot}/etc/rc.d/init.d/freeswitch
 %else
+%if "%{?_unitdir}" == ""
 # On RedHat like
 %{__install} -D -m 0755 build/freeswitch.init.redhat %{buildroot}/etc/rc.d/init.d/freeswitch
+%else
+# systemd
+%{__install} -Dpm 0644 build/freeswitch.service %{buildroot}%{_unitdir}/freeswitch.service
+%{__install} -Dpm 0644 build/freeswitch-tmpfiles.conf %{buildroot}%{_tmpfilesdir}/freeswitch.conf
+%endif
 %endif
 # On SuSE make /usr/sbin/rcfreeswitch a link to /etc/rc.d/init.d/freeswitch
 %if 0%{?suse_version} > 100
@@ -1723,9 +1729,18 @@ fi
 
 chown freeswitch:daemon /var/log/freeswitch /var/run/freeswitch
 
+%if "%{?_unitdir}" == ""
 chkconfig --add freeswitch
+%else
+%tmpfiles_create freeswitch
+/usr/bin/systemctl -q enable freeswitch.service
+%endif
+
+%preun
+%{?systemd_preun freeswitch.service}
 
 %postun
+%{?systemd_postun freeswitch.service}
 ######################################################################################################################
 #
 #                              On uninstallation get rid of the freeswitch user
@@ -1794,7 +1809,12 @@ fi
 ######################################################################################################################
 %config(noreplace) %attr(0644,-,-) %{HTDOCSDIR}/*
 %ifos linux
+%if "%{?_unitdir}" == ""
 /etc/rc.d/init.d/freeswitch
+%else
+%{_unitdir}/freeswitch.service
+%{_tmpfilesdir}/freeswitch.conf
+%endif
 %config(noreplace) /etc/sysconfig/freeswitch
 %if 0%{?suse_version} > 100
 /usr/sbin/rcfreeswitch
@@ -2482,6 +2502,8 @@ fi
 #
 ######################################################################################################################
 %changelog
+* Tue Jul 09 2015 - Artur Zaprzała
+- add systemd service file for CentOS 7
 * Thu Jun 25 2015 - s.safarov@gmail.com
 - Dependencies of mod_shout were declared
 * Mon Jun 22 2015 - krice@freeswitch.org