Explorar el Código

%status and pidfile handling

Michael van Elst hace 23 años
padre
commit
3d7934fce0
Se han modificado 4 ficheros con 36 adiciones y 16 borrados
  1. 3 3
      openssh/openssh.spec
  2. 13 3
      openssh/rc.openssh
  3. 17 7
      rsync/rc.rsync
  4. 3 3
      rsync/rsync.spec

+ 3 - 3
openssh/openssh.spec

@@ -38,7 +38,7 @@ Distribution: OpenPKG [CORE]
 Group:        Security
 License:      BSD
 Version:      %{V_base}%{V_portable}
-Release:      20030715
+Release:      20030717
 
 #   package options
 %option       with_fsl     yes
@@ -63,8 +63,8 @@ Source9:      http://chrootssh.sourceforge.net/download/osshChroot-%{V_chroot}.d
 #   build information
 Prefix:       %{l_prefix}
 BuildRoot:    %{l_buildroot}
-BuildPreReq:  OpenPKG, openpkg >= 20030710, perl
-PreReq:       OpenPKG, openpkg >= 20030710
+BuildPreReq:  OpenPKG, openpkg >= 20030716, perl
+PreReq:       OpenPKG, openpkg >= 20030716
 BuildPreReq:  openssl, zlib
 PreReq:       openssl, zlib
 %if "%{with_pam}" == "yes"

+ 13 - 3
openssh/rc.openssh

@@ -13,11 +13,19 @@
 
 %common
     openssh_signal () {
-        if [ -f "@l_prefix@/var/openssh/sshd.pid" ]; then
-            kill -$1 `cat @l_prefix@/var/openssh/sshd.pid`
-        fi
+        openssh_pidfile="@l_prefix@/var/openssh/sshd.pid"
+        [ -f $openssh_pidfile ] && kill -$1 `cat $openssh_pidfile`
     }
 
+%status -p 200 -u @l_susr@ -o
+    openssh_usable="unknown"
+    openssh_active="no"
+    opServiceEnabled openssh && \
+        openssh_signal 0 && openssh_active="yes"
+    echo "openssh_enable=\"$openssh_enable\""
+    echo "openssh_usable=\"$openssh_usable\""
+    echo "openssh_active=\"$openssh_active\""
+
 %start -p 200 -u @l_susr@
     opServiceEnabled openssh || exit 0
     @l_prefix@/bin/sshd
@@ -25,6 +33,8 @@
 %stop -p 200 -u @l_susr@
     opServiceEnabled openssh || exit 0
     openssh_signal TERM
+    #   sshd removes the pidfile itself
+    #   rm -f $openssh_pidfile 2>/dev/null || true
 
 %restart -u @l_susr@
     opServiceEnabled openssh || exit 0

+ 17 - 7
rsync/rc.rsync

@@ -15,6 +15,18 @@
     rsync_cfgfile="@l_prefix@/etc/rsync/rsync.conf"
     rsync_logfile="@l_prefix@/var/rsync/rsync.log"
     rsync_pidfile="@l_prefix@/var/rsync/rsync.pid"
+    rsync_signal () {
+        [ -f $rsync_pidfile ] && kill -$1 `cat $rsync_pidfile`
+    }
+
+%status -p 200 -u @l_susr@ -o
+    rsync_usable="unknown"
+    rsync_active="no"
+    opServiceEnabled rsync && \
+        rsync_signal 0 && rsync_active="yes"
+    echo "rsync_enable=\"$rsync_enable\""
+    echo "rsync_usable=\"$rsync_usable\""
+    echo "rsync_active=\"$rsync_active\""
 
 %start -p 200 -u @l_susr@
     opServiceEnabled rsync || exit 0
@@ -23,16 +35,14 @@
 
 %stop -p 200 -u @l_susr@
     opServiceEnabled rsync || exit 0
-    if [ -f $rsync_pidfile ]; then
-        kill -TERM `cat $rsync_pidfile`
-    fi
+    rsync_signal TERM
+    #   rsync removes the pidfile itself
+    #   rm -f $rsync_pidfile 2>/dev/null || true
 
 %restart -u @l_susr@
     opServiceEnabled rsync || exit 0
-    if [ -f $rsync_pidfile ]; then
-        kill -TERM `cat $rsync_pidfile`
-        sleep 2
-    fi
+    rsync_signal TERM
+    sleep 2
     nice -n $rsync_nicelevel @l_prefix@/bin/rsync $rsync_flags \
          --daemon --config=$rsync_cfgfile
 

+ 3 - 3
rsync/rsync.spec

@@ -33,7 +33,7 @@ Distribution: OpenPKG [CORE]
 Group:        Filesystem
 License:      GPL
 Version:      2.5.6
-Release:      20030710
+Release:      20030717
 
 #   list of sources
 Source0:      http://rsync.samba.org/ftp/rsync/rsync-%{version}.tar.gz
@@ -44,8 +44,8 @@ Patch0:       rsync.patch
 #   build information
 Prefix:       %{l_prefix}
 BuildRoot:    %{l_buildroot}
-BuildPreReq:  OpenPKG, openpkg >= 20030710
-PreReq:       OpenPKG, openpkg >= 20030710
+BuildPreReq:  OpenPKG, openpkg >= 20030716
+PreReq:       OpenPKG, openpkg >= 20030716
 AutoReq:      no
 AutoReqProv:  no