]> git.pld-linux.org Git - packages/tvheadend.git/commitdiff
- initial; unfinished init script, more work/testing needed
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Sat, 11 Jan 2014 20:46:00 +0000 (21:46 +0100)
committerArkadiusz Miśkiewicz <arekm@maven.pl>
Sat, 11 Jan 2014 20:46:00 +0000 (21:46 +0100)
tvheadend.init [new file with mode: 0755]
tvheadend.spec

diff --git a/tvheadend.init b/tvheadend.init
new file mode 100755 (executable)
index 0000000..c3d5a21
--- /dev/null
@@ -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
index 72069096ebbd0110d22e98228774c8a0d7b1a096..21a303a4aca071fc263ae123101597757961f366 100644 (file)
@@ -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}
This page took 0.229295 seconds and 4 git commands to generate.