[packages/tvheadend] - initial; unfinished init script, more work/testing needed

arekm arekm at pld-linux.org
Sat Jan 11 21:46:03 CET 2014


commit 7d3739f887a0a02038f70bcbce12e12de65ba28f
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sat Jan 11 21:46:00 2014 +0100

    - initial; unfinished init script, more work/testing needed

 tvheadend.init | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tvheadend.spec |  26 ++++++++--
 2 files changed, 181 insertions(+), 5 deletions(-)
---
diff --git a/tvheadend.spec b/tvheadend.spec
index 7206909..21a303a 100644
--- a/tvheadend.spec
+++ b/tvheadend.spec
@@ -3,18 +3,25 @@ Name:		tvheadend
 Version:	3.9
 Release:	0.1
 License:	GPL v3
-Group:		Video/Television
+Group:		Applications/Multimedia
 URL:		https://tvheadend.org/projects/tvheadend
-Source0:	https://github.com/tvheadend/tvheadend/archive/v3.9.tar.gz
+Source0:	https://github.com/tvheadend/tvheadend/archive/v%{version}.tar.gz
 # Source0-md5:	177f5ecf771a1877d38a00bf18806f15
 Source1:	%{name}.conf
 Source2:	%{name}.service
 Source3:	%{name}.sysconfig
+Source4:	%{name}.init
+BuildRequires:	avahi-devel
+BuildRequires:	curl-devel
+BuildRequires:	python-modules
 BuildRequires:	rpmbuild(macros) >= 1.647
+BuildRequires:	zlib-devel
 Requires(post,preun,postun):	systemd-units >= 38
 Requires:	systemd-units >= 0.38
 Requires(post):	pwgen
 Requires(post):	sed >= 4.0
+Requires(post):	/sbin/chkconfig
+Requires(post,preun):	/sbin/chkconfig
 Requires:	group(video)
 Provides:	user(%{name})
 
@@ -23,12 +30,13 @@ Tvheadend is a TV streaming server for Linux supporting DVB-S, DVB-S2,
 DVB-C, DVB-T, ATSC, IPTV, and Analog video (V4L) as input sources.
 
 %prep
-%setup -q -n %{name}-%{version}
+%setup -q
 
 %build
 export CFLAGS="%{rpmcflags}"
 export CC="%{__cc}"
-#tvheadend uses a custom configure script, so %%configure cannot be used
+
+# tvheadend uses a custom script, so %%configure cannot be used
 # as not all options are supported
 ./configure \
 	--prefix=%{_prefix} \
@@ -44,7 +52,7 @@ rm -rf $RPM_BUILD_ROOT
 install -d $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/.hts/%{name}/accesscontrol \
 	$RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/Videos \
 	$RPM_BUILD_ROOT%{systemdunitdir} \
-	$RPM_BUILD_ROOT/etc/sysconfig
+	$RPM_BUILD_ROOT/etc/{rc.d/init.d,sysconfig}
 
 %{__make} install \
 	DESTDIR=$RPM_BUILD_ROOT
@@ -52,6 +60,7 @@ install -d $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/.hts/%{name}/accesscontr
 cp %{SOURCE1} $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/.hts/%{name}/accesscontrol/1
 cp %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/%{name}.service
 cp %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
+cp %{SOURCE4} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
 
 chmod +x $RPM_BUILD_ROOT%{_bindir}/%{name}
 
@@ -59,6 +68,8 @@ chmod +x $RPM_BUILD_ROOT%{_bindir}/%{name}
 %useradd -u 20 -d %{_localstatedir}/lib/%{name} -g video -c "tvheadend User" %{name}
 
 %post
+/sbin/chkconfig --add tvheadend
+%service tvheadend reload "tvheadend"
 %systemd_post %{name}.service
 
 # check if the access control file still has the initial dummy password, and
