Browse Source

create daemon support

Ralf S. Engelschall 15 years ago
parent
commit
afd4769b00
3 changed files with 183 additions and 2 deletions
  1. 53 0
      avahi/avahi-daemon.conf
  2. 49 2
      avahi/avahi.spec
  3. 81 0
      avahi/rc.avahi

+ 53 - 0
avahi/avahi-daemon.conf

@@ -0,0 +1,53 @@
+##
+##  avahi-daemon.conf -- Avahi Daemon Configuration
+##
+
+[server]
+#host-name=example
+#domain-name=local
+browse-domains=example.com, zeroconf.org
+use-ipv4=yes
+use-ipv6=no
+#allow-interfaces=eth0
+#deny-interfaces=eth1
+#check-response-ttl=no
+#use-iff-running=no
+#enable-dbus=yes
+#disallow-other-stacks=no
+#allow-point-to-point=no
+#cache-entries-max=4096
+#clients-max=4096
+#objects-per-client-max=1024
+#entries-per-entry-group-max=32
+ratelimit-interval-usec=1000000
+ratelimit-burst=1000
+
+[wide-area]
+enable-wide-area=yes
+
+[publish]
+#disable-publishing=no
+#disable-user-service-publishing=no
+#add-service-cookie=no
+#publish-addresses=yes
+#publish-hinfo=yes
+#publish-workstation=yes
+#publish-domain=yes
+#publish-dns-servers=192.168.50.1, 192.168.50.2
+#publish-resolv-conf-dns-servers=yes
+#publish-aaaa-on-ipv4=yes
+#publish-a-on-ipv6=no
+
+[reflector]
+#enable-reflector=no
+#reflect-ipv=no
+
+[rlimits]
+#rlimit-as=
+rlimit-core=0
+rlimit-data=4194304
+rlimit-fsize=0
+rlimit-nofile=768
+rlimit-stack=4194304
+rlimit-nproc=3
+

+ 49 - 2
avahi/avahi.spec

@@ -21,6 +21,8 @@
 ##  SUCH DAMAGE.
 ##
 
+#   FIXME: rse: package still fully untested
+
 #   package information
 Name:         avahi
 Summary:      Zeroconf/DNS-SD/mDNS Toolkit
@@ -39,6 +41,8 @@ Release:      20100813
 
 #   list of sources
 Source0:      http://avahi.org/download/avahi-%{version}.tar.gz
+Source1:      rc.avahi
+Source2:      avahi-daemon.conf
 Patch0:       avahi.patch
 
 #   build information
@@ -118,12 +122,55 @@ PreReq:       dbus
     strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
     strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
 
-    #   determine installation files
+    #   install default configuration
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/avahi
+    %{l_shtool} install -c -m 644 %{l_value -s -a} \
+        %{SOURCE avahi-daemon.conf} \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/avahi/
+
+    #   install run-command script
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
+    %{l_shtool} install -c -m 755 %{l_value -s -a} \
+        %{SOURCE rc.avahi} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
+
+    #   make sure the database directory exists
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/var/avahi/run \
+        $RPM_BUILD_ROOT%{l_prefix}/var/avahi/log
+
+    #   determine the package files
     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
         %{l_files_std} \
-        '%config %{l_prefix}/etc/avahi/*'
+        '%config %{l_prefix}/etc/avahi/*' \
+        '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/avahi' \
+        '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/avahi/*'
 
 %files -f files
 
 %clean
 
+%pre
+    #   before upgrade, save status and stop service
+    [ $1 -eq 2 ] || exit 0
+    eval `%{l_rc} avahi status 2>/dev/null | tee %{l_tmpfile}`
+    %{l_rc} avahi stop 2>/dev/null
+    exit 0
+
+%post
+    if [ $1 -eq 2 ]; then
+        #   after upgrade, restore status
+        { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
+        [ ".$avahi_active" = .yes ] && %{l_rc} avahi start
+    fi
+    exit 0
+
+%preun
+    #   before erase, stop service and remove log files
+    [ $1 -eq 0 ] || exit 0
+    %{l_rc} avahi stop 2>/dev/null
+    rm -f  $RPM_INSTALL_PREFIX/var/avahi/run/* >/dev/null 2>&1 || true
+    rm -f  $RPM_INSTALL_PREFIX/var/avahi/log/* >/dev/null 2>&1 || true
+    exit 0
+

+ 81 - 0
avahi/rc.avahi

@@ -0,0 +1,81 @@
+#!@l_prefix@/bin/openpkg rc
+##
+##  rc.avahi -- Run-Commands
+##
+
+%config
+    avahi_enable="$openpkg_rc_def"
+    avahi_daemons="avahi-daemon avahi-dnsconfd"
+    avahi_log_prolog="true"
+    avahi_log_epilog="true"
+    avahi_log_numfiles="10"
+    avahi_log_minsize="1M"
+    avahi_log_complevel="9"
+
+%common
+    avahi_etcdir="@l_prefix@/etc/avahi"
+    avahi_vardir="@l_prefix@/var/avahi"
+    avahi_check () {
+        local retcode=0
+        local daemons=
+        for daemon in $avahi_daemons; do
+            @l_prefix@/sbin/$daemon -c
+            retcode=$(($retcode+$?))
+        done
+        return $retcode
+    }
+
+%status -u @l_susr@ -o
+    avahi_usable="unknown"
+    avahi_active="no"
+    rcService avahi enable yes && \
+        avahi_check && avahi_active="yes"
+    echo "avahi_enable=\"$avahi_enable\""
+    echo "avahi_usable=\"$avahi_usable\""
+    echo "avahi_active=\"$avahi_active\""
+
+%start -u @l_rusr@
+    rcService avahi enable yes || exit 0
+    rcService avahi active yes && exit 0
+    for daemon in $avahi_daemons; do
+        @l_prefix@/sbin/$daemon -D
+    done
+
+%stop -u @l_susr@
+    rcService avahi enable yes || exit 0
+    rcService avahi active no  && exit 0
+    for daemon in $avahi_daemons; do
+        @l_prefix@/sbin/$daemon -k
+    done
+
+%restart -u @l_susr@
+    rcService avahi enable yes || exit 0
+    rcService avahi active no  && exit 0
+    rc avahi stop start
+
+%reload -u @l_susr@
+    rcService avahi enable yes || exit 0
+    rcService avahi active no  && exit 0
+    for daemon in $avahi_daemons; do
+        @l_prefix@/sbin/$daemon -r
+    done
+
+%daily -u @l_susr@
+    rcService avahi enable yes || exit 0
+    rcTmp -i
+    hintfile=`rcTmp -f -n hint`
+    for daemon in $avahi_daemons; do
+        if [ -f $avahi_vardir/log/$daemon.log ]; then
+            shtool rotate -f \
+                -n $avahi_log_numfiles -s $avahi_log_minsize -d \
+                -z $avahi_log_complevel -m 664 -o @l_rusr@ -g @l_rgrp@ \
+                -P "$avahi_log_prolog" \
+                -E "$avahi_log_epilog; echo 1 >$hintfile" \
+                $avahi_vardir/log/$daemon.log
+        fi
+    done
+    if [ -s $hintfile ]; then
+        rc avahi restart
+    fi
+    rcTmp -k
+