[Pkg-sysvinit-commits] r1337 - in sysvinit/trunk/debian: . service

Petter Reinholdtsen pere at alioth.debian.org
Tue Jun 23 12:49:50 UTC 2009


Author: pere
Date: 2009-06-23 12:49:49 +0000 (Tue, 23 Jun 2009)
New Revision: 1337

Added:
   sysvinit/trunk/debian/service/
   sysvinit/trunk/debian/service/service
   sysvinit/trunk/debian/service/service.8
Modified:
   sysvinit/trunk/debian/changelog
   sysvinit/trunk/debian/control
   sysvinit/trunk/debian/rules
Log:
Add a /usr/sbin/service command (Closes: #534300).  Modified the
manual page based on ideas from the sysvconfig package.  Thanks to
Steve Langasek and Ubuntu.  Add conflict with sysvconfig and
chkconfig providing the same program.

Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog	2009-06-23 11:45:36 UTC (rev 1336)
+++ sysvinit/trunk/debian/changelog	2009-06-23 12:49:49 UTC (rev 1337)
@@ -71,6 +71,10 @@
   * Comment out the code disabling fsck when running on battery.  It
     need changes in fsck to work properly (Closes: #526398).  This
     Reopens #326647.
+  * Add a /usr/sbin/service command (Closes: #534300).  Modified the
+    manual page based on ideas from the sysvconfig package.  Thanks to
+    Steve Langasek and Ubuntu.  Add conflict with sysvconfig and
+    chkconfig providing the same program.
 
  -- Kel Modderman <kel at otaku42.de>  Tue, 23 Jun 2009 20:40:49 +1000
 

Modified: sysvinit/trunk/debian/control
===================================================================
--- sysvinit/trunk/debian/control	2009-06-23 11:45:36 UTC (rev 1336)
+++ sysvinit/trunk/debian/control	2009-06-23 12:49:49 UTC (rev 1337)
@@ -26,7 +26,7 @@
 Package: sysvinit-utils
 Essential: yes
 Architecture: any
-Conflicts: last
+Conflicts: last, sysvconfig, chkconfig
 Replaces: last, sysvinit (<= 2.86.ds1-61)
 Depends: ${shlibs:Depends}
 Suggests: sash

Modified: sysvinit/trunk/debian/rules
===================================================================
--- sysvinit/trunk/debian/rules	2009-06-23 11:45:36 UTC (rev 1336)
+++ sysvinit/trunk/debian/rules	2009-06-23 12:49:49 UTC (rev 1337)
@@ -108,6 +108,7 @@
 	rm -f $(tmp)/usr/share/man/man1/last.1
 	rm -f $(tmp)/usr/share/man/man1/lastb.1
 	rm -f $(tmp)/usr/share/man/man1/mesg.1
+	rm -f $(tmp)/usr/share/man/man8/service.8
 	rm -f $(tmp)/usr/share/man/man8/pidof.8
 	rm -f $(tmp)/usr/share/man/man1/mountpoint.1
 	rm -f $(tmp)/sbin/killall5
@@ -115,6 +116,7 @@
 	rm -f $(tmp)/usr/bin/last
 	rm -f $(tmp)/usr/bin/lastb
 	rm -f $(tmp)/usr/bin/mesg
+	rm -f $(tmp)/usr/sbin/service
 	rm -f $(tmp)/bin/pidof
 	rm -f $(tmp)/bin/mountpoint
 	rmdir $(tmp)/usr/share/man/man1
@@ -152,6 +154,7 @@
 	install -o root -g root -m 755 src/mesg $(tmp)/usr/bin
 	$(MAKE) $(CROSS) -C debian/startpar DESTDIR=$(tmp) install
 	strip -s -R comment -R .comment $(tmp)/sbin/startpar
+	install -o root -g root -m 755 debian/service/service $(tmp)/usr/sbin
 	strip -s -R .comment $(tmp)/sbin/killall5
 	strip -s -R .comment $(tmp)/sbin/sulogin
 	strip -s -R .comment $(tmp)/usr/bin/last
@@ -163,6 +166,7 @@
 	install -o root -g root -m 644 man/last.1 $(tmp)/usr/share/man/man1
 	install -o root -g root -m 644 man/lastb.1 $(tmp)/usr/share/man/man1
 	install -o root -g root -m 644 man/mesg.1 $(tmp)/usr/share/man/man1
+	install -o root -g root -m 644 debian/service/service.8 $(tmp)/usr/share/man/man8
 	install -o root -g root -m 644 man/pidof.8 $(tmp)/usr/share/man/man8
 	gzip -9f $(tmp)/usr/share/man/man*/*.[0-9]
 	install -o root -g root -m 644 debian/copyright \

Added: sysvinit/trunk/debian/service/service
===================================================================
--- sysvinit/trunk/debian/service/service	                        (rev 0)
+++ sysvinit/trunk/debian/service/service	2009-06-23 12:49:49 UTC (rev 1337)
@@ -0,0 +1,120 @@
+#!/bin/sh
+
+###########################################################################
+# /usr/bin/service
+#
+# A convenient wrapper for the /etc/init.d init scripts.
+#
+# This script is a modified version of the /sbin/service utility found on
+# Red Hat/Fedora systems (licensed GPLv2+).
+#
+# Copyright (C) 2006 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2008 Canonical Ltd.
+#   * August 2008 - Dustin Kirkland <kirkland at canonical.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+# On Debian GNU/Linux systems, the complete text of the GNU General
+# Public License can be found in `/usr/share/common-licenses/GPL'.
+###########################################################################
+
+
+is_ignored_file() {
+	case "$1" in
+		skeleton | README | *.dpkg-dist | *.dpkg-old | rc | rcS | single | reboot | bootclean.sh)
+			return 0
+		;;
+	esac
+	return 1
+}
+
+VERSION="`basename $0` ver. 0.91-ubuntu1"
+USAGE="Usage: `basename $0` < option > | --status-all | \
+[ service_name [ command | --full-restart ] ]"
+SERVICE=
+SERVICEDIR="/etc/init.d"
+OPTIONS=
+
+if [ $# -eq 0 ]; then
+   echo "${USAGE}" >&2
+   exit 1
+fi
+
+cd /
+while [ $# -gt 0 ]; do
+  case "${1}" in
+    --help | -h | --h* )
+       echo "${USAGE}" >&2
+       exit 0
+       ;;
+    --version | -V )
+       echo "${VERSION}" >&2
+       exit 0
+       ;;
+    *)
+       if [ -z "${SERVICE}" -a $# -eq 1 -a "${1}" = "--status-all" ]; then
+          cd ${SERVICEDIR}
+          for SERVICE in * ; do
+            case "${SERVICE}" in
+              functions | halt | killall | single| linuxconf| kudzu)
+                  ;;
+              *)
+                if ! is_ignored_file "${SERVICE}" \
+		    && [ -x "${SERVICEDIR}/${SERVICE}" ]; then
+                        if ! grep -qs "\Wstatus)" "$SERVICE"; then
+                          #printf " %s %-60s %s\n" "[?]" "$SERVICE:" "unknown" 1>&2
+                          echo " [ ? ]  $SERVICE" 1>&2
+                          continue
+                        else
+                          out=$(env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status 2>&1)
+                          if [ "$?" = "0" -a -n "$out" ]; then
+                            #printf " %s %-60s %s\n" "[+]" "$SERVICE:" "running"
+                            echo " [ + ]  $SERVICE"
+                            continue
+                          else
+                            #printf " %s %-60s %s\n" "[-]" "$SERVICE:" "NOT running"
+                            echo " [ - ]  $SERVICE"
+                            continue
+                          fi
+                        fi
+                  #env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status
+                fi
+                ;;
+            esac
+          done
+          exit 0
+       elif [ $# -eq 2 -a "${2}" = "--full-restart" ]; then
+          SERVICE="${1}"
+          if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
+            env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" stop
+            env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" start
+            exit $?
+          fi
+       elif [ -z "${SERVICE}" ]; then
+         SERVICE="${1}"
+       else
+         OPTIONS="${OPTIONS} ${1}"
+       fi
+       shift
+       ;;
+   esac
+done
+
+if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
+   env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" ${OPTIONS}
+else
+   echo $"${SERVICE}: unrecognized service" >&2
+   exit 1
+fi

Added: sysvinit/trunk/debian/service/service.8
===================================================================
--- sysvinit/trunk/debian/service/service.8	                        (rev 0)
+++ sysvinit/trunk/debian/service/service.8	2009-06-23 12:49:49 UTC (rev 1337)
@@ -0,0 +1,91 @@
+.\" A man page for service(8). -*- nroff -*-
+.\"
+.\" Copyright (C) 2006 Red Hat, Inc. All rights reserved.
+.\"
+.\" This copyrighted material is made available to anyone wishing to use,
+.\" modify, copy, or redistribute it subject to the terms and conditions of the
+.\" GNU General Public License v.2.
+.\"
+.\" This program is distributed in the hope that it will be useful, but WITHOUT
+.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
+.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 
+.\" more details.
+.\"
+.\" You should have received a copy of the GNU General Public License along
+.\" with this program; if not, write to the Free Software Foundation, Inc.,
+.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+.\"
+.\" Author: Miloslav Trmac <mitr at redhat.com>
+.\" Updated by: Petter Reinholdtsen <pere at hungry.com>
+
+.TH service 8 "Jan 2006"
+
+.SH NAME
+service \- run a System V init script
+
+.SH SYNOPSIS
+\fBservice\fR \fISCRIPT\fR \fICOMMAND\fR [\fIOPTIONS\fR]
+
+\fBservice \-\-status\-all\fR
+
+\fBservice\fR \fB\-\-help\fR | \fB\-h\fR | \fB\-\-version\fR
+
+.SH DESCRIPTION
+.B service
+runs a System V init script in as predictable environment as possible,
+removing most environment variables
+and with current working directory set to \fB/\fR.
+
+The
+.I SCRIPT
+parameter specifies a System V init script,
+located in \fB/etc/init.d/\fISCRIPT\fR.
+The supported values of
+.I COMMAND
+depend on the invoked script,
+.B service
+passes
+.I COMMAND
+and
+.I OPTIONS
+it to the init script unmodified.
+All scripts should support at least the
+.B start
+and
+.B stop
+commands.
+As a special case, if
+.I COMMAND
+is \fB\-\-full-restart\fR, the script is run twice, first with the
+.B stop
+command, then with the
+.B start
+command.
+
+.B service \-\-status\-all
+runs all init scripts, in alphabetical order, with the
+.B status
+command.
+
+.SH EXIT CODES
+.BR service
+calls the init script and returns the status returned by it.
+
+.SH FILES
+.TP
+\fB/etc/init.d\fR
+The directory containing System V init scripts.
+
+.SH ENVIRONMENT
+.TP
+\fBLANG\fR, \fBTERM\fR
+The only environment variables passed to the init scripts.
+
+.SH SEE ALSO
+.IR /etc/init.d/skeleton ,
+.br
+.BR update\-rc.d (8),
+.br
+.BR init (8),
+.br
+.BR invoke\-rc.d (8).




More information about the Pkg-sysvinit-commits mailing list