Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7]: src Pull up following revision(s) (requested by ast in ticket...



details:   https://anonhg.NetBSD.org/src/rev/2886a2d3c334
branches:  netbsd-7
changeset: 799239:2886a2d3c334
user:      snj <snj%NetBSD.org@localhost>
date:      Tue Apr 21 05:22:58 2015 +0000

description:
Pull up following revision(s) (requested by ast in ticket #636):
        distrib/sets/lists/base/mi: revision 1.1098
        distrib/sets/lists/man/mi: revision 1.1498
        doc/CHANGES: patch
        usr.sbin/Makefile: revision 1.270
        usr.sbin/service/Makefile: revision 1.1
        usr.sbin/service/service: revision 1.1-1.7
        usr.sbin/service/service.8: revisions 1.1-1.4
Import a substantially modified service(8) command from FreeBSD to
manage rc.d scripts.  This command is well known on most other Unixes
and should help soften the learning curve for Unix admins coming
to NetBSD.
--
Make the usage appear more standard.
--
Sort options. Use An -nosplit in AUTHORS section.
--
Remove -f option as rc_fast is not set in invocation mode.
Do the load_rc_config *after* option parsing.
Catch conflicting -e + -l option specs.
--
Integrate some feedback gleened from tech-userlevel%netbsd.org@localhost
Avoid ls -P so that script can also run pre-netbsd-7.
Make sure /etc/rc.conf.d configurations are supported.
--
cosmetic change in man 8 service
use shell quoting in a safe way as suggested by Alan Barrett
--
More shell quoting.  /etc/rc.d/* file names with embedded spaces are
not expected to work, but let's quote them anyway.

diffstat:

 distrib/sets/lists/base/mi |    3 +-
 distrib/sets/lists/man/mi  |    5 +-
 doc/CHANGES                |    5 +-
 usr.sbin/Makefile          |    5 +-
 usr.sbin/service/Makefile  |    9 ++
 usr.sbin/service/service   |  126 ++++++++++++++++++++++++++++++++
 usr.sbin/service/service.8 |  173 +++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 320 insertions(+), 6 deletions(-)

diffs (truncated from 412 to 300 lines):

diff -r ea2d3eac88f5 -r 2886a2d3c334 distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi        Tue Apr 21 04:55:15 2015 +0000
+++ b/distrib/sets/lists/base/mi        Tue Apr 21 05:22:58 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1087.2.3 2015/01/28 19:00:28 martin Exp $
+# $NetBSD: mi,v 1.1087.2.4 2015/04/21 05:22:58 snj Exp $
 #
 # Note:        Don't delete entries from here - mark them as "obsolete" instead,
 #      unless otherwise stated below.
@@ -1673,6 +1673,7 @@
 ./usr/sbin/scriptdump                          base-obsolete           obsolete
 ./usr/sbin/sdpd                                        base-sysutil-bin
 ./usr/sbin/sendmail                            base-mailwrapper-bin
+./usr/sbin/service                             base-sysutil-bin
 ./usr/sbin/services_mkdb                       base-sysutil-bin
 ./usr/sbin/sesd                                        base-sysutil-bin
 ./usr/sbin/setencstat                          base-sysutil-bin
diff -r ea2d3eac88f5 -r 2886a2d3c334 distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Tue Apr 21 04:55:15 2015 +0000
+++ b/distrib/sets/lists/man/mi Tue Apr 21 05:22:58 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1485.2.6 2015/03/26 10:54:35 martin Exp $
+# $NetBSD: mi,v 1.1485.2.7 2015/04/21 05:22:58 snj Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2943,6 +2943,7 @@
 ./usr/share/man/cat8/sdpd.0                    man-sysutil-catman      .cat
 ./usr/share/man/cat8/security.0                        man-obsolete            obsolete
 ./usr/share/man/cat8/sendmail.0                        man-obsolete            obsolete
+./usr/share/man/cat8/service.0                 man-sysutil-catman      .cat
 ./usr/share/man/cat8/services_mkdb.0           man-sysutil-catman      .cat
 ./usr/share/man/cat8/sesd.0                    man-sysutil-catman      .cat
 ./usr/share/man/cat8/setencstat.0              man-sysutil-catman      .cat
@@ -5739,6 +5740,7 @@
 ./usr/share/man/html8/scsictl.html             man-sysutil-htmlman     html
 ./usr/share/man/html8/sdpd.html                        man-sysutil-htmlman     html
 ./usr/share/man/html8/security.html            man-obsolete            obsolete
+./usr/share/man/html8/service.html             man-sysutil-htmlman     html
 ./usr/share/man/html8/services_mkdb.html       man-sysutil-htmlman     html
 ./usr/share/man/html8/sesd.html                        man-sysutil-htmlman     html
 ./usr/share/man/html8/setencstat.html          man-sysutil-htmlman     html
@@ -8821,6 +8823,7 @@
 ./usr/share/man/man8/sdpd.8                    man-sysutil-man         .man
 ./usr/share/man/man8/security.8                        man-obsolete            obsolete
 ./usr/share/man/man8/sendmail.8                        man-obsolete            obsolete
+./usr/share/man/man8/service.8                 man-sysutil-man         .man
 ./usr/share/man/man8/services_mkdb.8           man-sysutil-man         .man
 ./usr/share/man/man8/sesd.8                    man-sysutil-man         .man
 ./usr/share/man/man8/setencstat.8              man-sysutil-man         .man
diff -r ea2d3eac88f5 -r 2886a2d3c334 doc/CHANGES
--- a/doc/CHANGES       Tue Apr 21 04:55:15 2015 +0000
+++ b/doc/CHANGES       Tue Apr 21 05:22:58 2015 +0000
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:                   <$Revision: 1.1967.2.11 $>
+# LIST OF CHANGES FROM LAST RELEASE:                   <$Revision: 1.1967.2.12 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -21,7 +21,7 @@
 #
 # See htutils/changes/changes2html script for more details.
 #
-LIST OF CHANGES FROM PREVIOUS RELEASES:                        <$Revision: 1.1967.2.11 $>
+LIST OF CHANGES FROM PREVIOUS RELEASES:                        <$Revision: 1.1967.2.12 $>
 
 
 Changes from NetBSD 6.0 to NetBSD 7.0:
@@ -523,3 +523,4 @@
                processed sooner. [tls 20141026]
        viornd(4):      Add driver for VirtIO entropy source available on
                QEMU, KVM, and Google Compute Engine.  From OpenBSD.
+       service(8): Import adapted script from FreeBSD [ast 20150322]
diff -r ea2d3eac88f5 -r 2886a2d3c334 usr.sbin/Makefile
--- a/usr.sbin/Makefile Tue Apr 21 04:55:15 2015 +0000
+++ b/usr.sbin/Makefile Tue Apr 21 05:22:58 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.269 2014/07/26 19:32:37 dholland Exp $
+#      $NetBSD: Makefile,v 1.269.2.1 2015/04/21 05:22:58 snj Exp $
 #      from: @(#)Makefile      5.20 (Berkeley) 6/12/93
 
 .include <bsd.own.mk>
@@ -24,7 +24,8 @@
        quot quotacheck quotaon quotarestore \
        rarpd rbootd rdate repquota rmt rpc.bootparamd rpc.lockd \
        rpc.pcnfsd rpc.statd rpcbind rwhod \
-       sa screenblank sdpd services_mkdb sesd schedctl sliplogin spray \
+       sa screenblank sdpd service services_mkdb sesd schedctl \
+       sliplogin spray \
        srtconfig sti sunlabel sup sysinst syslogd \
        tadpolectl tcpdchk tcpdmatch tcpdrop timed tpctl tprof traceroute trpt \
        unlink usbdevs user \
diff -r ea2d3eac88f5 -r 2886a2d3c334 usr.sbin/service/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/service/Makefile Tue Apr 21 05:22:58 2015 +0000
@@ -0,0 +1,9 @@
+# $NetBSD: Makefile,v 1.1.2.2 2015/04/21 05:22:58 snj Exp $
+
+FILES=         service
+MAN=           service.8
+
+FILESDIR=      /usr/sbin
+FILESMODE=     ${BINMODE}
+
+.include <bsd.prog.mk>
diff -r ea2d3eac88f5 -r 2886a2d3c334 usr.sbin/service/service
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/service/service  Tue Apr 21 05:22:58 2015 +0000
@@ -0,0 +1,126 @@
+#!/bin/sh
+#    $NetBSD: service,v 1.7.2.2 2015/04/21 05:22:58 snj Exp $
+#    service -- run or list system services
+#
+#  Taken from FreeBSD: releng/10.1/usr.sbin/service/service.sh 268098
+#  Modified for NetBSD by Adrian Steinmann in March, 2015
+#
+#  Copyright (c) 2009 Douglas Barton
+#  All rights reserved.
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#  1. Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+#  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+#  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+#  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+#  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+#  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+#  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+#  SUCH DAMAGE.
+
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+usage ()
+{
+    local me="${0##*/}"
+    echo "usage: ${me} [-elv]"
+    echo "       ${me} [-ev] rc_script_name [rc_script_name2 [...]]"
+    echo "       ${me} [-v] rc_script_name action"
+    echo "       -e: List enabled scripts; check if given scripts are enabled"
+    echo "       -l: List all scripts in rcorder"
+    echo "       -v: Verbose (mention in which directory script is found)"
+    echo "rc_directories is currently set to ${rc_directories}"
+    exit 1
+}
+
+# list all files in rc_directories with absolute pathnames
+# written to be compatible with ls(1) from pre netbsd-7
+_rc_files()
+{
+    local _d _f
+    for _d in ${rc_directories}; do
+         if [ -d "$_d" ]; then
+             for _f in "$_d"/*; do
+                 [ -f "$_f" -a -x "$_f" ] && echo "$_f"
+             done
+         fi
+    done | xargs rcorder -s nostart ${rc_rcorder_flags} 2>/dev/null
+    return 0
+}
+
+while getopts elv o; do
+    case "$o" in
+        e) ENABLED=1 ;;
+        l) LIST=1 ;;
+        v) VERBOSE=1 ;;
+        *) usage ;;
+    esac
+done
+shift $( expr $OPTIND - 1 )
+
+[ -n "${ENABLED}" -a -n "${LIST}" ] && usage
+
+. /etc/rc.subr
+load_rc_config :
+
+if [ -n "${ENABLED}" ]; then
+    [ -n "${VERBOSE}" ] && echo "rc_directories is ${rc_directories}" >&2
+    flt=cat
+    if [ $# -gt 0 ]
+    then
+        flt=$( echo $* | sed -e 's; ;|;g' -e 's;^;egrep /(;' -e 's;$;)$;' )
+    fi
+    _rc_files | $flt | while read file
+    do
+        if grep -q ^rcvar "$file"; then
+            eval $( grep ^name= "$file" )
+            eval $( grep ^rcvar "$file" )
+            if [ -n "${rcvar}" ]; then
+                load_rc_config ${rcvar}
+                checkyesno ${rcvar} 2>/dev/null && echo ${file}
+            fi
+        fi
+    done
+    exit 0
+fi
+
+if [ -n "${LIST}" ]; then
+    [ -n "${VERBOSE}" ] && echo "rc_directories is ${rc_directories}" >&2
+    _rc_files
+    exit 0
+fi
+
+if [ $# -eq 2 ]; then
+    script=$1
+    arg=$2
+else
+    usage
+fi
+
+for dir in ${rc_directories}; do
+    if [ -x "${dir}/${script}" ]; then
+        [ -n "${VERBOSE}" ] && echo "${script} is located in ${dir}" >&2
+        # run as in /etc/rc
+        cd /
+        umask 022
+        exec env -i \
+            HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin \
+                "${dir}/${script}" "${arg}"
+        echo "Failed to exec ${dir}/${script} ${arg}" >&2
+        exit 255
+    fi
+done
+
+echo "${script} does not exist in ${rc_directories}" >&2
+exit 1
diff -r ea2d3eac88f5 -r 2886a2d3c334 usr.sbin/service/service.8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/service/service.8        Tue Apr 21 05:22:58 2015 +0000
@@ -0,0 +1,173 @@
+.\"    $NetBSD: service.8,v 1.4.2.2 2015/04/21 05:22:58 snj Exp $
+.\"
+.\" Copyright (c) 2009 Douglas Barton
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd March 20, 2015
+.Dt SERVICE 8
+.Os
+.Sh NAME
+.Nm service
+.Nd run or list system services
+.Sh SYNOPSIS
+.Nm
+.Op Fl elv
+.Nm
+.Op Fl ev
+.Ar rc_script_name1 Op Ar rc_script_name2 Op Ar ...
+.Nm
+.Op Fl v
+.Ar rc_script_name action
+.Sh DESCRIPTION
+The
+.Nm
+command is a simple interface to the services startup system.
+.Pp
+Its purpose is to list the services or invoke actions on them
+as provided by the
+.Ev rc.d
+scripts.
+When used to invoke
+.Ev rc.d
+scripts,
+.Nm
+will set the same environment that is used at boot time.
+.Pp
+The options are as follows:
+.Bl -tag -width F1
+.It Fl e
+List services that are enabled.
+The list of scripts is compiled using



Home | Main Index | Thread Index | Old Index