@@ -68,6 +79,10 @@ if  grep -q '"password": "dummypassword"' %{_localstatedir}/lib/%{name}/.hts/%{n
 fi
 
 %preun
+if [ "$1" = "0" ]; then
+	%service tvheadend stop
+	/sbin/chkconfig --del tvheadend
+fi
 %systemd_preun %{name}.service
 
 %postun
@@ -83,6 +98,7 @@ rm -rf $RPM_BUILD_ROOT
 %defattr(644,root,root,755)
 %doc docs
 %attr(755,root,root) %{_bindir}/%{name}
+%attr(754,root,root) /etc/rc.d/init.d/tvheadend
 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
 %{_mandir}/man1/%{name}.1*
 %{_datadir}/%{name}
diff --git a/tvheadend.init b/tvheadend.init
new file mode 100755
index 0000000..c3d5a21
--- /dev/null
+++ b/tvheadend.init
@@ -0,0 +1,160 @@
+#!/bin/sh
+#
+# tvheadend	tvheadend tv streaming service
+#
+# chkconfig:	345 40 60
+#
+# description:	tvheadend tv streaming service
+#
+# processname:	tvheadend
+#
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# 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 "tvheadend"
+		exit 1
+	fi
+else
+	exit 0
+fi
+
+# Set defaults
+TVHEADEND_ARGS=""
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/tvheadend ] && . /etc/sysconfig/tvheadend
+
+# configtest itself
+# must return non-zero if check failed
+# output is discarded if checkconfig is ran without details
+configtest() {
+	/usr/sbin/tvheadend -t
+	return $?
+}
+
+# wrapper for configtest
+checkconfig() {
+	local details=${1:-0}
+
+	if [ $details = 1 ]; then
+		# run config test and display report (status action)
+		show "Checking %s configuration" "tvheadend"; busy
+		local out
+		out=$(configtest 2>&1)
+		RETVAL=$?
+		if [ $RETVAL = 0 ]; then
+			ok
+		else
+			fail
+		fi
+		[ "$out" ] && echo >&2 "$out"
+	else
+		# run config test and abort with nice message if failed
+		# (for actions checking status before action).
+		configtest >/dev/null 2>&1
+		RETVAL=$?
+		if [ $RETVAL != 0 ]; then
+			show "Checking %s configuration" "tvheadend"; fail
+			nls 'Configuration test failed. See details with %s "checkconfig"' $0
+			exit $RETVAL
+		fi
+	fi
+}
+
+start() {
+	# Check if the service is already running?
+	if [ -f /var/lock/subsys/tvheadend ]; then
+		msg_already_running "tvheadend"
+		return
+	fi
+
+	checkconfig
+	msg_starting "tvheadend"
+	daemon --group video /usr/sbin/tvheadend
+	RETVAL=$?
+	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/tvheadend
+}
+
+stop() {
+	if [ ! -f /var/lock/subsys/tvheadend ]; then
+		msg_not_running "tvheadend"
+		return
+	fi
+
+	# Stop daemons.
+	msg_stopping "tvheadend"
+	killproc tvheadend
+	rm -f /var/lock/subsys/tvheadend
+}
+
+reload() {
+	if [ ! -f /var/lock/subsys/tvheadend ]; then
+		msg_not_running "tvheadend"
+		RETVAL=7
+		return
+	fi
+
+	checkconfig
+	msg_reloading "tvheadend"
+	killproc tvheadend -HUP
+	RETVAL=$?
+}
+
+condrestart() {
+	if [ ! -f /var/lock/subsys/tvheadend ]; then
+		msg_not_running "tvheadend"
+		RETVAL=$1
+		return
+	fi
+
+	checkconfig
+	stop
+	start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+	start
+	;;
+  stop)
+	stop
+	;;
+  restart)
+	checkconfig
+	stop
+	start
+	;;
+  try-restart)
+	condrestart 0
+	;;
+# include force-reload here if program allows reloading without restart
+# otherwise remove reload action and support force-reload as restart if running
+  reload|force-reload)
+	reload
+	;;
+# use this one if program doesn't support reloading without restart
+  force-reload)
+	condrestart 7
+	;;
+  checkconfig|configtest)
+	checkconfig 1
+	;;
+  status)
+	status tvheadend
+	RETVAL=$?
+	;;
+  *)
+	msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|checkconfig|status}"
+	exit 3
+esac
+
+exit $RETVAL
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/tvheadend.git/commitdiff/7d3739f887a0a02038f70bcbce12e12de65ba28f



More information about the pld-cvs-commit mailing list