Projects
Multimedia
mediatomb
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 25
View file
mediatomb.spec
Changed
@@ -66,13 +66,12 @@ BuildRequires: sqlite3-devel BuildRequires: udev BuildRequires: pkgconfig(libexif) -BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: js-devel Requires: %{name}-dbbackend = %{version}-%{release} Requires: logrotate -Requires(pre): %insserv_prereq +%{?systemd_requires} Requires(pre): coreutils Requires(pre): sed Requires(pre): iproute @@ -213,16 +212,26 @@ mv %{buildroot}%{_bindir}/mediatomb \ %{buildroot}%{_bindir}/mediatomb-sqlite -################### -# init script -install -dm 755 %{buildroot}%{_sbindir} -install -dm 755 %{buildroot}%{_sysconfdir}/init.d -install -m 755 %{SOURCE1} \ - %{buildroot}%{_sysconfdir}/init.d/mediatomb +mkdir -vp %{buildroot}%{_libexecdir} %{buildroot}%{_sysconfdir} +install -m 755 %{SOURCE1} %{buildroot}%{_libexecdir}/%{name} install -m 755 config/mediatomb-conf-fedora \ - %{buildroot}%{_sysconfdir}/mediatomb.conf -ln -s ../../%{_sysconfdir}/init.d/%{name} \ - %{buildroot}%{_sbindir}/rcmediatomb + %{buildroot}%{_sysconfdir}/%{name}.conf +mkdir -vp %{buildroot}%{_unitdir} +tee %{buildroot}%{_unitdir}/%{name}.service <<_EOS_ +[Unit] +Description=%{name} UPnP AV MediaServer +After=network-online.target +After=remote-fs.target +After=time-sync.target + +[Service] +EnvironmentFile=-%{_sysconfdir}/%{name}.conf +ExecStart=%{_libexecdir}/%{name} +ExecReload=%{_bindir}/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target +_EOS_ ################### # sample config @@ -261,22 +270,25 @@ -r \ -d %{_localstatedir}/lib/%{name} \ -G mediatomb \ - mediatomb > /dev/null 2> /dev/null || : + mediatomb || : +%service_add_pre %{name}.service + +%post +%service_add_post %{name}.service %preun -%stop_on_removal mediatomb +%service_del_preun %{name}.service # if removal and not upgrade clean up if test "$1" -eq 0 ; then - /usr/sbin/userdel -r -f mediatomb > /dev/null 2> /dev/null || : - /usr/sbin/groupdel mediatomb > /dev/null 2> /dev/null || : + /usr/sbin/userdel -r -f mediatomb || : + /usr/sbin/groupdel mediatomb || : fi %postun if test "$1" = 0 ; then rm -fv "%{_bindir}/mediatomb" fi -%restart_on_update mediatomb -%insserv_cleanup +%service_del_postun_with_restart %{name}.service %pre sqlite # create group if necessary @@ -290,7 +302,7 @@ -r \ -d %{_localstatedir}/lib/%{name} \ -G mediatomb \ - mediatomb > /dev/null 2> /dev/null || : + mediatomb || : %post sqlite if test "$1" != 0 ; then @@ -310,10 +322,10 @@ %attr(0750,mediatomb,mediatomb) %dir %{_sysconfdir}/%{name} %attr(0660,mediatomb,mediatomb) %config(noreplace) %{_sysconfdir}/%{name}/config.xml %config(noreplace) %{_sysconfdir}/logrotate.d/%{name} -%{_sysconfdir}/init.d/%{name} -%{_sbindir}/rcmediatomb %{_datadir}/%{name}/ +%{_libexecdir}/%{name} %{_mandir}/man1/* +%{_unitdir} %files mysql %{_bindir}/mediatomb-mysql
View file
rcmediatomb
Changed
@@ -1,110 +1,37 @@ -#!/bin/sh -# -# mediatomb This script starts and stops the mediatomb daemon -# -# processname: mediatomb -# description: mediatomb is a daemon process which provides a UPnP service -# config: /etc/mediatomb -# config: /etc/mediatomb/config.xml -# pidfile: /var/run/mediatomb.pid - -### BEGIN INIT INFO -# Provides: mediatomb -# Required-Start: $local_fs $remote_fs $network -# Required-Stop: $local_fs $remote_fs $network -# Default-Start: 3 5 -# Default-Stop: 0 1 2 6 -# Short-Description: MediaTomb daemon -# Description: This script starts and stops the mediatomb daemon -### END INIT INFO - -# Source function library. -. /etc/rc.status -rc_reset - -# Source networking configuration. -#. /etc/sysconfig/network - -# Set default mediatomb configuration. - -# either make an installation in /etc/mediatomb and leave this blank, -# or specify an alternative config file location using the -c option -# Note: be aware, that -i parameter is used to set the ip of the -# interface specified above - -. /etc/mediatomb.conf - +#!/bin/bash +set -e +cfg='/etc/mediatomb.conf' +for i in MT_USER MT_GROUP MT_LOGFILE MT_HOME MT_CFGDIR MT_PORT +do + if test -z "${!i}" + then + echo "${i}= must be set, either in ${cfg} or /etc/systemd/system/mediatomb.service.d/tune.conf" + exit 1 + fi +done +if test "${MT_INTERFACE}" = "NOT_SET" || test "${MT_INTERFACE}" = "" +then + echo "Please edit ${cfg} and change the MT_INTERFACE variable to your network device (eth0, eth1, etc.)" + exit 1 +fi +IFACE_IP="`ip -oneline -family inet addr show dev ${MT_INTERFACE} | sed -n 's@\(^[0-9]\+:[[:blank:]]\+[^[:blank:]]\+[[:blank:]]\+inet[[:blank:]]\+\)\([^/]\+\)\(.*\)@\2@p'`" +if test -z "${IFACE_IP}" +then + echo "No IPv4 found on MT_INTERFACE ${MT_INTERFACE}" + exit 1 +fi ############################### # make sure to run it as $MT_USER -MEDIATOMB="-d -u $MT_USER -g $MT_GROUP -P $MT_PIDFILE -l $MT_LOGFILE -m $MT_HOME -f $MT_CFGDIR -p $MT_PORT" - -test -x "/usr/bin/mediatomb" || { echo "/usr/bin/mediatomb not installed"; - if [ "$1" = "stop" ]; then exit 0; - else exit 5; fi; } - -[ ${MT_INTERFACE} = "NOT_SET" ] && echo "Please edit /etc/mediatomb.conf and change \ -the MT_INTERFACE variable to your network device (eth0, eth1, etc.)" && exit 0 - -PATH="$PATH:/usr/bin:/usr/local/bin" - -IFACE_IP="`ip -oneline -family inet addr show dev $MT_INTERFACE | sed -n 's@\(^[0-9]\+:[[:blank:]]\+[^[:blank:]]\+[[:blank:]]\+inet[[:blank:]]\+\)\([^/]\+\)\(.*\)@\2@p'`" -[ -d /var/lock/subsys/ ] || mkdir -p /var/lock/subsys/ - -# By default it's all good -RETVAL=0 - -# See how we were called. -case "$1" in - start) - # Start daemon. - echo -n "Applying multicast settings to $MT_INTERFACE... " - # those settings are necessary for us to react to M-SEARCH requests - ip route add 239.0.0.0/8 dev $MT_INTERFACE - ip link set dev $MT_INTERFACE allmulti on - touch $MT_PIDFILE - chown $MT_USER $MT_PIDFILE - - mkdir -p "/$MT_HOME/$MT_CFGDIR" - chown $MT_USER "/$MT_HOME/$MT_CFGDIR" +MEDIATOMB="-u ${MT_USER} -g ${MT_GROUP} -l ${MT_LOGFILE} -m ${MT_HOME} -f ${MT_CFGDIR} -p ${MT_PORT}" - echo -n "Starting mediatomb: " - mediatomb $MEDIATOMB -i $IFACE_IP $MT_OPTIONS - RETVAL=$? - rc_status -v - [ $RETVAL = 0 ] && touch /var/lock/subsys/mediatomb - ;; - stop) - # Stop daemons. - echo -n "Shutting down mediatomb: " - killproc mediatomb - RETVAL=$? - rc_status -v +# Start daemon. +echo "Applying multicast settings to ${MT_INTERFACE}" +# those settings are necessary for us to react to M-SEARCH requests +ip route add 239.0.0.0/8 dev ${MT_INTERFACE} +ip link set dev ${MT_INTERFACE} allmulticast on - [ $RETVAL = 0 ] && rm -f /var/lock/subsys/mediatomb - ;; - restart) - $0 stop - $0 start - ;; - reload) - $0 stop - $0 start - ;; - condrestart) - [ -e /var/lock/subsys/mediatomb ] && $0 restart - ;; - status) - if test -e $MT_PIDFILE ; then - echo " seems running" - else - echo " not running" - fi - RETVAL=$? - ;; - *) - echo "Usage: $0 {start|stop|restart|status|condrestart}" - RETVAL=1 - ;; -esac +mkdir -vp "${MT_HOME}/${MT_CFGDIR}" +chown -v "${MT_USER}:${MT_GROUP}" "${MT_HOME}/${MT_CFGDIR}" -rc_exit +echo "Starting mediatomb" +exec mediatomb ${MEDIATOMB} -i ${IFACE_IP} ${MT_OPTIONS}
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.