From owner-svn-src-all@FreeBSD.ORG Wed Dec 12 01:50:59 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0D11DE3E; Wed, 12 Dec 2012 01:50:59 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E65918FC08; Wed, 12 Dec 2012 01:50:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qBC1owhq036377; Wed, 12 Dec 2012 01:50:58 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qBC1owJt036375; Wed, 12 Dec 2012 01:50:58 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201212120150.qBC1owJt036375@svn.freebsd.org> From: Xin LI Date: Wed, 12 Dec 2012 01:50:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r244132 - head/usr.sbin/service X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Dec 2012 01:50:59 -0000 Author: delphij Date: Wed Dec 12 01:50:58 2012 New Revision: 244132 URL: http://svnweb.freebsd.org/changeset/base/244132 Log: Add -R, an option to restart all enabled "local" services. Discussed on: -rc@ (in September) MFC after: 2 months Modified: head/usr.sbin/service/service.8 head/usr.sbin/service/service.sh Modified: head/usr.sbin/service/service.8 ============================================================================== --- head/usr.sbin/service/service.8 Wed Dec 12 01:05:19 2012 (r244131) +++ head/usr.sbin/service/service.8 Wed Dec 12 01:50:58 2012 (r244132) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 26, 2009 +.Dd December 11, 2012 .Dt SERVICE 8 .Os .Sh NAME @@ -34,6 +34,8 @@ .Nm .Fl e .Nm +.Fl R +.Nm .Op Fl v .Fl l | r .Nm @@ -62,6 +64,8 @@ then that list of scripts is checked for .Qq rcvar assignment. If present the script is checked to see if it is enabled. +.It Fl R +Restart all enabled local services. .It Fl l List all files in .Pa /etc/rc.d Modified: head/usr.sbin/service/service.sh ============================================================================== --- head/usr.sbin/service/service.sh Wed Dec 12 01:05:19 2012 (r244131) +++ head/usr.sbin/service/service.sh Wed Dec 12 01:50:58 2012 (r244132) @@ -33,29 +33,58 @@ usage () { echo '' echo 'Usage:' echo "${0##*/} -e" + echo "${0##*/} -R" echo "${0##*/} [-v] -l | -r" echo "${0##*/} [-v] start|stop|etc." echo "${0##*/} -h" echo '' echo '-e Show services that are enabled' + echo "-R Stop and start enabled $local_startup services" echo "-l List all scripts in /etc/rc.d and $local_startup" echo '-r Show the results of boot time rcorder' echo '-v Verbose' echo '' } -while getopts 'ehlrv' COMMAND_LINE_ARGUMENT ; do +while getopts 'ehlrRv' COMMAND_LINE_ARGUMENT ; do case "${COMMAND_LINE_ARGUMENT}" in e) ENABLED=eopt ;; h) usage ; exit 0 ;; l) LIST=lopt ;; r) RCORDER=ropt ;; + R) RESTART=Ropt ;; v) VERBOSE=vopt ;; *) usage ; exit 1 ;; esac done shift $(( $OPTIND - 1 )) +if [ -n "$RESTART" ]; then + skip="-s nostart" + if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then + skip="$skip -s nojail" + fi + [ -n "$local_startup" ] && find_local_scripts_new + files=`rcorder ${skip} ${local_rc} 2>/dev/null` + + for file in `reverse_list ${files}`; do + if grep -q ^rcvar $file; then + eval `grep ^name= $file` + eval `grep ^rcvar $file` + checkyesno $rcvar 2>/dev/null && run_rc_script ${file} stop + fi + done + for file in $files; do + if grep -q ^rcvar $file; then + eval `grep ^name= $file` + eval `grep ^rcvar $file` + checkyesno $rcvar 2>/dev/null && run_rc_script ${file} start + fi + done + + exit 0 +fi + if [ -n "$ENABLED" -o -n "$RCORDER" ]; then # Copied from /etc/rc skip="-s nostart"