[packages/stunserver] - rel 2; add init script
arekm
arekm at pld-linux.org
Tue Mar 24 13:55:11 CET 2020
commit 2242fad202f1d4191edda4a518711b792bd93fd1
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Tue Mar 24 13:55:04 2020 +0100
- rel 2; add init script
stunserver.init | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
stunserver.spec | 13 ++++++--
2 files changed, 103 insertions(+), 2 deletions(-)
---
diff --git a/stunserver.spec b/stunserver.spec
index 8238804..d5b53e3 100644
--- a/stunserver.spec
+++ b/stunserver.spec
@@ -5,13 +5,14 @@
Summary: STUNTMAN STUN server
Name: stunserver
Version: 1.2.15
-Release: 1
+Release: 2
License: Apache v2.0
Group: Networking/Daemons
Source0: http://www.stunprotocol.org/%{name}-%{version}.tgz
# Source0-md5: 8a923faa15fff05cbfb77330e5ebf116
Source1: %{name}.service
Source2: %{name}.sysconfig
+Source3: %{name}.init
URL: http://www.stunprotocol.org/
BuildRequires: rpmbuild(macros) >= 1.647
Requires(post,preun,postun): systemd-units >= 38
@@ -53,19 +54,26 @@ This package contains the client application.
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_bindir},%{systemdunitdir},/etc/sysconfig}
+install -d $RPM_BUILD_ROOT{%{_bindir},%{systemdunitdir},/etc/{rc.d/init.d,sysconfig}}
cp -p stunclient stunserver $RPM_BUILD_ROOT%{_bindir}
cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/%{name}.service
cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
+cp -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
%clean
rm -rf $RPM_BUILD_ROOT
%post
+/sbin/chkconfig --add %{name}
+%service %{name} restart
%systemd_post %{name}.service
%preun
+if [ "$1" = "0" ]; then
+ %service %{name} stop
+ /sbin/chkconfig --del %{name}
+fi
%systemd_preun %{name}.service
%postun
@@ -77,6 +85,7 @@ rm -rf $RPM_BUILD_ROOT
%attr(755,root,root) %{_bindir}/stunserver
%config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/stunserver
%{systemdunitdir}/%{name}.service
+%attr(754,root,root) /etc/rc.d/init.d/%{name}
%files -n stunclient
%defattr(644,root,root,755)
diff --git a/stunserver.init b/stunserver.init
new file mode 100644
index 0000000..22d6b85
--- /dev/null
+++ b/stunserver.init
@@ -0,0 +1,92 @@
+#!/bin/sh
+#
+# stunserver This shell script takes care of starting and stopping stunserver.
+#
+# chkconfig: 2345 80 30
+# description: stunserver is a STUN protocol server
+#
+# processname: stunserver
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Source networking configuration.
+. /etc/sysconfig/network
+
+# Source oident configureation.
+if [ -f /etc/sysconfig/stunserver ]; then
+ . /etc/sysconfig/stunserver
+fi
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+ if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+ msg_network_down stunserver
+ exit 1
+ fi
+else
+ exit 0
+fi
+
+start() {
+ # Start daemons.
+ if [ ! -f /var/lock/subsys/stunserver ]; then
+ msg_starting stunserver
+ daemon --user nobody --fork /usr/bin/stunserver $STUNSERVER_OPTIONS
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/stunserver
+ else
+ msg_already_running stunserver
+ fi
+}
+
+stop() {
+ # Stop daemons.
+ if [ -f /var/lock/subsys/stunserver ]; then
+ msg_stopping stunserver
+ killproc stunserver
+ rm -f /var/lock/subsys/stunserver >/dev/null 2>&1
+ else
+ msg_not_running stunserver
+ fi
+}
+
+condrestart() {
+ if [ -f /var/lock/subsys/stunserver ]; then
+ stop
+ start
+ else
+ msg_not_running stunserver
+ RETVAL=$1
+ fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ try-restart)
+ condrestart 0
+ ;;
+ force-reload)
+ condrestart 7
+ ;;
+ status)
+ status stunserver
+ exit $?
+ ;;
+ *)
+ msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+ exit 3
+esac
+
+exit $RETVAL
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/stunserver.git/commitdiff/2242fad202f1d4191edda4a518711b792bd93fd1
More information about the pld-cvs-commit
mailing list