Date: Wed, 12 Dec 2012 01:50:58 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r244132 - head/usr.sbin/service Message-ID: <201212120150.qBC1owJt036375@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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] <rc.d script> 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"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212120150.qBC1owJt036375>