From owner-svn-src-head@freebsd.org Sun May 27 10:48:22 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E030EFE6C5; Sun, 27 May 2018 10:48:22 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 413AF7B5AE; Sun, 27 May 2018 10:48:22 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1D6CB1D76B; Sun, 27 May 2018 10:48:22 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4RAmL14028267; Sun, 27 May 2018 10:48:21 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4RAmLcQ028266; Sun, 27 May 2018 10:48:21 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201805271048.w4RAmLcQ028266@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 27 May 2018 10:48:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334254 - head/etc/rc.d X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: head/etc/rc.d X-SVN-Commit-Revision: 334254 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 May 2018 10:48:22 -0000 Author: trasz Date: Sun May 27 10:48:21 2018 New Revision: 334254 URL: https://svnweb.freebsd.org/changeset/base/334254 Log: Make the cfumass rc script support USB template 10. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Modified: head/etc/rc.d/cfumass Modified: head/etc/rc.d/cfumass ============================================================================== --- head/etc/rc.d/cfumass Sun May 27 06:47:09 2018 (r334253) +++ head/etc/rc.d/cfumass Sun May 27 10:48:21 2018 (r334254) @@ -45,7 +45,7 @@ remove_luns() cfumass_start() { - local err _files _template + local err _files _template _new_template if [ ! -d "${cfumass_dir}" ]; then warn "${cfumass_dir} does not exist" @@ -90,36 +90,59 @@ cfumass_start() fi fi + # Set the template number based on the current one. _template=`sysctl -n hw.usb.template` - if [ "${_template}" -lt 0 ]; then - sysctl hw.usb.template=0 > /dev/null + case "${_template}" in + -1) + _new_template="0" + ;; + 8) + _new_template="10" + ;; + *) + warn "hw.usb.template sysctl set to neither -1 nor 8; not changing" + _new_template="" + ;; + esac + + if [ -n "${_new_template}" ]; then + sysctl hw.usb.template="${_new_template}" > /dev/null err=$? if [ "${err}" -ne 0 ]; then - warn "unable to set hw.usb.template sysctl" + warn "unable to set hw.usb.template sysctl to ${_new_template}" return "${err}" fi - else - # Otherwise don't touch the sysctl - we could lock the user - # out of the machine otherwise. - warn "hw.usb.template sysctl set to neither -1 nor 0" fi } cfumass_stop() { - local err _template + local err _template _new_template + remove_luns + _template=`sysctl -n hw.usb.template` - if [ "${_template}" -eq 0 ]; then - sysctl hw.usb.template=-1 > /dev/null + case "${_template}" in + 0) + _new_template="-1" + ;; + 10) + _new_template="8" + ;; + *) + warn "hw.usb.template sysctl set to neither 0 nor 10; not changing" + _new_template="" + ;; + esac + + if [ -n "${_new_template}" ]; then + sysctl hw.usb.template="${_new_template}" > /dev/null err=$? if [ "${err}" -ne 0 ]; then - warn "unable to set hw.usb.template sysctl" + warn "unable to set hw.usb.template sysctl to ${_new_template}" return "${err}" fi fi - - remove_luns } load_rc_config $name