From owner-freebsd-hackers@freebsd.org Sun Aug 23 22:13:16 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8C5CC9BF661 for ; Sun, 23 Aug 2015 22:13:16 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 429EE163 for ; Sun, 23 Aug 2015 22:13:16 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.84 (FreeBSD)) (envelope-from ) id 1ZTdVo-000GVs-MJ for freebsd-hackers@FreeBSD.org; Mon, 24 Aug 2015 01:13:12 +0300 Date: Mon, 24 Aug 2015 01:13:12 +0300 From: Slawa Olhovchenkov To: freebsd-hackers@FreeBSD.org Subject: How to application sample profiling? Message-ID: <20150823221312.GD21849@zxy.spb.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2015 22:13:16 -0000 I have multi-thread application fully utilise all CPU cores. I am need to determine lines give mostly CPU loads. How I can do this? `pmcstat -P BU_CPU_CLK_UNHALTED -t application_pid -n 500000 -O sample.out` consume to many CPU (performance drop x100 times) and mostly show himself in kernel and pmc locks and none for application. pmcstat -S BU_CPU_CLK_UNHALTED -- same here. From owner-freebsd-hackers@freebsd.org Mon Aug 24 08:23:35 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 41D3F9BF7B0 for ; Mon, 24 Aug 2015 08:23:35 +0000 (UTC) (envelope-from noname.esst@yahoo.com) Received: from nm6.bullet.mail.ne1.yahoo.com (nm6.bullet.mail.ne1.yahoo.com [98.138.90.69]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 08C371D18 for ; Mon, 24 Aug 2015 08:23:34 +0000 (UTC) (envelope-from noname.esst@yahoo.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1440404223; bh=Fwn7qNF52nva9cOF438s+lgcLJ2q+/KWmjcGXNPxKmg=; h=Date:From:Reply-To:To:Subject:From:Subject; b=facpHqGgpQehUr9KBaQxWvSJPsgoc7fia+0SOWzTp+KxOPwx5C215n7xkZO16taSSDsm+jCoTcyaicgPBSOiU6OZzBWmYy21058NgyZ+MSBjAEHb5R7KRROd3icAKsD3KIETRl0p7F8QFFHsMeYK0GA74/tvbfo4m+IjrHOChQ3T1PdkK3kCVZV03VuT1PjchJJSIq1+MiBmVQ+E13FNxsusEpuUZgpPNa0SdNWV1O4wXTVsrmDTzdpnfu8NJuZJx7LzbD/FvdXCoTHDmbL3homkGRfO7H3ZZ84o2jFWDz5+TuxyIvEoxchrYh6iAkn37102JL1tVe4lnhXJ7HzlQQ== Received: from [98.138.100.103] by nm6.bullet.mail.ne1.yahoo.com with NNFMP; 24 Aug 2015 08:17:03 -0000 Received: from [98.138.89.169] by tm102.bullet.mail.ne1.yahoo.com with NNFMP; 24 Aug 2015 08:17:03 -0000 Received: from [127.0.0.1] by omp1025.mail.ne1.yahoo.com with NNFMP; 24 Aug 2015 08:17:03 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 157056.3041.bm@omp1025.mail.ne1.yahoo.com X-YMail-OSG: 0DFkF94VM1mcNMV.ZRtmpkjuVikTAGf7dMseeQ1zcvvtn4ILzGJ8D9z8_FqfAnh DzDmEN3x0xM8n1THPBGVqnLNQpPLRsmfpbsFqglRuxWbrxDse8IJv3iELtly62oiSv7MxdcnG6Wu I6vkPf29rSPB7cKMwPaMfx2wJKmTOeZJlViGjZY_jFyS8AZxJK.iBLqiCrGtQnk7LfdrRqeFoNdO AkFo37_SN_qzb41P5UbieSyu2fZWgglXPGjcIv1X3iBQ53edZWioWgIk3PkqAXw4Sou67No9STb8 Sx2rH99_pQ8lqqTpO8Se6OPZMGN7go3Lj5rvorSbD_Blt7At3vDEnJzAwqKzBuCj7ineoPDcDafx Q2S17.850YRnxoqkIwmPVPcIua5Z6JMrvWbA9mGX_2S8Gq_QkLziZatTVvrDSIC3OOOTcjgJozS2 5ld7aFfufPzs2T4XL7d4cMty.f97Y6vEIGGM77QzCZAHh2iY8bqMPmEsmGLWnoCbWK670j.w729s PspeVGRYmKRSM9w-- Received: by 98.138.101.164; Mon, 24 Aug 2015 08:17:02 +0000 Date: Mon, 24 Aug 2015 08:17:02 +0000 (UTC) From: Nomad Esst Reply-To: Nomad Esst To: "freebsd-drivers@freebsd.org" , Freebsd Hackers List Message-ID: <1473579278.716147.1440404222458.JavaMail.yahoo@mail.yahoo.com> Subject: Get pci slot number in driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2015 08:23:35 -0000 Is it possible to find out the pci slot number on which the card is mounted in driver? I tried pci_get_slot but it's always 0.Any ideas about doing this? regards From owner-freebsd-hackers@freebsd.org Mon Aug 24 15:19:01 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CAE7E9C0528; Mon, 24 Aug 2015 15:19:01 +0000 (UTC) (envelope-from jim.harris@gmail.com) Received: from mail-ob0-x22e.google.com (mail-ob0-x22e.google.com [IPv6:2607:f8b0:4003:c01::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 92B65E8D; Mon, 24 Aug 2015 15:19:01 +0000 (UTC) (envelope-from jim.harris@gmail.com) Received: by obbhe7 with SMTP id he7so116106716obb.0; Mon, 24 Aug 2015 08:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=LMBtQDc0jiAykPZLO6qyhd9WfY4trce0mp1qZvLrDpQ=; b=Wbp0drf7Cvh0NuBqu+Mv9dUP6GzUUNRFOC6LGPNXU0tYYEkOTCwUMI7xox7E+hi3kH 9/puZnBBz7AtLE6R7UsvPowxrzI7gfSjNVoF5chGHHevz5IHOqrBVysDiEm7EcfFWGo3 5ri/zoyfG8rhMa8p6T+tGRsOPPzTQex7t/NHIImxYxiH1/NbhOYyaWkshuvAWgGrgEwu LfCwsXVtHOjq/6eDwKUiEZCDsfS5ttmq7jB1JoOOBZW45rlReQt3W/TTIWZGTrhkpa+f iB1nPahZV/i6g8iw4IQuNTlFYo6BhYhpLTybhPBPCP0Pv4lZH2/GivaZKGCCJJp0fGnH vZOw== MIME-Version: 1.0 X-Received: by 10.182.33.38 with SMTP id o6mr21072474obi.41.1440429540928; Mon, 24 Aug 2015 08:19:00 -0700 (PDT) Received: by 10.202.212.76 with HTTP; Mon, 24 Aug 2015 08:19:00 -0700 (PDT) In-Reply-To: <1473579278.716147.1440404222458.JavaMail.yahoo@mail.yahoo.com> References: <1473579278.716147.1440404222458.JavaMail.yahoo@mail.yahoo.com> Date: Mon, 24 Aug 2015 08:19:00 -0700 Message-ID: Subject: Re: Get pci slot number in driver From: Jim Harris To: Nomad Esst Cc: "freebsd-drivers@freebsd.org" , Freebsd Hackers List Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2015 15:19:02 -0000 On Mon, Aug 24, 2015 at 1:17 AM, Nomad Esst via freebsd-drivers < freebsd-drivers@freebsd.org> wrote: > Is it possible to find out the pci slot number on which the card is > mounted in driver? I tried pci_get_slot but it's always 0.Any ideas about > doing this? > regards > What do the PCI bus, slot, and function numbers for this device show up as in "pciconf -l" output? For PCI Express endpoints, the PCI slot number (also sometimes referred to as PCI device number) is typically 0. These endpoints are more typically differentiated by their PCI bus number, not slot number. -Jim _______________________________________________ > freebsd-drivers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-drivers > To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org" > From owner-freebsd-hackers@freebsd.org Mon Aug 24 17:20:28 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3ED809C111A; Mon, 24 Aug 2015 17:20:28 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "gold.funkthat.com", Issuer "gold.funkthat.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 21AF4ECB; Mon, 24 Aug 2015 17:20:26 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (localhost [127.0.0.1]) by gold.funkthat.com (8.14.5/8.14.5) with ESMTP id t7OHKP3G000590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 24 Aug 2015 10:20:25 -0700 (PDT) (envelope-from jmg@gold.funkthat.com) Received: (from jmg@localhost) by gold.funkthat.com (8.14.5/8.14.5/Submit) id t7OHKPHs000589; Mon, 24 Aug 2015 10:20:25 -0700 (PDT) (envelope-from jmg) Date: Mon, 24 Aug 2015 10:20:25 -0700 From: John-Mark Gurney To: Nomad Esst Cc: "freebsd-drivers@freebsd.org" , Freebsd Hackers List Subject: Re: Get pci slot number in driver Message-ID: <20150824172025.GI33167@funkthat.com> References: <1473579278.716147.1440404222458.JavaMail.yahoo@mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1473579278.716147.1440404222458.JavaMail.yahoo@mail.yahoo.com> X-Operating-System: FreeBSD 9.1-PRERELEASE amd64 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? User-Agent: Mutt/1.5.21 (2010-09-15) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (gold.funkthat.com [127.0.0.1]); Mon, 24 Aug 2015 10:20:25 -0700 (PDT) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2015 17:20:28 -0000 Nomad Esst via freebsd-drivers wrote this message on Mon, Aug 24, 2015 at 08:17 +0000: > Is it possible to find out the pci slot number on which the card is mounted in driver? I tried pci_get_slot but it's always 0.Any ideas about doing this? > regards Are these PCIe add in cards? If so, check pciconv -lv, but most PCIe cards are slot 0 of the bus... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." From owner-freebsd-hackers@freebsd.org Mon Aug 24 22:48:32 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4453D9C22A1; Mon, 24 Aug 2015 22:48:32 +0000 (UTC) (envelope-from zbeeble@gmail.com) Received: from mail-yk0-x234.google.com (mail-yk0-x234.google.com [IPv6:2607:f8b0:4002:c07::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 08C081D69; Mon, 24 Aug 2015 22:48:32 +0000 (UTC) (envelope-from zbeeble@gmail.com) Received: by ykdt205 with SMTP id t205so138578677ykd.1; Mon, 24 Aug 2015 15:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=Lv2RVK9bi4UGneUdLDERC6txUijjI1MAePidQ2FWx9s=; b=exUCuhn2wkcVRgC/EX6HjTQl9A5NHUS+ECzFpWMod77OOOA2o1U9GbnnHoDDnxG9Cc gyzvh1dj0GTuH3brPTZqB96D+U15+JEt5eib3V6HobnmfTFXRYo7fzjh5GEo030X4qBS y5yHmhfqS136uX+LEigm6jIbos5cm4hfN1uxANW7vObCuxcM1Fd/WPrkYxkjSbi85rrR Vd2/fbOJvRdKXDhabX159hMxLPLAU5sUQCbGVBccxFOnc/W8QtpgoadXiSlgkJrAq162 wbqg8i3qnMzMNOxbpp3jni/DViShaRmgJHYiZ6cb6W9Z5xgFsHFO+Qqfc3AmZI0Uk68r KhYA== MIME-Version: 1.0 X-Received: by 10.129.131.84 with SMTP id t81mr33163650ywf.97.1440456511111; Mon, 24 Aug 2015 15:48:31 -0700 (PDT) Received: by 10.37.52.22 with HTTP; Mon, 24 Aug 2015 15:48:31 -0700 (PDT) Date: Mon, 24 Aug 2015 18:48:31 -0400 Message-ID: Subject: FreeBSD not properly padding vlan packets on several interface types. From: Zaphod Beeblebrox To: FreeBSD Net , FreeBSD Hackers Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2015 22:48:32 -0000 So, as background, the minimum packet size for ethernet packets is 64 bytes. According to at least cisco, the minimum size, then, for 802.1q (vlan, etc) packets is 68 bytes. On at least BGE and BCE interfaces, it seems (according to counters on my switch) that FreeBSD doesn't honour this. "show interface counters error" is the cisco command to check. From owner-freebsd-hackers@freebsd.org Mon Aug 24 23:04:55 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DEA319C28E1; Mon, 24 Aug 2015 23:04:54 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9B3361669; Mon, 24 Aug 2015 23:04:54 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.84 (FreeBSD)) (envelope-from ) id 1ZU0nM-0005iZ-9r; Tue, 25 Aug 2015 02:04:52 +0300 Date: Tue, 25 Aug 2015 02:04:52 +0300 From: Slawa Olhovchenkov To: Zaphod Beeblebrox Cc: FreeBSD Net , FreeBSD Hackers Subject: Re: FreeBSD not properly padding vlan packets on several interface types. Message-ID: <20150824230452.GG21849@zxy.spb.ru> References: MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2015 23:04:55 -0000 On Mon, Aug 24, 2015 at 06:48:31PM -0400, Zaphod Beeblebrox wrote: > So, as background, the minimum packet size for ethernet packets is 64 > bytes. According to at least cisco, the minimum size, then, for 802.1q > (vlan, etc) packets is 68 bytes. On at least BGE and BCE interfaces, it > seems (according to counters on my switch) that FreeBSD doesn't honour this. > > "show interface counters error" is the cisco command to check. C.4.4 Padding and frame size considerations C.4.4.1 Treatment of PAD fields in IEEE Std 802.3 frames The minimum frame size constraint placed on IEEE 802.3/Ethernet frames requires frames to carry zero or more pad octets following the MAC client data, in order to ensure that no frame of total length less than 64 octets is transmitted on the medium. This requirement means that frames whose overall length would otherwise be less than 64 octets in length have (64-len) octets of padding added after the MAC client data, where len is the size of the frame before padding. When tagged frames are transmitted by a Bridge on an IEEE Std 802.3 MAC, there are two permissible approaches (7.2), as follows: a) Keep the minimum frame size generated by the Bridge equal to 64 octets. This implies that the number of pad octets in a received untagged IEEE Std 802.3 frame would be reduced by up to 4 octets when that frame was tagged; b) Adopt a minimum tagged frame length of 68 octets. This implies that the number of pad octets in a received untagged IEEE Std 802.3 frame would not be adjusted when tagging such frames; equally, if subsequently untagged, no pad adjustment would be necessary before transmission on IEEE 802.3/Ethernet. C.4.4.2 Maximum PDU size VLAN tagging of an untagged frame, or relaying frames in tagged frame format, can result in an increase in the length of the original frame. If transmission of a given frame in tagged frame format through a given destination Port would result in violation of the maximum PDU size for the destination MAC method, the Bridge discards the frame for that destination Port. NOTE-Violation of the maximum PDU sizes for destination MAC methods can produce undefined results in networks that contain devices that adhere strictly to these maxima, or in MAC methods where these maxima are inherently constrained by the operation of the MAC method itself (e.g., constrained by timing considerations in the MAC state machines). IEEE Std 802.3ac-1998 defines an extension to the normal IEEE 802.3 maximum frame size for the specific purpose of accommodating the additional octets of the VLAN tag header. The example frame translations in this annex make use of this extension to the IEEE 802.3 frame size. C.4.4.3 Minimum PDU size VLAN untagging of a tagged frame results in the original frame decreasing in length. Where the destination MAC is CSMA/CD: a) If untagging a given frame would result in violation of the minimum frame length requirements of CSMA/CD, the Bridge is required to adjust the PAD field to ensure that the frame length equals the minimum length of 64 octets (7.2 and C.4.4.1); b) If a frame is transmitted in tagged frame format, the Bridge may adopt a minimum tagged frame length of either 64 or 68 octets, as an implementation option. If the latter is chosen, the Bridge adjusts the size of the PAD field on transmission for any tagged frame that is less than 68 octets in length (7.2, C.4.4.1). From owner-freebsd-hackers@freebsd.org Wed Aug 26 08:49:13 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31ED499AC28 for ; Wed, 26 Aug 2015 08:49:13 +0000 (UTC) (envelope-from ganael.laplanche@corp.ovh.com) Received: from 5.mo174.mail-out.ovh.net (5.mo174.mail-out.ovh.net [46.105.34.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EB511E5C for ; Wed, 26 Aug 2015 08:49:12 +0000 (UTC) (envelope-from ganael.laplanche@corp.ovh.com) Received: from MBX001.OVH.local (corp.ovh.com [5.196.251.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mo174.mail-out.ovh.net (Postfix) with ESMTPS id 5830EFF8094; Wed, 26 Aug 2015 10:42:48 +0200 (CEST) Received: from desk533202.ovh.net (5.196.2.34) by MBX001.OVH.local (172.16.2.1) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Wed, 26 Aug 2015 09:41:59 +0100 From: Ganael Laplanche Organization: OVH To: Subject: Re: EFI ZFS loader success story Date: Wed, 26 Aug 2015 10:42:47 +0200 User-Agent: KMail/1.13.7 (Linux/3.2.0-4-amd64; KDE/4.8.4; x86_64; ; ) CC: Eric McCorkle References: <201508121139.40852.ganael.laplanche@corp.ovh.com> In-Reply-To: <201508121139.40852.ganael.laplanche@corp.ovh.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-ID: <201508261042.47680.ganael.laplanche@corp.ovh.com> X-Originating-IP: [5.196.2.34] X-ClientProxiedBy: cas01.OVH.local (172.16.1.1) To MBX001.OVH.local (172.16.2.1) X-C2ProcessedOrg: adf1d41a-9ee8-48fd-a72d-f604a03a8e62 X-Ovh-Tracer-Id: 8937393462334831144 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeekfedrieduucetufdoteggucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2015 08:49:13 -0000 On Wednesday, August 12, 2015 11:39:40 AM Ganael Laplanche wrote: Hi, > Prepare the EFI partition : > --------------------------- > [...] > # cat > /mnt/boot/loader.rc << EOF > unload > set currdev=3Dzfs:root/ROOT/default: > load boot/kernel/kernel > load boot/kernel/zfs.ko > autoboot > EOF > [...] =46YI, I've faced a problem today with the configuration above : loading th= e=20 kernel with a *relative* path leads to kern.bootfile being defined as=20 "boot/kernel/kernel" (instead of "/boot/kernel/kernel") ; as a consequence,= =20 freebsd-update exits with the following error : "Cannot identify running=20 kernel". It is much better to use absolute file names within loader.rc, so the above= =20 paragraph should be re-written this way : # cat > /mnt/boot/loader.rc << EOF unload set currdev=3Dzfs:root/ROOT/default: load /boot/kernel/kernel load /boot/kernel/zfs.ko autoboot EOF Best regards, =2D-=20 Gana=EBl LAPLANCHE From owner-freebsd-hackers@freebsd.org Wed Aug 26 20:25:36 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 982E09C33EB for ; Wed, 26 Aug 2015 20:25:36 +0000 (UTC) (envelope-from stas@freebsd.org) Received: from mx0.deglitch.com (cl-414.sto-01.se.sixxs.net [IPv6:2001:16d8:ff00:19d::2]) by mx1.freebsd.org (Postfix) with ESMTP id 583F3DC1 for ; Wed, 26 Aug 2015 20:25:36 +0000 (UTC) (envelope-from stas@freebsd.org) Received: from [172.27.138.58] (unknown [199.201.64.131]) by mx0.deglitch.com (Postfix) with ESMTPSA id 0D3B28FC27; Thu, 27 Aug 2015 00:25:29 +0400 (MSK) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: How to application sample profiling? From: Stanislav Sedov In-Reply-To: <20150823221312.GD21849@zxy.spb.ru> Date: Wed, 26 Aug 2015 13:25:25 -0700 Cc: freebsd-hackers@FreeBSD.org Content-Transfer-Encoding: 7bit Message-Id: <9BFE7A4D-CCA3-4B44-9E2D-F6F7DAB78F07@freebsd.org> References: <20150823221312.GD21849@zxy.spb.ru> To: Slawa Olhovchenkov X-Mailer: Apple Mail (2.2104) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2015 20:25:36 -0000 > On Aug 23, 2015, at 3:13 PM, Slawa Olhovchenkov wrote: > > I have multi-thread application fully utilise all CPU cores. > I am need to determine lines give mostly CPU loads. > How I can do this? > > `pmcstat -P BU_CPU_CLK_UNHALTED -t application_pid -n 500000 -O sample.out` > consume to many CPU (performance drop x100 times) and mostly show > himself in kernel and pmc locks and none for application. > pmcstat -S BU_CPU_CLK_UNHALTED -- same here. > Did you try something like `pmcstat -S instructions -T` by any chance? That should give some quick clues as to which functions are being hot at least. Which FreeBSD version are you using by the way? -- Stanislav Sedov ST4096-RIPE From owner-freebsd-hackers@freebsd.org Wed Aug 26 20:41:28 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A164C9C39AC for ; Wed, 26 Aug 2015 20:41:28 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5F059862; Wed, 26 Aug 2015 20:41:28 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.84 (FreeBSD)) (envelope-from ) id 1ZUhVd-000Cg5-RV; Wed, 26 Aug 2015 23:41:25 +0300 Date: Wed, 26 Aug 2015 23:41:25 +0300 From: Slawa Olhovchenkov To: Stanislav Sedov Cc: freebsd-hackers@FreeBSD.org Subject: Re: How to application sample profiling? Message-ID: <20150826204125.GK21849@zxy.spb.ru> References: <20150823221312.GD21849@zxy.spb.ru> <9BFE7A4D-CCA3-4B44-9E2D-F6F7DAB78F07@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9BFE7A4D-CCA3-4B44-9E2D-F6F7DAB78F07@freebsd.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2015 20:41:28 -0000 On Wed, Aug 26, 2015 at 01:25:25PM -0700, Stanislav Sedov wrote: > > > On Aug 23, 2015, at 3:13 PM, Slawa Olhovchenkov wrote: > > > > I have multi-thread application fully utilise all CPU cores. > > I am need to determine lines give mostly CPU loads. > > How I can do this? > > > > `pmcstat -P BU_CPU_CLK_UNHALTED -t application_pid -n 500000 -O sample.out` > > consume to many CPU (performance drop x100 times) and mostly show > > himself in kernel and pmc locks and none for application. > > pmcstat -S BU_CPU_CLK_UNHALTED -- same here. > > > > Did you try something like `pmcstat -S instructions -T` by any chance? > That should give some quick clues as to which functions are being hot > at least. I am try '-S instructions' w/o -T, no difference. > Which FreeBSD version are you using by the way? 10-STABLE From owner-freebsd-hackers@freebsd.org Thu Aug 27 13:21:22 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4E3FD9C4C2A for ; Thu, 27 Aug 2015 13:21:22 +0000 (UTC) (envelope-from timp87@gmail.com) Received: from mail-wi0-x231.google.com (mail-wi0-x231.google.com [IPv6:2a00:1450:400c:c05::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D38CE189E; Thu, 27 Aug 2015 13:21:21 +0000 (UTC) (envelope-from timp87@gmail.com) Received: by wicgk12 with SMTP id gk12so9226733wic.1; Thu, 27 Aug 2015 06:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=ts4jY9XINnB077H+M77tIsgB6B6K6lX6kGcJ+8DCkFU=; b=wt81+ueHKGZPNnbtpbJ+gZfhk+2RsqTiROqw90m2UxhlOJNOzrqbDwYiTp0XbfsqMl t7NcfEJ61qml3FyQF/IbDWmX8TUUcb2gO7xvXYJIhZXyb7uMjljmxK4aoSx2c8ZiUOMZ U9iPVne9HSosL1C2a99sTQI1Riv8Pznh2Iq1ppHsSK53idcF+xlkmB8zYPDw6mOPJMsH /wE8K28kNw1ok6i3D3M0J9cKE1Z4IC/K03Nqr0Gs6DUqV29LJa3J3W15RJaE1k50hHi6 phDX9QmxHxPkR6ZYI2a5x0sSW4L2GU7ud+DPJmAPbNfngN6rhqXUMZMsr/8tHAeJt0be Lrpg== MIME-Version: 1.0 X-Received: by 10.194.2.9 with SMTP id 9mr4707641wjq.95.1440681680320; Thu, 27 Aug 2015 06:21:20 -0700 (PDT) Received: by 10.28.9.195 with HTTP; Thu, 27 Aug 2015 06:21:20 -0700 (PDT) Date: Thu, 27 Aug 2015 16:21:20 +0300 Message-ID: Subject: How to control and setup service? From: Pavel Timofeev To: freebsd-hackers@freebsd.org, Devin Teske Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 13:21:22 -0000 Hi! Good day! let me declare something first: HOPE="I just should know about that dir/sruff and hope that nothing will change in future releases"; I'm trying to write some automation code to manipulate services. There is no problem with installing service, I can just use pkg(8) to search/install/remove service. Like following: # pkg install mysql56-server No problem. pkg(8) covers pretty much everything. But I have problems with starting and enabling services. Ok, to start a service we have rc scripts. If it's a base system service then it has rc script in /etc/rc.d dir. If a service is installed from packages (ports) then an rc script is in /usr/local/etc/rc.d dir. So, first, I should check one dir then another. But how can I be sure I'm looking in right directories? Is there any way to ask FreeBSD "Hey! Where is you startup dirs?". I'd say yes, but only partially. /etc/rc.d dir is hardcoded everywhere. So $HOPE, which is not good IMO. "/usr/local/etc/rc.d" is ${local_startup} var which is defined in /etc/defaults/rc.conf. I can actually ask FreeBSD about that by calling: # sh -c '. /etc/rc.subr; load_rc_config "XXX"; echo $local_startup' Good! But in geretal, there is no way to ask FreeBSD for a complete list of startup dirs. So $HOPE. It would be pretty useful if I could ask FreeBSD for one variable like $all_startup, which would contain all of the startup dirs ("/etc/rc.d ${local_startup} ${new_startup_whatever}"). And it would be great if "/etc/rc.d" was defined as variable too. Like ${system_startup}="/etc/rc.d" (which is not simple I believe, it's hardcoded everywhere!). Thank god, there is a alternative way to start/stop services! It's service(8) tool that can do this stuff for me. I can rely on it, because it's a base system tool and I'm sure it knows everything about startup dirs, no matter what FreeBSD release I'm using. IMO service(8) covers this use case. So we can forget my ideas above. Or realize them because it can be useful for such tools like service(8), sysrc(8) or even your_new_tool(8), and code written once would not break in future ;) Ok, imagine I started/stopped service. Then, to enable/disable service I should know a lot of stuff! To enable/disable service first thing that I should know is $rcvar of a service. It can be different than $service name (which is rc script name). I should find rc script in right place, but thank again to service(8) tool. I just can ask it with: # service mysql-server rcvar and get the $rcvar of service, no matter where startup script is. Good! Second thing I should know is if it's already enabled/disabled. # service mysql-server rcvar will output YES/NO besides $rcvar var name. FreeBSD 10 got good command for rc scripts - "enabled", which would answer us by its exit code. # service mysql-server enabled; echo $? Excellent! Third thing I should know is how I have to enable/disable service. How would I do that? Where would I do that? Is it directly disabled (if $sysadmin2 set mysql_enable="NO"), if so - where, or it just not enabled anywhere? How many config files do you know which can be used to enable/disable (control) service? What's their precedence? Well, most of us (probably) would use /etc/rc.conf to enable $service or to check if it's directly disabled. We would use $rcvar (!), not rc script name. But, FreeBSD has more places with higher precedence than /etc/rc.conf! It's /etc/rc.conf.local file, then /etc/rc.conf.d/$service file, then /etc/rc.conf.d/$service/* files. Then even /usr/local/etc/rc.conf.d/$service files and subdirs which appeared in FreeBSD 10! And there is no way to ask FreeBSD "Hey! Where is your config files to control services?". You can ask about them, but again, partially by running: # sh -c '. /etc/rc.subr; load_rc_config "XXX"; echo $rc_conf_files' which outputs "/etc/rc.conf /etc/rc.conf.local". Of course, there is no way to ask "Where this service is enabled/disabled?" So we can catch $rc_conf_files, but not a bunch of rc.conf.d dirs and subdirs. No way. So $HOPE, again, which is not good IMO. Why $HOPE? Because such change already happened between FreeBSD 9 and 10. So I should track such changes in my own code manually. As a way to solve this, I'd like to see some vars like $rc_conf_d_dirs which would point to "/etc/rc.conf.d ${local_startup%/rc.d}/rc.conf.d/". Or any way to get them. Now these dirs are "hardcoded" and used only in /etc/rc.subr here https://github.com/freebsd/freebsd/blob/master/etc/rc.subr#L1336-L1354. It's not used anywhere else. Thank good we have an alternative to this hell of manual editing and going through the list of dirs! You can forget about anything above. I can rely on it, because it's in the base system and I'm sure it knows any cases. It's a ... Hmm, where is it? Turns out, we don't have such tool. We have only sysrc(8), but it can only edit $rc_conf_files in safe way. There is no support for rc.conf.d dirs in sysrc(8). And, in general, it's a tool to just `edit` $rc_conf_files, not to control and configure services. As a user I would love to have a cool tool to control and configure services in way like OpenBSD's rcctl(8) does http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/rcctl.8?query=rcctl. # cooltool set mysql-server status on That's all. It would take care of those things like getting right $rcvar name, choose right rc config file to edit (remember, we have a lot of places to check, see above) and enable service, etc. This $cooltool can be an extended version of service(8) tool. More difficult example: # cooltool set flow_capture status on flags "-e 2200 -n 23 -N 0 -V 5" port "8787" datadir "/storage/flows/all_routers" would enable flow_capture service and set other stuff using right $rcvar. # cooltool get flow_capture would print all of the configured stuff for $service # cooltool get flow_capture status would print only a status YES/NO (don't forget about exit code ;) ) and etc. IMO such tools would be useful even for ansible/puppet and friends. Not just for users ;) I'm really sorry if I misunderstand something and wasted your time! And I don't want to offend anyone in case I'm impolite! P.S. Do you have any ideas? From owner-freebsd-hackers@freebsd.org Thu Aug 27 15:00:12 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E29DF9C42CB for ; Thu, 27 Aug 2015 15:00:11 +0000 (UTC) (envelope-from allanjude@freebsd.org) Received: from mx1.scaleengine.net (mx1.scaleengine.net [209.51.186.6]) by mx1.freebsd.org (Postfix) with ESMTP id C09B41895; Thu, 27 Aug 2015 15:00:11 +0000 (UTC) (envelope-from allanjude@freebsd.org) Received: from [10.1.1.2] (unknown [10.1.1.2]) (Authenticated sender: allanjude.freebsd@scaleengine.com) by mx1.scaleengine.net (Postfix) with ESMTPSA id BB7EB93DB; Thu, 27 Aug 2015 15:00:10 +0000 (UTC) Subject: Re: How to control and setup service? To: freebsd-hackers@freebsd.org References: From: Allan Jude X-Enigmail-Draft-Status: N1110 Cc: Devin Teske Message-ID: <55DF261C.80009@freebsd.org> Date: Thu, 27 Aug 2015 11:00:44 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="rt2TGWE6hHS8NU4XO0fMF1I5NhesBdjdf" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 15:00:12 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rt2TGWE6hHS8NU4XO0fMF1I5NhesBdjdf Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 2015-08-27 09:21, Pavel Timofeev wrote: > Hi! Good day! >=20 > let me declare something first: > HOPE=3D"I just should know about that dir/sruff and hope that nothing > will change in future releases"; >=20 >=20 > I'm trying to write some automation code to manipulate services. > There is no problem with installing service, I can just use pkg(8) to > search/install/remove service. > Like following: > # pkg install mysql56-server > No problem. pkg(8) covers pretty much everything. >=20 >=20 >=20 > But I have problems with starting and enabling services. >=20 >=20 >=20 > Ok, to start a service we have rc scripts. If it's a base system > service then it has rc script in /etc/rc.d dir. > If a service is installed from packages (ports) then an rc script is > in /usr/local/etc/rc.d dir. > So, first, I should check one dir then another. But how can I be sure > I'm looking in right directories? > Is there any way to ask FreeBSD "Hey! Where is you startup dirs?". I'd > say yes, but only partially. >=20 > /etc/rc.d dir is hardcoded everywhere. So $HOPE, which is not good IMO.= >=20 > "/usr/local/etc/rc.d" is ${local_startup} var which is defined in > /etc/defaults/rc.conf. > I can actually ask FreeBSD about that by calling: > # sh -c '. /etc/rc.subr; load_rc_config "XXX"; echo $local_startup' > Good! >=20 > But in geretal, there is no way to ask FreeBSD for a complete list of > startup dirs. So $HOPE. >=20 > It would be pretty useful if I could ask FreeBSD for one variable like > $all_startup, which would contain all of the startup dirs ("/etc/rc.d > ${local_startup} ${new_startup_whatever}"). > And it would be great if "/etc/rc.d" was defined as variable too. Like > ${system_startup}=3D"/etc/rc.d" (which is not simple I believe, it's > hardcoded everywhere!). >=20 >=20 > Thank god, there is a alternative way to start/stop services! > It's service(8) tool that can do this stuff for me. I can rely on it, > because it's a base system tool and I'm sure it knows everything about > startup dirs, no matter what FreeBSD release I'm using. > IMO service(8) covers this use case. > So we can forget my ideas above. > Or realize them because it can be useful for such tools like > service(8), sysrc(8) or even your_new_tool(8), and code written once > would not break in future ;) >=20 You don't need to do all of that. There is the service(8) command, and it will do the searching for you. You can get a list of all of the rc scripts, in the correct order that they are run during system startup using this command: service -e You can also do: service -l And it will list every installed service for you. >=20 >=20 > Ok, imagine I started/stopped service. >=20 > Then, to enable/disable service I should know a lot of stuff! >=20 > To enable/disable service first thing that I should know is $rcvar of > a service. It can be different than $service name (which is rc script > name). > I should find rc script in right place, but thank again to service(8) > tool. I just can ask it with: > # service mysql-server rcvar > and get the $rcvar of service, no matter where startup script is. Good!= >=20 > Second thing I should know is if it's already enabled/disabled. > # service mysql-server rcvar > will output YES/NO besides $rcvar var name. > FreeBSD 10 got good command for rc scripts - "enabled", which would > answer us by its exit code. > # service mysql-server enabled; echo $? > Excellent! >=20 > Third thing I should know is how I have to enable/disable service. > How would I do that? Where would I do that? > Is it directly disabled (if $sysadmin2 set mysql_enable=3D"NO"), if so = - > where, or it just not enabled anywhere? > How many config files do you know which can be used to enable/disable > (control) service? What's their precedence? >=20 > Well, most of us (probably) would use /etc/rc.conf to enable $service > or to check if it's directly disabled. We would use $rcvar (!), not rc > script name. > But, FreeBSD has more places with higher precedence than /etc/rc.conf! > It's /etc/rc.conf.local file, > then /etc/rc.conf.d/$service file, > then /etc/rc.conf.d/$service/* files. > Then even /usr/local/etc/rc.conf.d/$service files and subdirs which > appeared in FreeBSD 10! >=20 > And there is no way to ask FreeBSD "Hey! Where is your config files to > control services?". > You can ask about them, but again, partially by running: > # sh -c '. /etc/rc.subr; load_rc_config "XXX"; echo $rc_conf_files' > which outputs "/etc/rc.conf /etc/rc.conf.local". > Of course, there is no way to ask "Where this service is enabled/disabl= ed?" > So we can catch $rc_conf_files, but not a bunch of rc.conf.d dirs and > subdirs. No way. So $HOPE, again, which is not good IMO. > Why $HOPE? Because such change already happened between FreeBSD 9 and > 10. So I should track such changes in my own code manually. >=20 > As a way to solve this, I'd like to see some vars like $rc_conf_d_dirs > which would point to "/etc/rc.conf.d > ${local_startup%/rc.d}/rc.conf.d/". Or any way to get them. > Now these dirs are "hardcoded" and used only in /etc/rc.subr here > https://github.com/freebsd/freebsd/blob/master/etc/rc.subr#L1336-L1354.= > It's not used anywhere else. >=20 >=20 > Thank good we have an alternative to this hell of manual editing and > going through the list of dirs! You can forget about anything above. I > can rely on it, because it's in the base system and I'm sure it knows > any cases. > It's a ... Hmm, where is it? > Turns out, we don't have such tool. We have only sysrc(8), but it can > only edit $rc_conf_files in safe way. There is no support for > rc.conf.d dirs in sysrc(8). > And, in general, it's a tool to just `edit` $rc_conf_files, not to > control and configure services. sysrc automatically detects values from rc.conf.d directories, and can edit them if you ask it to. It just defaults to writing your changes to /etc/rc.conf My puppet scripts use: sysrc -f /etc/rc.conf.d/varnish varnishd_identity=3D"PDX1-01" and the the like all the time >=20 > As a user I would love to have a cool tool to control and configure > services in way like OpenBSD's rcctl(8) does > http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/rcctl.8?que= ry=3Drcctl. > # cooltool set mysql-server status on > That's all. It would take care of those things like getting right > $rcvar name, choose right rc config file to edit (remember, we have a > lot of places to check, see above) and enable service, etc. > This $cooltool can be an extended version of service(8) tool. > More difficult example: > # cooltool set flow_capture status on flags "-e 2200 -n 23 -N 0 -V 5" > port "8787" datadir "/storage/flows/all_routers" > would enable flow_capture service and set other stuff using right $rcva= r. > # cooltool get flow_capture > would print all of the configured stuff for $service > # cooltool get flow_capture status > would print only a status YES/NO (don't forget about exit code ;) ) > and etc. sysrc can do that, it will search all of the directories and find the final answer. The only thing it doesn't do is the translation between the 'service name' (mysql-server) and the 'rcvar prefix' (mysql_), which might be a useful addition, but might make more sense in the service command, because when I pass something to sysrc, I expect it to be interpreted literally. I guess it could be a flag for sysrc to specify the service instead of the rcvar. sysrc -s mysql datadir=3D/var/db/mysql > IMO such tools would be useful even for ansible/puppet and friends. > Not just for users ;) >=20 Teaching service to use sysrc might be useful. Making sysrc detect that /etc/rc.conf.d/ exists, and use it, else fallback to /etc/rc.conf might also be nice. service mysql-server enable|disable sets mysql_enable=3D"YES|NO" service mysql-server set datadir=3D/var/db/mysql sets mysql_datadir=3D"/var/db/mysql" I am currently doing all of this in puppet with sysrc. >=20 > I'm really sorry if I misunderstand something and wasted your time! > And I don't want to offend anyone in case I'm impolite! >=20 > P.S. Do you have any ideas? > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.o= rg" >=20 --=20 Allan Jude --rt2TGWE6hHS8NU4XO0fMF1I5NhesBdjdf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (MingW32) iQIcBAEBAgAGBQJV3yYgAAoJEBmVNT4SmAt+USQP/3RLaGBq9tNZdIporxnXHlzn nNqdgob/GHXdSgqJAAgqz0DZLoXeJj82oXECgZIeuiPlxYEUXwiD3W1K4qjlbp+q qEuogu105kV2yu/lLLuuhy6hQ9xBrArQarp+UVV8gVXhO/5i7daTYh9Z/9kh7ovX WZcmV7MqRcdbbLYeNDFlDVkEft+dS6/3jFWcH2B2ey2WMZNwWJ9zH4NLPL0Uo4j7 guTTcKxtglC6y79P5rQVJiq1o/j+Hg6Rfvy/wnHTDNUjLklpTc9Cg4Z1wMWColyY SYUVMy0Mc00SjqdN75AdlH1JBihMxXnNH1qCUKYBK+1ItW0h+Q8pNHtoHHmkVwV2 7Ss1mRssZ+fs/6oMqv6/gWD1Ed/gvZgsiXYNyDdZf/8XReTyfxEnVeGI/C01kbrb 5sxBbAnDsKngQt7Hj/lEDmr3XKTwpie0FDRdqzqv/CBSqlgrmGT55o39mwNb8/8A qqUIFxgkQZ0IWO3mjcTLYHBoSVLBilq3su/WSEKq1jzQr9fRbCccQJ2khPNq+tfB f4+CA9HdyIj8IYjnT4zH1s4TVV+XmTrydi8T4cACcNnsjYKJDQP5lG5ken54hC6r bCPHLREeg97jN6/33cZeBPWpa44sIDtWhItcXw37jhYf3GLt5FCb38HKTJ96+DLg AH02QKg1Vg6iQC7/50Bo =5ijg -----END PGP SIGNATURE----- --rt2TGWE6hHS8NU4XO0fMF1I5NhesBdjdf-- From owner-freebsd-hackers@freebsd.org Thu Aug 27 15:01:20 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 90BB59C433F for ; Thu, 27 Aug 2015 15:01:20 +0000 (UTC) (envelope-from ml@my.gd) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F34DB1B16 for ; Thu, 27 Aug 2015 15:01:19 +0000 (UTC) (envelope-from ml@my.gd) Received: by labia3 with SMTP id ia3so14382634lab.3 for ; Thu, 27 Aug 2015 08:01:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=VvU1s7oObM++aHP7qF6D8xss4Dgjz5DYFfxSaKMv4dc=; b=RGy+16/InA8C7uUyx11U403Jy3Jm/qb2WHrL1ARb2ZMU0nilSD2dMQbN4ih2bkCRAq 1wtYQszRrVpfrmewveeMYH87z2hUhuueip/Vjg4Lol3N4UbZcHv5rJtty1bu5Jbpj7O/ 9jgfAevPd9G940gxDbm3/VF8UKbOtgj22VAgW5zV9zuhQu44e06tZiKNhPQPAHDK4NOw zwPVqrAeBYOUold7Z4+Xlw8umo+NyaphGMc+VEpqD02ZJBmHhmBVf8v61JhwvDSygOjq Ui40NWmy2GOLSbVjP8JtRq6v9e+JWd10sVIiImcAYe/ioNxWzdZEGbqfyW3srG0s1Thl hE/A== X-Gm-Message-State: ALoCoQlf9mlBIY4/VRxKZOSSc32KdJB3oMoXG/apeZZgshTEh0l+TUSKQqB5DKe3Yhj1jpPbyKh0 MIME-Version: 1.0 X-Received: by 10.112.119.180 with SMTP id kv20mr2466718lbb.81.1440687333380; Thu, 27 Aug 2015 07:55:33 -0700 (PDT) Received: by 10.112.60.34 with HTTP; Thu, 27 Aug 2015 07:55:33 -0700 (PDT) In-Reply-To: References: Date: Thu, 27 Aug 2015 16:55:33 +0200 Message-ID: Subject: Re: How to control and setup service? From: Damien Fleuriot To: Pavel Timofeev Cc: freebsd-hackers@freebsd.org, Devin Teske Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 15:01:20 -0000 On 27 August 2015 at 15:21, Pavel Timofeev wrote: > Hi! Good day! > > let me declare something first: > HOPE="I just should know about that dir/sruff and hope that nothing > will change in future releases"; > > > I'm trying to write some automation code to manipulate services. > There is no problem with installing service, I can just use pkg(8) to > search/install/remove service. > Like following: > # pkg install mysql56-server > No problem. pkg(8) covers pretty much everything. > > > > But I have problems with starting and enabling services. > > > > Ok, to start a service we have rc scripts. If it's a base system > service then it has rc script in /etc/rc.d dir. > If a service is installed from packages (ports) then an rc script is > in /usr/local/etc/rc.d dir. > So, first, I should check one dir then another. But how can I be sure > I'm looking in right directories? > Is there any way to ask FreeBSD "Hey! Where is you startup dirs?". I'd > say yes, but only partially. > > /etc/rc.d dir is hardcoded everywhere. So $HOPE, which is not good IMO. > > Wow wow wow slow down here. Base system init scripts have been in /etc/rc.d/ as long as I've used FreeBSD which is from 4.4, perhaps even earlier. You may have not noticed, but FreeBSD goes to great length to preserve backwards compatibility. > "/usr/local/etc/rc.d" is ${local_startup} var which is defined in > /etc/defaults/rc.conf. > I can actually ask FreeBSD about that by calling: > # sh -c '. /etc/rc.subr; load_rc_config "XXX"; echo $local_startup' > Good! > > But in geretal, there is no way to ask FreeBSD for a complete list of > startup dirs. So $HOPE. > > Neither should there be need for such a way. Base system RC scripts are in /etc/rc.d/ Ports RC scripts are in /usr/local/etc/rc.d/ You should never see a RC script anywhere else, otherwise the package you installed doesn't respect the hierarchy, and then that's the package creator's problem, not the OS' . Refer man 7 hier > It would be pretty useful if I could ask FreeBSD for one variable like > $all_startup, which would contain all of the startup dirs ("/etc/rc.d > ${local_startup} ${new_startup_whatever}"). > And it would be great if "/etc/rc.d" was defined as variable too. Like > ${system_startup}="/etc/rc.d" (which is not simple I believe, it's > hardcoded everywhere!). > > > Thank god, there is a alternative way to start/stop services! > It's service(8) tool that can do this stuff for me. I can rely on it, > because it's a base system tool and I'm sure it knows everything about > startup dirs, no matter what FreeBSD release I'm using. > IMO service(8) covers this use case. > So we can forget my ideas above. > Or realize them because it can be useful for such tools like > service(8), sysrc(8) or even your_new_tool(8), and code written once > would not break in future ;) > > I'm not sure what you're trying to get at here. > > > Ok, imagine I started/stopped service. > > Then, to enable/disable service I should know a lot of stuff! > > Not that much as a matter of fact, since when you install a port it usually tells you how to enable it. Besides seeing you're actually installing a new service (as in, the system didn't decide to install one for you, you're the one performing the action), then you should read the documentation for said service, which instructs you on how to enable/disable the service. To enable/disable service first thing that I should know is $rcvar of > a service. It can be different than $service name (which is rc script > name). > I should find rc script in right place, but thank again to service(8) > tool. I just can ask it with: > # service mysql-server rcvar > and get the $rcvar of service, no matter where startup script is. Good! > > Second thing I should know is if it's already enabled/disabled. > # service mysql-server rcvar > will output YES/NO besides $rcvar var name. > FreeBSD 10 got good command for rc scripts - "enabled", which would > answer us by its exit code. > # service mysql-server enabled; echo $? > Excellent! > > Third thing I should know is how I have to enable/disable service. > How would I do that? Where would I do that? > Is it directly disabled (if $sysadmin2 set mysql_enable="NO"), if so - > where, or it just not enabled anywhere? > How many config files do you know which can be used to enable/disable > (control) service? What's their precedence? > > Well that one's rather easy isn't it ? Stick to /etc/rc.conf and the problem will disappear all by itself ;) > Well, most of us (probably) would use /etc/rc.conf to enable $service > or to check if it's directly disabled. We would use $rcvar (!), not rc > script name. > But, FreeBSD has more places with higher precedence than /etc/rc.conf! > It's /etc/rc.conf.local file, > then /etc/rc.conf.d/$service file, > then /etc/rc.conf.d/$service/* files. > Then even /usr/local/etc/rc.conf.d/$service files and subdirs which > appeared in FreeBSD 10! > > And there is no way to ask FreeBSD "Hey! Where is your config files to > control services?". > You can ask about them, but again, partially by running: > # sh -c '. /etc/rc.subr; load_rc_config "XXX"; echo $rc_conf_files' > which outputs "/etc/rc.conf /etc/rc.conf.local". > Of course, there is no way to ask "Where this service is enabled/disabled?" > So we can catch $rc_conf_files, but not a bunch of rc.conf.d dirs and > subdirs. No way. So $HOPE, again, which is not good IMO. > Why $HOPE? Because such change already happened between FreeBSD 9 and > 10. So I should track such changes in my own code manually. > > And what change would that be, that *wasn't documented in /usr/src/UPDATING* or in the release notes ? > As a way to solve this, I'd like to see some vars like $rc_conf_d_dirs > which would point to "/etc/rc.conf.d > ${local_startup%/rc.d}/rc.conf.d/". Or any way to get them. > Now these dirs are "hardcoded" and used only in /etc/rc.subr here > https://github.com/freebsd/freebsd/blob/master/etc/rc.subr#L1336-L1354. > It's not used anywhere else. > > And I, wouldn't. You wanna make a mess out of your box by tossing startup definitions here and there ? Knock yourself out, but don't try to trivialise the malpractice by asking that it be made easier. I, on the other hand, am gonna stick to /etc/rc.conf > > Thank good we have an alternative to this hell of manual editing and > going through the list of dirs! You can forget about anything above. I > can rely on it, because it's in the base system and I'm sure it knows > any cases. > It's a ... Hmm, where is it? > Turns out, we don't have such tool. We have only sysrc(8), but it can > only edit $rc_conf_files in safe way. There is no support for > rc.conf.d dirs in sysrc(8). > And, in general, it's a tool to just `edit` $rc_conf_files, not to > control and configure services. > > Might that be because such a tool is not NEEDED, possibly ? Your choice of phrasing makes it look like you're trying to fuck up your box and using a condescending tone to bitch about the absence of tools to help you do so. > As a user I would love to have a cool tool to control and configure > services in way like OpenBSD's rcctl(8) does > > http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/rcctl.8?query=rcctl > . > # cooltool set mysql-server status on > That's all. It would take care of those things like getting right > $rcvar name, choose right rc config file to edit (remember, we have a > lot of places to check, see above) and enable service, etc. > If your use case requires such a tool, for convenience or whatever, then how about you hack one up ? I'm convinced if other people have the same needs as you do, they'll very much welcome such a program. > This $cooltool can be an extended version of service(8) tool. > More difficult example: > # cooltool set flow_capture status on flags "-e 2200 -n 23 -N 0 -V 5" > port "8787" datadir "/storage/flows/all_routers" > would enable flow_capture service and set other stuff using right $rcvar. > # cooltool get flow_capture > would print all of the configured stuff for $service > # cooltool get flow_capture status > would print only a status YES/NO (don't forget about exit code ;) ) > and etc. > IMO such tools would be useful even for ansible/puppet and friends. > Not just for users ;) > > > I'm really sorry if I misunderstand something and wasted your time! > And I don't want to offend anyone in case I'm impolite! > > P.S. Do you have any ideas? I myself dislike your idea and would rather stick to /etc/rc.conf. Nobody's preventing you from getting to work on such a tool if you deem it necessary for your needs though. In fact, you could even create a port to do just that, in sysutils/ for example. Sky's the limit and all that stuff. From owner-freebsd-hackers@freebsd.org Thu Aug 27 20:05:39 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 24E469C4EF6 for ; Thu, 27 Aug 2015 20:05:39 +0000 (UTC) (envelope-from lars@e-new.0x20.net) Received: from mail.0x20.net (mail.0x20.net [217.69.76.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.0x20.net", Issuer "mail.0x20.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id D92D57A0; Thu, 27 Aug 2015 20:05:37 +0000 (UTC) (envelope-from lars@e-new.0x20.net) Received: from e-new.0x20.net (mail.0x20.net [IPv6:2001:aa8:fffb:1::3]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.0x20.net (Postfix) with ESMTPS id DC7096E005D; Thu, 27 Aug 2015 22:05:34 +0200 (CEST) Received: from e-new.0x20.net (localhost [127.0.0.1]) by e-new.0x20.net (8.14.7/8.14.7) with ESMTP id t7RK5Yl5044295; Thu, 27 Aug 2015 22:05:34 +0200 (CEST) (envelope-from lars@e-new.0x20.net) Received: (from lars@localhost) by e-new.0x20.net (8.14.7/8.14.7/Submit) id t7RK5YAc042960; Thu, 27 Aug 2015 22:05:34 +0200 (CEST) (envelope-from lars) Date: Thu, 27 Aug 2015 22:05:34 +0200 From: Lars Engels To: Allan Jude Cc: freebsd-hackers@freebsd.org, Devin Teske Subject: Re: How to control and setup service? Message-ID: <20150827200534.GH16003@e-new.0x20.net> References: <55DF261C.80009@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="jaoouwwPWoQSJZYp" Content-Disposition: inline In-Reply-To: <55DF261C.80009@freebsd.org> X-Editor: VIM - Vi IMproved 7.4 X-Operation-System: FreeBSD 8.4-RELEASE-p23 User-Agent: Mutt/1.5.23 (2014-03-12) X-Mailman-Approved-At: Thu, 27 Aug 2015 20:46:43 +0000 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 20:05:39 -0000 --jaoouwwPWoQSJZYp Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 27, 2015 at 11:00:44AM -0400, Allan Jude wrote: > On 2015-08-27 09:21, Pavel Timofeev wrote: > > IMO such tools would be useful even for ansible/puppet and friends. > > Not just for users ;) > >=20 >=20 > Teaching service to use sysrc might be useful. Making sysrc detect that > /etc/rc.conf.d/ exists, and use it, else fallback to > /etc/rc.conf might also be nice. >=20 > service mysql-server enable|disable > sets mysql_enable=3D"YES|NO" > service mysql-server set datadir=3D/var/db/mysql > sets mysql_datadir=3D"/var/db/mysql" There's already a patch in phabricator: https://reviews.freebsd.org/D451 --jaoouwwPWoQSJZYp Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQF8BAEBCgBmBQJV322OXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ4RjQwMDE3RTRERjUzMTI1N0FGRTUxNDlF NTRDQjM3RDNBMDg5RDZEAAoJEOVMs306CJ1t+NMIAIvrCe2nKhDLBWCnWJ6ob4i4 R08pdLqXZdXmUi+eLtvMDLnRHYCUO2Yh5RNUGBfJGjAPrpB3zn4K+zlnrmkxw71Q m138Ssi/wN2LFND/ffZXzgJ/zQxYRHjADl2WtSjZfOUlaCJ6uQiF46BN/k5v4KLW uvsB2KEZ3AXlYIPv9K/7JquFve3txCRl5LAtCFMlyU6vxHVEZkIwy5SfUlzfZ149 Bj2oAwpv9Gs0F3KrWi2my2g2wz1EtwItIbnWT7w+OEjkXGCdxkm6EdRlUxyI7S1E W52ykLNUeaGq6oelh2GyE03L7HCo3ULVDiFU5QhFeBKg7ZWtBbf3B6VkbMVsvH4= =00qj -----END PGP SIGNATURE----- --jaoouwwPWoQSJZYp-- From owner-freebsd-hackers@freebsd.org Thu Aug 27 21:21:44 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A17C9C4A6B for ; Thu, 27 Aug 2015 21:21:44 +0000 (UTC) (envelope-from devin@shxd.cx) Received: from shxd.cx (mail.shxd.cx [64.201.244.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4592E19F7; Thu, 27 Aug 2015 21:21:44 +0000 (UTC) (envelope-from devin@shxd.cx) Received: from 50-196-156-133-static.hfc.comcastbusiness.net ([50.196.156.133]:64770 helo=tinkerbell.pixel8networks.com) by shxd.cx with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.77 (FreeBSD)) (envelope-from ) id 1ZUxZG-000LcP-9z; Thu, 27 Aug 2015 06:50:14 -0700 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Subject: Re: How to control and setup service? From: Devin Teske In-Reply-To: <55DF261C.80009@freebsd.org> Date: Thu, 27 Aug 2015 14:21:39 -0700 Cc: freebsd-hackers@freebsd.org, Devin Teske Message-Id: <988F49BB-5F42-4563-98AF-B8947FAC1EDC@FreeBSD.org> References: <55DF261C.80009@freebsd.org> To: Allan Jude X-Mailer: Apple Mail (2.2102) Sender: devin@shxd.cx Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 21:21:44 -0000 > On Aug 27, 2015, at 8:00 AM, Allan Jude wrote: >=20 > sysrc automatically detects values from rc.conf.d directories, and can > edit them if you ask it to. It just defaults to writing your changes = to > /etc/rc.conf >=20 Only if you use the =93-f file=94 argument to point sysrc at said = file(s). Worth mentioning is this is in the sysrc(8) manual: LIMITATIONS The sysrc utility presently does not support the `rc.conf.d' = collection of system configuration files (which requires a service name to be = known during execution). This will be corrected by a future enhancement. So while below Allan shows us how to use `-f file=92 to support = rc.conf.d file(s): > My puppet scripts use: > sysrc -f /etc/rc.conf.d/varnish varnishd_identity=3D"PDX1-01" >=20 >=20 The OP was interested in an enhancement: sysrc -s varnish varnishd_identity=3D=93PDX1-01=94 When given `-s service_name=92, sysrc would do the following: 1. For information purposes, first make sure service_name exists in any = of: a. /etc/rc.d b. $local_startup directories =97 default: /usr/local/etc/rc.d 2. If the service does not exist, issue a warning to stderr but proceed = anyway NB: If we prevent moving ahead, it would be impossible to configure a = setting when service is not installed 3. If service does exist, add the following paths to list of files = checked (in addition to $rc_conf_files) i. /etc/rc.conf.d/$_name ii. ${local_startup%/rc.d}/rc.conf.d/$_name =97 default = /usr/local/etc/rc.conf.d/$_name You can better simulate this effect without the `-s service_name=92 = enhancement, using the currently available `-f file=92 argument (more pedantic than = Allan Jude=92s approach from above): sysrc -f "/etc/rc.conf.d/$_name $( sysrc -n local_startup%/rc.d = )/rc.conf.d/$_name" vimage_enable Where $_name is the service_name. A `-s service_name=92 argument to sysrc would make this easier. ASIDE: While I was diving into this, I discovered a code typo in = /etc/rc.subr NB: The typo has gone unnoticed because it has no effect on outcome =3D=3D=3D BEGIN DIFF =3D=3D=3D --- rc.subr.orig 2015-08-27 12:56:24.445475772 -0700 +++ rc.subr 2015-08-27 12:56:33.980474637 -0700 @@ -1333,7 +1333,7 @@ load_rc_config() _rc_conf_loaded=3Dtrue fi =20 - for _d in /etc ${local_startup%*/rc.d}; do + for _d in /etc ${local_startup%/rc.d}; do if [ -f ${_d}/rc.conf.d/"$_name" ]; then debug "Sourcing ${_d}/rc.conf.d/$_name" . ${_d}/rc.conf.d/"$_name=94 =3D=3D=3D END DIFF =3D=3D=3D FURTHER ASIDE: Why is the code in /etc/rc.subr treating $local_startup as though it=92s a single item? There are many locations in code that consider $local_startup to be a white- space separated list of directories where rc.d scripts can live? I think the above code should perhaps be changed to: =3D=3D=3D BEGIN DIFF =3D=3D=3D --- rc.subr.orig 2015-08-27 12:56:24.445475772 -0700 +++ rc.subr 2015-08-27 13:53:30.976240109 -0700 @@ -1333,7 +1333,8 @@ load_rc_config() _rc_conf_loaded=3Dtrue fi =20 - for _d in /etc ${local_startup%*/rc.d}; do + for _d in /etc/rc.d $local_startup; do + _d=3D"${_d%/rc.d}" if [ -f ${_d}/rc.conf.d/"$_name" ]; then debug "Sourcing ${_d}/rc.conf.d/$_name" . ${_d}/rc.conf.d/"$_name" =3D=3D=3D END DIFF =3D=3D=3D >>=20 >> As a user I would love to have a cool tool to control and configure >> services in way like OpenBSD's rcctl(8) does >> = http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/rcctl.8?query=3D= rcctl. >> # cooltool set mysql-server status on >> That's all. It would take care of those things like getting right >> $rcvar name, choose right rc config file to edit (remember, we have a >> lot of places to check, see above) and enable service, etc. >> This $cooltool can be an extended version of service(8) tool. >> More difficult example: >> # cooltool set flow_capture status on flags "-e 2200 -n 23 -N 0 -V = 5" >> port "8787" datadir "/storage/flows/all_routers" >> would enable flow_capture service and set other stuff using right = $rcvar. >> # cooltool get flow_capture >> would print all of the configured stuff for $service >> # cooltool get flow_capture status >> would print only a status YES/NO (don't forget about exit code ;) ) >> and etc. >=20 > sysrc can do that, it will search all of the directories and find the > final answer. >=20 > The only thing it doesn't do is the translation between the 'service > name' (mysql-server) and the 'rcvar prefix' (mysql_), The rcvar =93prefix" is not actually what you=92re after. In load_rc_config() of /etc/rc.subr we can see that it uses $_name to append to /etc/rc.conf.d/ and /usr/local/etc/rc.conf.d/ What exactly is =93$_name=94 you ask? Good question=85 Almost 100% of the time, it=92s whatever =93name=3D=93 in the rc.d = script. This is not guaranteed to be ${0##*/} (the rc.d script name). However, this just happens to be because almost 100% of the time, rc.d scripts do the following: load_rc_config "$name" So for sysrc to know the proper name of the thing that /etc/rc.subr will source from rc.conf.d collection of directories, we need to know what name=3D in the rc.d script. This seems to be the simplest approach: =3D=3D=3D BEGIN SCRIPT: sconfigs.sh =3D=3D=3D #!/bin/sh sname=3D"$1" sconfigs=3D _name=3D$( service "$sname" rcvar 2> /dev/null | awk 'NR=3D=3D1&&sub(/^# /,""){print;exit}?' 2> /dev/null ) if [ "$_name" ]; then sconfigs=3D"/etc/rc.conf.d/$_name" local_etc=3D$( sysrc -qn local_startup%/rc.d 2> /dev/null ) [ "$local_etc" ] && sconfigs=3D"$sconfigs $local_etc/rc.d/rc.conf.d/$_name" sconfigs=3D"${sconfigs# }" fi echo "sconfigs=3D[$sconfigs]" =3D=3D=3D END SCRIPT: sconfigs.sh =3D=3D=3D Examples: $ ./sconfigs.sh sconfigs=3D[] $ ./sconfigs.sh zfs sconfigs=3D[/etc/rc.conf.d/zfs /usr/local/etc/rc.d/rc.conf.d/zfs] $ ./sconfigs.sh jail sconfigs=3D[/etc/rc.conf.d/jail /usr/local/etc/rc.d/rc.conf.d/jail] $ ./sconfigs.sh nosuchservice sconfigs=3D[] So naturally, if the logic in sconfigs.sh yields a non-NULL value for $sconfigs, this would become the value of `-f files=92 via service name. > which might be a > useful addition, but might make more sense in the service command, > because when I pass something to sysrc, I expect it to be interpreted > literally. I guess it could be a flag for sysrc to specify the service > instead of the rcvar. >=20 > sysrc -s mysql datadir=3D/var/db/mysql Given above talking-points, that would cause: a. sysrc makes sure that =93mysql=94 is an actual service b. sysrc uses =93service mysql rcvar" (piped into awk) to get `name=3D=91 = value NB: This could potentially result in a disconnect IFF the rc.d script = passes something other than =93$name=94 to load_rc_config() (if we=92re = worried about this, I have another recipe =97 further below). c. Sets `-f files=92 value to "/etc/rc.conf.d/mysql = /usr/local/etc/rc.conf.d/mysql=94 ASIDE: The only edge-case would be, for example... =3D=3D=3D BEGIN FILE: /etc/rc.d/fooserv =3D=3D=3D #!/bin/sh . /etc/rc.subr name=3DfoooooooooooooOOOooo load_rc_config foooooooooo run_rc_command "$@=93 =3D=3D=3D END FILE: /etc/rc.d/fooserv =3D=3D=3D Wherein we get the following from =93service =85 rcvar=94: $ service fooserv rcvar | awk NR=3D=3D1 # foooooooooooooOOOooo The above command returns the =93name=3D=93 value but the script doesn=92t= actually pass $name to load_rc_config() and thus what /etc/rc.subr would check for in this case is /etc/rc.conf.d/foooooooooo and /usr/local/etc/rc.conf.d/foooooooooo (versus the camel-case $name). This edge-case exists for a number of services in the base: $ awk '$1 ~ /^name=3D/ { name =3D $0; fn =3D FILENAME } $1 =3D=3D = "load_rc_config" && $2 !~ /\$(name|{name})/{ print "--"; if (fn =3D=3D = FILENAME) print fn ":" name; print FILENAME ":" $0 }' /etc/rc.d/* -- /etc/rc.d/dhclient:name=3D"dhclient" /etc/rc.d/dhclient:load_rc_config network -- /etc/rc.d/fooserv:name=3DfoooooooooooooOOOooo /etc/rc.d/fooserv:load_rc_config foooooooooo -- /etc/rc.d/initrandom:name=3D"initrandom" /etc/rc.d/initrandom:load_rc_config random -- /etc/rc.d/othermta:load_rc_config 'XXX' -- /etc/rc.d/postrandom:name=3D"postrandom" /etc/rc.d/postrandom:load_rc_config random -- /etc/rc.d/swaplate:name=3D"swaplate" /etc/rc.d/swaplate:load_rc_config swap NB: Ignore the /etc/rc.d/fooserv script which I created specifically to = illustrate the disconnect. For the above edge-case services in base, load_rc_config() of = /etc/rc.subr will check the following: dhclient: /etc/rc.conf.d/network /usr/local/etc/rc.conf.d/network initrandom: /etc/rc.conf.d/random /usr/local/etc/rc.conf.d/random othermta: /etc/rc.conf.d/XXX /usr/local/etc/rc.conf.d/XXX postrandom: /etc/rc.conf.d/random /usr/local/etc/rc.conf.d/random swaplate: /etc/rc.conf.d/swap /usr/local/etc/rc.conf.d/swap Let=92s ignore for a second that it seems like an obvious error to be = sourcing /usr/local/etc/rc.conf.d/ANYTHING for a base service in /etc/rc.d/ NB: I can see someone utilizing that as a form of value-add anyways What stands out at first glance is: + If /etc/rc.conf.d/XXX or /usr/local/etc/rc.conf.d/XXX exists, it will be sourced when working on the =93othermta=94 service NB: My testing indicates that othermta can obtain the desired results (of not sourcing any additional rc.conf.d files) by instead passing a single =93.=94 to load_c_config() =97 which does not allow a NULL arg1. + The =93service rcvar | awk =85=94 approach to get =93name=3D=93 value fails for dhclient, initrandom, postrandom, and swaplate. Oh, but it gets worse when you look deeper at the above-mentioned = scripts: $ grep -c load_rc_config /etc/rc.d/* | grep -v ':[01]$' | sed -e = 's/:[[:digit:]]\{1,\}$//' | xargs grep -n load_rc_config=20 /etc/rc.d/dhclient:54:load_rc_config $name /etc/rc.d/dhclient:55:load_rc_config network /etc/rc.d/local_unbound:32:load_rc_config $name /etc/rc.d/local_unbound:90:load_rc_config $name It turns out that the dhclient script will actually source all of (if = any exist; in order): 1. /etc/rc.conf.d/dhclient 2. /usr/local/etc/rc.conf.d/dhclient 3. /etc/rc.conf.d/network 4. /usr/local/etc/rc.conf.d/network I have a recipe that overcomes this edge-case that I=92d like to offer as a potential solution: =3D=3D=3D BEGIN FILE: sconfigs2.sh =3D=3D=3D #!/bin/sh sname=3D"$1" sconfigs=3D local_startup=3D$( sysrc -qn local_startup ) for dir in /etc/rc.d $local_startup; do spath=3D"$dir/$sname" [ -f "$spath" -a -x "$spath" ] || spath=3D continue break done if [ ! "$spath" ]; then echo "$sname does not exist in /etc/rc.d or the local startup" echo "directories ($local_startup)" exit 1 fi _names=3D case "$( file -b "$spath" 2> /dev/null )" in *"shell script"*) _names=3D$( exec 9<&1 1>&- 2>&- last_name=3D print_name() { local name=3D"$1" [ "$name" =3D "$last_name" ] && return echo "$name" >&9 last_name=3D"$name" } eval "$( awk '{ gsub(/load_rc_config /, "print_name ") gsub(/run_rc_command /, ": ") print }' "$spath" )" ) ;; esac for _name in $_names; do for dir in /etc/rc.d $local_startup; do sconfigs=3D"$sconfigs ${dir%/rc.d}/rc.conf.d/$_name" done done sconfigs=3D"${sconfigs# }" echo "sconfigs=3D[$sconfigs]=94 =3D=3D=3D END FILE: sconfigs2.sh =3D=3D=3D Given the above code, we can handle the afore-mentioned edge-casen: $ ./sconfigs2.sh dhclient sconfigs=3D[/etc/rc.conf.d/dhclient /usr/local/etc/rc.conf.d/dhclient = /etc/rc.conf.d/network /usr/local/etc/rc.conf.d/network] $ ./sconfigs2.sh initrandom sconfigs=3D[/etc/rc.conf.d/random /usr/local/etc/rc.conf.d/random] $ ./sconfigs2.sh postrandom sconfigs=3D[/etc/rc.conf.d/random /usr/local/etc/rc.conf.d/random] $ ./sconfigs2.sh swaplate sconfigs=3D[/etc/rc.conf.d/swap /usr/local/etc/rc.conf.d/swap] $ ./sconfigs2.sh local_unbound sconfigs=3D[/etc/rc.conf.d/local_unbound = /usr/local/etc/rc.conf.d/local_unbound] $ ./sconfigs2.sh=20 does not exist in /etc/rc.d or the local startup directories (/usr/local/etc/rc.d) $ ./sconfigs2.sh nosuchservice nosuchservice does not exist in /etc/rc.d or the local startup directories (/usr/local/etc/rc.d) This is looking like a much better approach. >=20 >> IMO such tools would be useful even for ansible/puppet and friends. >> Not just for users ;) >>=20 >=20 > Teaching service to use sysrc might be useful. Making sysrc detect = that > /etc/rc.conf.d/ exists, and use it, else fallback to > /etc/rc.conf might also be nice. >=20 > service mysql-server enable|disable > sets mysql_enable=3D"YES|NO" > service mysql-server set datadir=3D/var/db/mysql > sets mysql_datadir=3D"/var/db/mysql" >=20 > I am currently doing all of this in puppet with sysrc. Adding a =93service =85 enable=94 and =93service =85 disable=94 could be = nice. I=92m sure some of the above logic would be instrumental in that. =97=20 Devin= From owner-freebsd-hackers@freebsd.org Thu Aug 27 21:38:24 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D455A9C310A for ; Thu, 27 Aug 2015 21:38:24 +0000 (UTC) (envelope-from devin@shxd.cx) Received: from shxd.cx (mail.shxd.cx [64.201.244.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BEFA67F7; Thu, 27 Aug 2015 21:38:24 +0000 (UTC) (envelope-from devin@shxd.cx) Received: from 50-196-156-133-static.hfc.comcastbusiness.net ([50.196.156.133]:64962 helo=tinkerbell.pixel8networks.com) by shxd.cx with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.77 (FreeBSD)) (envelope-from ) id 1ZUxpM-000Lls-8f; Thu, 27 Aug 2015 07:06:52 -0700 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Subject: Re: How to control and setup service? From: Devin Teske In-Reply-To: <988F49BB-5F42-4563-98AF-B8947FAC1EDC@FreeBSD.org> Date: Thu, 27 Aug 2015 14:38:25 -0700 Cc: freebsd-hackers@freebsd.org, Devin Teske Message-Id: <7D057F49-F1AC-4224-9D48-07E958F610F9@FreeBSD.org> References: <55DF261C.80009@freebsd.org> <988F49BB-5F42-4563-98AF-B8947FAC1EDC@FreeBSD.org> To: Allan Jude X-Mailer: Apple Mail (2.2102) Sender: devin@shxd.cx Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 21:38:25 -0000 My last e-mail needs some distilling perhaps =85 > On Aug 27, 2015, at 2:21 PM, Devin Teske wrote: >=20 >> On Aug 27, 2015, at 8:00 AM, Allan Jude > wrote: >>=20 >> sysrc automatically detects values from rc.conf.d directories, and = can >> edit them if you ask it to. It just defaults to writing your changes = to >> /etc/rc.conf >>=20 >> My puppet scripts use: >> sysrc -f /etc/rc.conf.d/varnish varnishd_identity=3D"PDX1-01" >>=20 >>=20 >=20 [snip] > You can better simulate this effect without the `-s service_name=92 = enhancement, > using the currently available `-f file=92 argument (more pedantic than = Allan Jude=92s > approach from above): >=20 > sysrc -f "/etc/rc.conf.d/$_name $( sysrc -n local_startup%/rc.d = )/rc.conf.d/$_name" vimage_enable >=20 > Where $_name is the service_name. > A `-s service_name=92 argument to sysrc would make this easier. >=20 Don=92t do that. That assumes that $local_startup is a single directory when in reality, it should be treated as a white-space separated list of one-or-more directories where startup scripts can live. NB: It also ignores the fact that some rc.d scripts call = load_rc_config() more than once with different arguments. E.g, dhclient > ASIDE: While I was diving into this, I discovered a code typo in = /etc/rc.subr > NB: The typo has gone unnoticed because it has no effect on outcome >=20 > =3D=3D=3D BEGIN DIFF =3D=3D=3D > --- rc.subr.orig 2015-08-27 12:56:24.445475772 -0700 > +++ rc.subr 2015-08-27 12:56:33.980474637 -0700 > @@ -1333,7 +1333,7 @@ load_rc_config() > _rc_conf_loaded=3Dtrue > fi > =20 > - for _d in /etc ${local_startup%*/rc.d}; do > + for _d in /etc ${local_startup%/rc.d}; do > if [ -f ${_d}/rc.conf.d/"$_name" ]; then > debug "Sourcing ${_d}/rc.conf.d/$_name" > . ${_d}/rc.conf.d/"$_name=94 > =3D=3D=3D END DIFF =3D=3D=3D >=20 Oh, looks like someone already fixed that=85 (thx Jilles) https://svnweb.freebsd.org/base?view=3Drevision&revision=3D286163 > FURTHER ASIDE: Why is the code in /etc/rc.subr treating > $local_startup as though it=92s a single item? There are many > locations in code that consider $local_startup to be a white- > space separated list of directories where rc.d scripts can live? > I think the above code should perhaps be changed to: >=20 > =3D=3D=3D BEGIN DIFF =3D=3D=3D > --- rc.subr.orig 2015-08-27 12:56:24.445475772 -0700 > +++ rc.subr 2015-08-27 13:53:30.976240109 -0700 > @@ -1333,7 +1333,8 @@ load_rc_config() > _rc_conf_loaded=3Dtrue > fi > =20 > - for _d in /etc ${local_startup%*/rc.d}; do > + for _d in /etc/rc.d $local_startup; do > + _d=3D"${_d%/rc.d}" > if [ -f ${_d}/rc.conf.d/"$_name" ]; then > debug "Sourcing ${_d}/rc.conf.d/$_name" > . ${_d}/rc.conf.d/"$_name" > =3D=3D=3D END DIFF =3D=3D=3D Lol, jilles arrived at the same exact change (albeit superfluous use of = curlies). https://svnweb.freebsd.org/base?view=3Drevision&revision=3D286163 >=20 >=20 >>>=20 >>> As a user I would love to have a cool tool to control and configure >>> services in way like OpenBSD's rcctl(8) does >>> = http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/rcctl.8?query=3D= rcctl = . >>> # cooltool set mysql-server status on >>> That's all. It would take care of those things like getting right >>> $rcvar name, choose right rc config file to edit (remember, we have = a >>> lot of places to check, see above) and enable service, etc. >>> This $cooltool can be an extended version of service(8) tool. >>> More difficult example: >>> # cooltool set flow_capture status on flags "-e 2200 -n 23 -N 0 -V = 5" >>> port "8787" datadir "/storage/flows/all_routers" >>> would enable flow_capture service and set other stuff using right = $rcvar. >>> # cooltool get flow_capture >>> would print all of the configured stuff for $service >>> # cooltool get flow_capture status >>> would print only a status YES/NO (don't forget about exit code ;) ) >>> and etc. >>=20 >> sysrc can do that, it will search all of the directories and find the >> final answer. >>=20 >> The only thing it doesn't do is the translation between the 'service >> name' (mysql-server) and the 'rcvar prefix' (mysql_), >=20 > The rcvar =93prefix" is not actually what you=92re after. > In load_rc_config() of /etc/rc.subr we can see that it uses $_name > to append to /etc/rc.conf.d/ and /usr/local/etc/rc.conf.d/ >=20 > What exactly is =93$_name=94 you ask? Good question=85 >=20 > Almost 100% of the time, it=92s whatever =93name=3D=93 in the rc.d = script. > This is not guaranteed to be ${0##*/} (the rc.d script name). > However, this just happens to be because almost 100% of the > time, rc.d scripts do the following: >=20 > load_rc_config "$name" >=20 > So for sysrc to know the proper name of the thing that /etc/rc.subr > will source from rc.conf.d collection of directories, we need to know > what name=3D in the rc.d script. >=20 > This seems to be the simplest approach: >=20 > =3D=3D=3D BEGIN SCRIPT: sconfigs.sh =3D=3D=3D > #!/bin/sh > sname=3D"$1" sconfigs=3D > _name=3D$( service "$sname" rcvar 2> /dev/null | > awk 'NR=3D=3D1&&sub(/^# /,""){print;exit}?' 2> /dev/null ) > if [ "$_name" ]; then > sconfigs=3D"/etc/rc.conf.d/$_name" > local_etc=3D$( sysrc -qn local_startup%/rc.d 2> /dev/null ) > [ "$local_etc" ] && > sconfigs=3D"$sconfigs $local_etc/rc.d/rc.conf.d/$_name" > sconfigs=3D"${sconfigs# }" > fi > echo "sconfigs=3D[$sconfigs]" > =3D=3D=3D END SCRIPT: sconfigs.sh =3D=3D=3D >=20 > Examples: >=20 > $ ./sconfigs.sh > sconfigs=3D[] > $ ./sconfigs.sh zfs > sconfigs=3D[/etc/rc.conf.d/zfs /usr/local/etc/rc.d/rc.conf.d/zfs] > $ ./sconfigs.sh jail > sconfigs=3D[/etc/rc.conf.d/jail /usr/local/etc/rc.d/rc.conf.d/jail] > $ ./sconfigs.sh nosuchservice > sconfigs=3D[] >=20 > So naturally, if the logic in sconfigs.sh yields a non-NULL > value for $sconfigs, this would become the value of `-f files=92 > via service name. >=20 The =93simplest=94 approach has edge-cases described below and should be avoided. The more holistic approach is below. >=20 >> which might be a >> useful addition, but might make more sense in the service command, >> because when I pass something to sysrc, I expect it to be interpreted >> literally. I guess it could be a flag for sysrc to specify the = service >> instead of the rcvar. >>=20 >> sysrc -s mysql datadir=3D/var/db/mysql >=20 > Given above talking-points, that would cause: >=20 > a. sysrc makes sure that =93mysql=94 is an actual service > b. sysrc uses =93service mysql rcvar" (piped into awk) to get `name=3D=91= value > NB: This could potentially result in a disconnect IFF the rc.d script = passes something other than =93$name=94 to load_rc_config() (if we=92re = worried about this, I have another recipe =97 further below). > c. Sets `-f files=92 value to "/etc/rc.conf.d/mysql = /usr/local/etc/rc.conf.d/mysql=94 >=20 > ASIDE: The only edge-case would be, for example... >=20 > =3D=3D=3D BEGIN FILE: /etc/rc.d/fooserv =3D=3D=3D > #!/bin/sh > . /etc/rc.subr > name=3DfoooooooooooooOOOooo > load_rc_config foooooooooo > run_rc_command "$@=93 > =3D=3D=3D END FILE: /etc/rc.d/fooserv =3D=3D=3D >=20 > Wherein we get the following from =93service =85 rcvar=94: >=20 > $ service fooserv rcvar | awk NR=3D=3D1 > # foooooooooooooOOOooo >=20 > The above command returns the =93name=3D=93 value but the script = doesn=92t > actually pass $name to load_rc_config() and thus what /etc/rc.subr > would check for in this case is /etc/rc.conf.d/foooooooooo and > /usr/local/etc/rc.conf.d/foooooooooo (versus the camel-case $name). >=20 > This edge-case exists for a number of services in the base: >=20 > $ awk '$1 ~ /^name=3D/ { name =3D $0; fn =3D FILENAME } $1 =3D=3D = "load_rc_config" && $2 !~ /\$(name|{name})/{ print "--"; if (fn =3D=3D = FILENAME) print fn ":" name; print FILENAME ":" $0 }' /etc/rc.d/* > -- > /etc/rc.d/dhclient:name=3D"dhclient" > /etc/rc.d/dhclient:load_rc_config network > -- > /etc/rc.d/fooserv:name=3DfoooooooooooooOOOooo > /etc/rc.d/fooserv:load_rc_config foooooooooo > -- > /etc/rc.d/initrandom:name=3D"initrandom" > /etc/rc.d/initrandom:load_rc_config random > -- > /etc/rc.d/othermta:load_rc_config 'XXX' > -- > /etc/rc.d/postrandom:name=3D"postrandom" > /etc/rc.d/postrandom:load_rc_config random > -- > /etc/rc.d/swaplate:name=3D"swaplate" > /etc/rc.d/swaplate:load_rc_config swap >=20 >=20 > NB: Ignore the /etc/rc.d/fooserv script which I created specifically = to illustrate the disconnect. >=20 > For the above edge-case services in base, load_rc_config() of = /etc/rc.subr will check the following: >=20 > dhclient: > /etc/rc.conf.d/network > /usr/local/etc/rc.conf.d/network > initrandom: > /etc/rc.conf.d/random > /usr/local/etc/rc.conf.d/random > othermta: > /etc/rc.conf.d/XXX > /usr/local/etc/rc.conf.d/XXX > postrandom: > /etc/rc.conf.d/random > /usr/local/etc/rc.conf.d/random > swaplate: > /etc/rc.conf.d/swap > /usr/local/etc/rc.conf.d/swap >=20 > Let=92s ignore for a second that it seems like an obvious error to be = sourcing > /usr/local/etc/rc.conf.d/ANYTHING for a base service in /etc/rc.d/ > NB: I can see someone utilizing that as a form of value-add anyways >=20 > What stands out at first glance is: >=20 > + If /etc/rc.conf.d/XXX or /usr/local/etc/rc.conf.d/XXX exists, > it will be sourced when working on the =93othermta=94 service >=20 > NB: My testing indicates that othermta can obtain the desired results > (of not sourcing any additional rc.conf.d files) by instead passing a > single =93.=94 to load_c_config() =97 which does not allow a NULL = arg1. >=20 > + The =93service rcvar | awk =85=94 approach to get =93name=3D=93= > value fails for dhclient, initrandom, postrandom, and swaplate. >=20 > Oh, but it gets worse when you look deeper at the above-mentioned = scripts: >=20 > $ grep -c load_rc_config /etc/rc.d/* | grep -v ':[01]$' | sed -e = 's/:[[:digit:]]\{1,\}$//' | xargs grep -n load_rc_config=20 > /etc/rc.d/dhclient:54:load_rc_config $name > /etc/rc.d/dhclient:55:load_rc_config network > /etc/rc.d/local_unbound:32:load_rc_config $name > /etc/rc.d/local_unbound:90:load_rc_config $name >=20 > It turns out that the dhclient script will actually source all of (if = any exist; in order): > 1. /etc/rc.conf.d/dhclient > 2. /usr/local/etc/rc.conf.d/dhclient > 3. /etc/rc.conf.d/network > 4. /usr/local/etc/rc.conf.d/network >=20 > I have a recipe that overcomes this edge-case that I=92d like to offer > as a potential solution: >=20 > =3D=3D=3D BEGIN FILE: sconfigs2.sh =3D=3D=3D > #!/bin/sh > sname=3D"$1" sconfigs=3D > local_startup=3D$( sysrc -qn local_startup ) > for dir in /etc/rc.d $local_startup; do > spath=3D"$dir/$sname" > [ -f "$spath" -a -x "$spath" ] || spath=3D continue > break > done > if [ ! "$spath" ]; then > echo "$sname does not exist in /etc/rc.d or the local startup" > echo "directories ($local_startup)" > exit 1 > fi > _names=3D > case "$( file -b "$spath" 2> /dev/null )" in *"shell script"*) > _names=3D$( exec 9<&1 1>&- 2>&- > last_name=3D > print_name() { > local name=3D"$1" > [ "$name" =3D "$last_name" ] && return > echo "$name" >&9 > last_name=3D"$name" > } > eval "$( awk '{ > gsub(/load_rc_config /, "print_name ") > gsub(/run_rc_command /, ": ") > print > }' "$spath" )" > ) ;; > esac > for _name in $_names; do > for dir in /etc/rc.d $local_startup; do > sconfigs=3D"$sconfigs ${dir%/rc.d}/rc.conf.d/$_name" > done > done > sconfigs=3D"${sconfigs# }" > echo "sconfigs=3D[$sconfigs]=94 > =3D=3D=3D END FILE: sconfigs2.sh =3D=3D=3D >=20 > Given the above code, we can handle the afore-mentioned edge-casen: >=20 > $ ./sconfigs2.sh dhclient > sconfigs=3D[/etc/rc.conf.d/dhclient /usr/local/etc/rc.conf.d/dhclient = /etc/rc.conf.d/network /usr/local/etc/rc.conf.d/network] > $ ./sconfigs2.sh initrandom > sconfigs=3D[/etc/rc.conf.d/random /usr/local/etc/rc.conf.d/random] > $ ./sconfigs2.sh postrandom > sconfigs=3D[/etc/rc.conf.d/random /usr/local/etc/rc.conf.d/random] > $ ./sconfigs2.sh swaplate > sconfigs=3D[/etc/rc.conf.d/swap /usr/local/etc/rc.conf.d/swap] > $ ./sconfigs2.sh local_unbound > sconfigs=3D[/etc/rc.conf.d/local_unbound = /usr/local/etc/rc.conf.d/local_unbound] > $ ./sconfigs2.sh=20 > does not exist in /etc/rc.d or the local startup > directories (/usr/local/etc/rc.d) > $ ./sconfigs2.sh nosuchservice > nosuchservice does not exist in /etc/rc.d or the local startup > directories (/usr/local/etc/rc.d) >=20 >=20 > This is looking like a much better approach. >=20 [snip] =97=20 Cheers, Devin= From owner-freebsd-hackers@freebsd.org Fri Aug 28 08:47:47 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E56B09C4DDF for ; Fri, 28 Aug 2015 08:47:47 +0000 (UTC) (envelope-from timp87@gmail.com) Received: from mail-wi0-x233.google.com (mail-wi0-x233.google.com [IPv6:2a00:1450:400c:c05::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7139CF76; Fri, 28 Aug 2015 08:47:47 +0000 (UTC) (envelope-from timp87@gmail.com) Received: by wicfv10 with SMTP id fv10so5297675wic.0; Fri, 28 Aug 2015 01:47:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=LDvdIpqumJSvuTtQ6gI8m5u70PBgE4QanPLCnupNTgU=; b=JWy/IRH/8BJlSJnls4A6kII2DmjDVMzJdKCYrbcvg4rVhvUKBF2klc5Yz4+/lWUWpJ e5JRv0sbG0lNyrlU435/q38lnheVi1im2w3CpaaNK/Ux81dwMTtM2i8z/fwZkIlimEVx jIEudfBMGOwjKE9mf0kN8eIITG4VRb04T3RJKQ5U57GYO+LPY2qvYoZKjbb9RRQnQUR4 J8i6o+yovJfAWEVMG+ha24KSZhesDdv2DpxUrsVEfBVMZy604Xail1iHMHrzcbr+yhgU NG8VdiLd9fT0NqaHufDwNYJ8ji99Wx7J0BxQhQff3GoVbBHRm/fm13w0MtjJzco4bWf5 jYxA== MIME-Version: 1.0 X-Received: by 10.180.100.40 with SMTP id ev8mr3225389wib.14.1440751665863; Fri, 28 Aug 2015 01:47:45 -0700 (PDT) Received: by 10.28.9.195 with HTTP; Fri, 28 Aug 2015 01:47:45 -0700 (PDT) In-Reply-To: <55DF261C.80009@freebsd.org> References: <55DF261C.80009@freebsd.org> Date: Fri, 28 Aug 2015 11:47:45 +0300 Message-ID: Subject: Re: How to control and setup service? From: Pavel Timofeev To: Allan Jude Cc: freebsd-hackers@freebsd.org, Devin Teske Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 08:47:48 -0000 2015-08-27 18:00 GMT+03:00 Allan Jude : > On 2015-08-27 09:21, Pavel Timofeev wrote: >> Hi! Good day! >> >> let me declare something first: >> HOPE="I just should know about that dir/sruff and hope that nothing >> will change in future releases"; >> >> >> I'm trying to write some automation code to manipulate services. >> There is no problem with installing service, I can just use pkg(8) to >> search/install/remove service. >> Like following: >> # pkg install mysql56-server >> No problem. pkg(8) covers pretty much everything. >> >> >> >> But I have problems with starting and enabling services. >> >> >> >> Ok, to start a service we have rc scripts. If it's a base system >> service then it has rc script in /etc/rc.d dir. >> If a service is installed from packages (ports) then an rc script is >> in /usr/local/etc/rc.d dir. >> So, first, I should check one dir then another. But how can I be sure >> I'm looking in right directories? >> Is there any way to ask FreeBSD "Hey! Where is you startup dirs?". I'd >> say yes, but only partially. >> >> /etc/rc.d dir is hardcoded everywhere. So $HOPE, which is not good IMO. >> >> "/usr/local/etc/rc.d" is ${local_startup} var which is defined in >> /etc/defaults/rc.conf. >> I can actually ask FreeBSD about that by calling: >> # sh -c '. /etc/rc.subr; load_rc_config "XXX"; echo $local_startup' >> Good! >> >> But in geretal, there is no way to ask FreeBSD for a complete list of >> startup dirs. So $HOPE. >> >> It would be pretty useful if I could ask FreeBSD for one variable like >> $all_startup, which would contain all of the startup dirs ("/etc/rc.d >> ${local_startup} ${new_startup_whatever}"). >> And it would be great if "/etc/rc.d" was defined as variable too. Like >> ${system_startup}="/etc/rc.d" (which is not simple I believe, it's >> hardcoded everywhere!). >> >> >> Thank god, there is a alternative way to start/stop services! >> It's service(8) tool that can do this stuff for me. I can rely on it, >> because it's a base system tool and I'm sure it knows everything about >> startup dirs, no matter what FreeBSD release I'm using. >> IMO service(8) covers this use case. >> So we can forget my ideas above. >> Or realize them because it can be useful for such tools like >> service(8), sysrc(8) or even your_new_tool(8), and code written once >> would not break in future ;) >> > > You don't need to do all of that. There is the service(8) command, and > it will do the searching for you. > > You can get a list of all of the rc scripts, in the correct order that > they are run during system startup using this command: > > service -e > > You can also do: service -l > > And it will list every installed service for you. Exactly! That's what I wanted to say actually as a conclusion. The following sentence about `realizing bla bla` is just a mad idea. >> >> >> Ok, imagine I started/stopped service. >> >> Then, to enable/disable service I should know a lot of stuff! >> >> To enable/disable service first thing that I should know is $rcvar of >> a service. It can be different than $service name (which is rc script >> name). >> I should find rc script in right place, but thank again to service(8) >> tool. I just can ask it with: >> # service mysql-server rcvar >> and get the $rcvar of service, no matter where startup script is. Good! >> >> Second thing I should know is if it's already enabled/disabled. >> # service mysql-server rcvar >> will output YES/NO besides $rcvar var name. >> FreeBSD 10 got good command for rc scripts - "enabled", which would >> answer us by its exit code. >> # service mysql-server enabled; echo $? >> Excellent! >> >> Third thing I should know is how I have to enable/disable service. >> How would I do that? Where would I do that? >> Is it directly disabled (if $sysadmin2 set mysql_enable="NO"), if so - >> where, or it just not enabled anywhere? >> How many config files do you know which can be used to enable/disable >> (control) service? What's their precedence? >> >> Well, most of us (probably) would use /etc/rc.conf to enable $service >> or to check if it's directly disabled. We would use $rcvar (!), not rc >> script name. >> But, FreeBSD has more places with higher precedence than /etc/rc.conf! >> It's /etc/rc.conf.local file, >> then /etc/rc.conf.d/$service file, >> then /etc/rc.conf.d/$service/* files. >> Then even /usr/local/etc/rc.conf.d/$service files and subdirs which >> appeared in FreeBSD 10! >> >> And there is no way to ask FreeBSD "Hey! Where is your config files to >> control services?". >> You can ask about them, but again, partially by running: >> # sh -c '. /etc/rc.subr; load_rc_config "XXX"; echo $rc_conf_files' >> which outputs "/etc/rc.conf /etc/rc.conf.local". >> Of course, there is no way to ask "Where this service is enabled/disabled?" >> So we can catch $rc_conf_files, but not a bunch of rc.conf.d dirs and >> subdirs. No way. So $HOPE, again, which is not good IMO. >> Why $HOPE? Because such change already happened between FreeBSD 9 and >> 10. So I should track such changes in my own code manually. >> >> As a way to solve this, I'd like to see some vars like $rc_conf_d_dirs >> which would point to "/etc/rc.conf.d >> ${local_startup%/rc.d}/rc.conf.d/". Or any way to get them. >> Now these dirs are "hardcoded" and used only in /etc/rc.subr here >> https://github.com/freebsd/freebsd/blob/master/etc/rc.subr#L1336-L1354. >> It's not used anywhere else. >> >> >> Thank good we have an alternative to this hell of manual editing and >> going through the list of dirs! You can forget about anything above. I >> can rely on it, because it's in the base system and I'm sure it knows >> any cases. >> It's a ... Hmm, where is it? >> Turns out, we don't have such tool. We have only sysrc(8), but it can >> only edit $rc_conf_files in safe way. There is no support for >> rc.conf.d dirs in sysrc(8). >> And, in general, it's a tool to just `edit` $rc_conf_files, not to >> control and configure services. > > sysrc automatically detects values from rc.conf.d directories, and can > edit them if you ask it to. It just defaults to writing your changes to > /etc/rc.conf I wouldn't say sysrc *automatically* detects values from rc.conf.d directories. > > My puppet scripts use: > sysrc -f /etc/rc.conf.d/varnish varnishd_identity="PDX1-01" > > and the the like all the time Exactly, you point sysrc(8) manually to file. In such case it works only with this specific file, ignoring /etc/rc.conf and /etc/rc.conf.local, which is not critical. But what is worse it ignores "/etc/rc.conf.d/$service/*", "/usr/local/etc/rc.conf.d/$service" and "/usr/local/etc/rc.conf.d/$service/*" files, which have higher precedence than your /etc/rc.conf.d/$service. So you should still manually track that cases. > >> >> As a user I would love to have a cool tool to control and configure >> services in way like OpenBSD's rcctl(8) does >> http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/rcctl.8?query=rcctl. >> # cooltool set mysql-server status on >> That's all. It would take care of those things like getting right >> $rcvar name, choose right rc config file to edit (remember, we have a >> lot of places to check, see above) and enable service, etc. >> This $cooltool can be an extended version of service(8) tool. >> More difficult example: >> # cooltool set flow_capture status on flags "-e 2200 -n 23 -N 0 -V 5" >> port "8787" datadir "/storage/flows/all_routers" >> would enable flow_capture service and set other stuff using right $rcvar. >> # cooltool get flow_capture >> would print all of the configured stuff for $service >> # cooltool get flow_capture status >> would print only a status YES/NO (don't forget about exit code ;) ) >> and etc. > > sysrc can do that, it will search all of the directories and find the > final answer. Well, it can't. It still needs your manual intervention. > The only thing it doesn't do is the translation between the 'service > name' (mysql-server) and the 'rcvar prefix' (mysql_), which might be a > useful addition, but might make more sense in the service command, > because when I pass something to sysrc, I expect it to be interpreted > literally. I guess it could be a flag for sysrc to specify the service > instead of the rcvar. > > sysrc -s mysql datadir=/var/db/mysql > >> IMO such tools would be useful even for ansible/puppet and friends. >> Not just for users ;) >> > > Teaching service to use sysrc might be useful. Making sysrc detect that > /etc/rc.conf.d/ exists, and use it, else fallback to > /etc/rc.conf might also be nice. > > service mysql-server enable|disable > sets mysql_enable="YES|NO" > service mysql-server set datadir=/var/db/mysql > sets mysql_datadir="/var/db/mysql" > > I am currently doing all of this in puppet with sysrc. Such tools is what I wrote this email for. >> >> I'm really sorry if I misunderstand something and wasted your time! >> And I don't want to offend anyone in case I'm impolite! >> >> P.S. Do you have any ideas? >> _______________________________________________ >> freebsd-hackers@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers >> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >> > > > -- > Allan Jude > From owner-freebsd-hackers@freebsd.org Fri Aug 28 08:58:36 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E8BD29C31AD for ; Fri, 28 Aug 2015 08:58:36 +0000 (UTC) (envelope-from timp87@gmail.com) Received: from mail-wi0-x22d.google.com (mail-wi0-x22d.google.com [IPv6:2a00:1450:400c:c05::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 859031380; Fri, 28 Aug 2015 08:58:36 +0000 (UTC) (envelope-from timp87@gmail.com) Received: by wicfv10 with SMTP id fv10so2537756wic.1; Fri, 28 Aug 2015 01:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=GxL4e0IGQIwNCW9Bn5HY9P7+2avfCBuvXQqgLCGtZ2s=; b=K64fflV7KphO7lO0W3GbksnBX0bLVNTaOtBglW1terxdm0rFGK4LwT1XbvhsffAWwj EoxcnD4D5AiuBS1EonXKpMiD6LyNEbcGm8Def9NwfdTbBwIQUp8V6FLIgon8qL2DRywG kCq4PB3Pk8i3yBzziyacm2x5NIU1l9jHIYDHLDXMNSsvy10aXW39hHa9uZ0U8IdzAsKN eSbwjqqNv7Gbw/mPB/0ysYL0jaxCSRO+74OHacV8fL4EPs+SJRy1X/7frlRgRqEtJbvD sjT3Ipef1YoFL6YOw92kg6SeQ2gRXOAcdkhFe3FAuu1QRSXMjW2MhX6V7R0RCy70oUiG 49RA== MIME-Version: 1.0 X-Received: by 10.180.108.103 with SMTP id hj7mr3180627wib.11.1440752315021; Fri, 28 Aug 2015 01:58:35 -0700 (PDT) Received: by 10.28.9.195 with HTTP; Fri, 28 Aug 2015 01:58:34 -0700 (PDT) In-Reply-To: <20150827200534.GH16003@e-new.0x20.net> References: <55DF261C.80009@freebsd.org> <20150827200534.GH16003@e-new.0x20.net> Date: Fri, 28 Aug 2015 11:58:34 +0300 Message-ID: Subject: Re: How to control and setup service? From: Pavel Timofeev To: Lars Engels Cc: Allan Jude , freebsd-hackers@freebsd.org, Devin Teske Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 08:58:37 -0000 2015-08-27 23:05 GMT+03:00 Lars Engels : > On Thu, Aug 27, 2015 at 11:00:44AM -0400, Allan Jude wrote: >> On 2015-08-27 09:21, Pavel Timofeev wrote: >> > IMO such tools would be useful even for ansible/puppet and friends. >> > Not just for users ;) >> > >> >> Teaching service to use sysrc might be useful. Making sysrc detect that >> /etc/rc.conf.d/ exists, and use it, else fallback to >> /etc/rc.conf might also be nice. >> >> service mysql-server enable|disable >> sets mysql_enable="YES|NO" >> service mysql-server set datadir=/var/db/mysql >> sets mysql_datadir="/var/db/mysql" > > There's already a patch in phabricator: > > https://reviews.freebsd.org/D451 Great! The supported features and syntax should be discussed more. For example, it can't set rcopts, just print them, as I can see. And I disagree with bapt@ and bdrewery@. IMO default place should be /etc/rc.conf. This behaviour could be controlled by some key. You already introduced '-s' key there. I like it! Finally, If a $service rcopts are already set in some file, this tool should use that file to supplement them. From owner-freebsd-hackers@freebsd.org Fri Aug 28 16:03:02 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AB6899C4DC6 for ; Fri, 28 Aug 2015 16:03:02 +0000 (UTC) (envelope-from timp87@gmail.com) Received: from mail-wi0-x233.google.com (mail-wi0-x233.google.com [IPv6:2a00:1450:400c:c05::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 43C3F37F; Fri, 28 Aug 2015 16:03:02 +0000 (UTC) (envelope-from timp87@gmail.com) Received: by wiae7 with SMTP id e7so1099908wia.0; Fri, 28 Aug 2015 09:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Qaye0ePtzvY+2hNft3o9yQxlvW/Ux+W0bTrr+oaXQfY=; b=mn/GsROwpeF9WnY7B7DPuOyNofvAtpBMXxNRS+tCgeppDBAB87D5XJZbyJlXHyicNB T0USS5n9S0WwsPGoCSj+V2Sj+z2VkOJD/x1iskkMnOKDcep8+ZESEAcDWtu/N4jQwebv escCss0bAHzsk8oVAWw716OwOmjv9Zx0PPMMsA90aFVBPRJ67Ez5MHbbUZUv1KlgcWu/ FJgPPQdL50hgMDlw3hkDtSoR7dIR8PTn1LUVZzQbexmFydEFKbG/X4i/yuu4/AEwd7GO HKJPN+uKV93hZAjEtwQZSwvBHwv6yJOxiiAY7iarxDrQsiG5Ofch37IQ2Mc6jhNC0oM6 2azQ== MIME-Version: 1.0 X-Received: by 10.180.19.102 with SMTP id d6mr5286939wie.86.1440777780744; Fri, 28 Aug 2015 09:03:00 -0700 (PDT) Received: by 10.28.9.195 with HTTP; Fri, 28 Aug 2015 09:03:00 -0700 (PDT) Received: by 10.28.9.195 with HTTP; Fri, 28 Aug 2015 09:03:00 -0700 (PDT) In-Reply-To: References: <55DF261C.80009@freebsd.org> <20150827200534.GH16003@e-new.0x20.net> Date: Fri, 28 Aug 2015 19:03:00 +0300 Message-ID: Subject: Re: How to control and setup service? From: Pavel Timofeev To: Lars Engels Cc: freebsd-hackers@freebsd.org, Devin Teske , Allan Jude Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 16:03:02 -0000 One more idea is to have a key that would delete from rc config file any other rcopts which are not being set by tool when user run it. Like delete all of already defined rcopts and then set only requested rcopts. 28 =D0=B0=D0=B2=D0=B3. 2015 =D0=B3. 11:58 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0= =BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C "Pavel Timofeev" =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB: > 2015-08-27 23:05 GMT+03:00 Lars Engels : > > On Thu, Aug 27, 2015 at 11:00:44AM -0400, Allan Jude wrote: > >> On 2015-08-27 09:21, Pavel Timofeev wrote: > >> > IMO such tools would be useful even for ansible/puppet and friends. > >> > Not just for users ;) > >> > > >> > >> Teaching service to use sysrc might be useful. Making sysrc detect tha= t > >> /etc/rc.conf.d/ exists, and use it, else fallback to > >> /etc/rc.conf might also be nice. > >> > >> service mysql-server enable|disable > >> sets mysql_enable=3D"YES|NO" > >> service mysql-server set datadir=3D/var/db/mysql > >> sets mysql_datadir=3D"/var/db/mysql" > > > > There's already a patch in phabricator: > > > > https://reviews.freebsd.org/D451 > > Great! > The supported features and syntax should be discussed more. > For example, it can't set rcopts, just print them, as I can see. > And I disagree with bapt@ and bdrewery@. > IMO default place should be /etc/rc.conf. This behaviour could be > controlled by some key. You already introduced '-s' key there. I like > it! > Finally, If a $service rcopts are already set in some file, this tool > should use that file to supplement them. > From owner-freebsd-hackers@freebsd.org Fri Aug 28 16:04:57 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 745269C4EB8 for ; Fri, 28 Aug 2015 16:04:57 +0000 (UTC) (envelope-from allanjude@freebsd.org) Received: from mx1.scaleengine.net (mx1.scaleengine.net [209.51.186.6]) by mx1.freebsd.org (Postfix) with ESMTP id 516976E9 for ; Fri, 28 Aug 2015 16:04:57 +0000 (UTC) (envelope-from allanjude@freebsd.org) Received: from [10.1.1.2] (unknown [10.1.1.2]) (Authenticated sender: allanjude.freebsd@scaleengine.com) by mx1.scaleengine.net (Postfix) with ESMTPSA id 978C796EE for ; Fri, 28 Aug 2015 16:04:56 +0000 (UTC) Subject: Re: How to control and setup service? To: freebsd-hackers@freebsd.org References: <55DF261C.80009@freebsd.org> <20150827200534.GH16003@e-new.0x20.net> From: Allan Jude Message-ID: <55E086D3.1040700@freebsd.org> Date: Fri, 28 Aug 2015 12:05:39 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IdNDH0vMe1bt1xhMUWRsnEH5mW5ePg9AQ" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 16:04:57 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --IdNDH0vMe1bt1xhMUWRsnEH5mW5ePg9AQ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2015-08-28 12:03, Pavel Timofeev wrote: > One more idea is to have a key that would delete from rc config file an= y > other rcopts which are not being set by tool when user run it. > Like delete all of already defined rcopts and then set only requested > rcopts. That is a big vague. If I understand correctly, you are saying, if you 'service mysql disable', you want it to delete mysql_datadir=3D ? I am not sure I like that. There is no harm in having the leftover variables left in place, and there is harm if you remove stuff people were expecting to keep around (if I say, disable the sql server before upgrading, and I don't want it to restart until I am sure my upgrade and 3 reboots have all gone successfully) --=20 Allan Jude --IdNDH0vMe1bt1xhMUWRsnEH5mW5ePg9AQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (MingW32) iQIcBAEBAgAGBQJV4IbTAAoJEBmVNT4SmAt+EygP/RQnSNFxYdTWv/35xmVSHdGB ulaaxT9vSSlYg/omLlX5UeKQM8sgSpwYTqKfPh3uBHR0BkmxOwGr156p7vEHFKoa 9SuhSc+qmT43AR3eALKq99UxPmJ85sbICAVVhC90l5TukO+FC1C21osM6hxmgdvd MGjVEwWv5FNcOcEd0D62fritJA1Bf4OGWwzorjhZex8Wpm2JRoWs2oKXGbZJncMN hr54CUzXsUgbsdLk93XMawDcXxxCj/TSHwKELXwRC3g3m7iZwnD7PZwlsLorpLjT DnVgq5Aqt7U+BN26tjnRfq1JUNjq1UfLjTeXwDnwzMGzrQcXjzQVEm1AODVcWiPL Io+RWMd3okQqfgBP4RnOh89+0jWrsOVgwERK7a7N2+HGea920bZNhuRuQUClYvhz K4sQTWGsha3WboRDLDR8uhuvNQT7r8GhZ8zs3bsi0jbgYKpJRZYB40AEZTqxe7ts nz4xY7WxrZ6oot52ggDPK000u9p370smJ2HUT5C4VTy+aGx2CNMV0VmYJmLJmHpt O/R33ERjqkG/JvQ2T7Nnp/BBIkH94dxM55finNzydbLcPCbtgPEulgoKIYRhI4AR 2Wk5CfL2ZtePhhi5yfL0Sd+USqoLvuzRkkseiwwOEQD2gTp2UEHfFQOPCpuHK1xJ R2aTqClcqlGYD9FTcy7j =I1N8 -----END PGP SIGNATURE----- --IdNDH0vMe1bt1xhMUWRsnEH5mW5ePg9AQ-- From owner-freebsd-hackers@freebsd.org Fri Aug 28 16:17:06 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1F2899C53B3 for ; Fri, 28 Aug 2015 16:17:06 +0000 (UTC) (envelope-from timp87@gmail.com) Received: from mail-wi0-x22e.google.com (mail-wi0-x22e.google.com [IPv6:2a00:1450:400c:c05::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AC2F9EDC; Fri, 28 Aug 2015 16:17:05 +0000 (UTC) (envelope-from timp87@gmail.com) Received: by wibcx1 with SMTP id cx1so1273018wib.1; Fri, 28 Aug 2015 09:17:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=yHo3C2NLtiOSmWfRCzzZum9j7tNRZ0xiz9flB5GrYZc=; b=Lwi2NJNAUw94zg4wpSY74o0wnLtntrAm8vZ6Y7MDyMIWRIdVw/e5tTrp2MI/grVQcl OOXHk5J0TgHRb1AqI5c8BOq7n5LPdiwG/sW5NL98FawtqguPgF9llX+1HVImLv2Fp4fw IHBoFrFswbOlN1G3aGSdGLaM+9XQzBHVt1oV6r6Ma1c8zaUSRbL86Ss/68EzrL5ZdWCV xbGmKK4iHwdcH4kG+MZ1QPowEudYEfRNtVK52+Uxj2UrrTYLvcxS7yHGMFas6N/9U60A DYufw4uNB8aPbCmv1CW4BYoLyFB9YQGGdmN+mpRXq6TGAwfixe9XRjVe/23ExkuI3hEG Kqmw== MIME-Version: 1.0 X-Received: by 10.194.2.9 with SMTP id 9mr11818149wjq.95.1440778623930; Fri, 28 Aug 2015 09:17:03 -0700 (PDT) Received: by 10.28.9.195 with HTTP; Fri, 28 Aug 2015 09:17:03 -0700 (PDT) Received: by 10.28.9.195 with HTTP; Fri, 28 Aug 2015 09:17:03 -0700 (PDT) In-Reply-To: <55E086D3.1040700@freebsd.org> References: <55DF261C.80009@freebsd.org> <20150827200534.GH16003@e-new.0x20.net> <55E086D3.1040700@freebsd.org> Date: Fri, 28 Aug 2015 19:17:03 +0300 Message-ID: Subject: Re: How to control and setup service? From: Pavel Timofeev To: Allan Jude Cc: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 16:17:06 -0000 A special key, not defaul behaviour 28 =D0=B0=D0=B2=D0=B3. 2015 =D0=B3. 19:05 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0= =BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C "Allan Jude" =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB: > On 2015-08-28 12:03, Pavel Timofeev wrote: > > One more idea is to have a key that would delete from rc config file an= y > > other rcopts which are not being set by tool when user run it. > > Like delete all of already defined rcopts and then set only requested > > rcopts. > > That is a big vague. > > If I understand correctly, you are saying, if you 'service mysql > disable', you want it to delete mysql_datadir=3D ? > > I am not sure I like that. There is no harm in having the leftover > variables left in place, and there is harm if you remove stuff people > were expecting to keep around (if I say, disable the sql server before > upgrading, and I don't want it to restart until I am sure my upgrade and > 3 reboots have all gone successfully) > > -- > Allan Jude > > From owner-freebsd-hackers@freebsd.org Fri Aug 28 16:07:29 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F00A69C4FB5 for ; Fri, 28 Aug 2015 16:07:28 +0000 (UTC) (envelope-from dteske@panzura.com) Received: from mail-pa0-x236.google.com (mail-pa0-x236.google.com [IPv6:2607:f8b0:400e:c03::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C137D860 for ; Fri, 28 Aug 2015 16:07:28 +0000 (UTC) (envelope-from dteske@panzura.com) Received: by pabzx8 with SMTP id zx8so67093918pab.1 for ; Fri, 28 Aug 2015 09:07:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=panzura.com; s=google; h=content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=QRyP3rLtSaITtdQtCZ7GOeEdzETTkeK8UkGC03FVVEg=; b=RWoLjeXdzqKR/o59QX7Vpg57ERewQBGU9lgR6mJh7crvOG167cOa4H2svfUEQPYF9N 7xrFk2o1N1dy/WGPjuC0BlBkmws6efQwaettfNtLXa0KhIRThhd/DC56Giox6a40G2cr HBKF6kz0E12gKVbd1OEbApPOX9zmX8Zepk1JI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:message-id:references:to; bh=QRyP3rLtSaITtdQtCZ7GOeEdzETTkeK8UkGC03FVVEg=; b=Im3GKqSM1w5wdLWljQr9akGLEJOQP78jdycApN+ZbyAhZU4/nIYpf49fO36qvHHnSF z6O3LiT89/24qeNR5klEhbj9nJzIdpIPBWm114QlJ8NB7JOM8h5Nm8FH/RubG7IOvqvd 2q55AaYRwkyurDbxiuceZ2VWUaG6fbfpDqjoVjQlqTqn0MEdFKDO0twnSt6K/N6Jgzsf kl3H195UKr7j7jbTCmdqe3CDdAIOaLrrhBcFeZK8AuRD1RnYZAEAphKysAqkXe2NjlIS iHHY75EdvO2m38DIL5K/qrW/FVxwJ2St4DWlD+Ddn6zOhE9r3icprf1Unz94ZHwZAP0w +XfQ== X-Gm-Message-State: ALoCoQl05KUF34RR3egrDPwu19yM0ht3yrh/2iIkQ8B+ULBhDKdZW3VEy0PLPHy+Mp/QXYnpRApm X-Received: by 10.66.148.136 with SMTP id ts8mr16859439pab.15.1440778048055; Fri, 28 Aug 2015 09:07:28 -0700 (PDT) Received: from tinkerbell.pixel8networks.com ([12.179.176.146]) by smtp.gmail.com with ESMTPSA id xv1sm6186386pbb.25.2015.08.28.09.07.24 (version=TLS1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Aug 2015 09:07:27 -0700 (PDT) Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Subject: Re: How to control and setup service? From: Devin Teske In-Reply-To: Date: Fri, 28 Aug 2015 09:07:24 -0700 Cc: Lars Engels , freebsd-hackers@freebsd.org, Allan Jude , Devin Teske Message-Id: <52FF4E1C-F3EF-4FB7-A84E-F65E1CD14D69@panzura.com> References: <55DF261C.80009@freebsd.org> <20150827200534.GH16003@e-new.0x20.net> To: Pavel Timofeev X-Mailer: Apple Mail (2.2102) X-Mailman-Approved-At: Fri, 28 Aug 2015 16:29:36 +0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 16:07:29 -0000 > On Aug 28, 2015, at 9:03 AM, Pavel Timofeev wrote: >=20 > One more idea is to have a key that would delete from rc config file = any other rcopts which are not being set by tool when user run it. > Like delete all of already defined rcopts and then set only requested = rcopts. >=20 >=20 Like =E2=80=9Csysrc -x =E2=80=A6=E2=80=9D ? =E2=80=94=20 Devin From owner-freebsd-hackers@freebsd.org Fri Aug 28 16:51:19 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5264F9C303B for ; Fri, 28 Aug 2015 16:51:19 +0000 (UTC) (envelope-from timp87@gmail.com) Received: from mail-wi0-x22f.google.com (mail-wi0-x22f.google.com [IPv6:2a00:1450:400c:c05::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E0B45D8B; Fri, 28 Aug 2015 16:51:18 +0000 (UTC) (envelope-from timp87@gmail.com) Received: by wicfv10 with SMTP id fv10so17314946wic.0; Fri, 28 Aug 2015 09:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=xkKOQuxaQW5WmjDhBvGA1xYRCrixeSlPO3oodll+MLo=; b=bhK3TzragDCmD1BXm1g3BhSLr2x9pV9kOpqBmNnsZjbl/ePxNXDINEqI0CLjKLAhQu BFjU836YTQJxbzROwtRRWJpmPo0hdGU6sNioD73MOjZKedyV6g2+6xB7XSvEQNIaWThv n0uquiUTRrs1W6ZkODBzBKnmP9BRkDuZIBSLd3AGiMlqUS48umnCl57fyKUt0lpybPWr DWynlE40uxGEHXw6eIMJHr8Kcgptk8dQQo/ocPncVdm6bY4Py8TizhQmGf0Fa58XqkOV HxsqpxOo17pbfx3BUSJsHMdm3FgzsN8GSS87DpC9MRg9ujJ9gEVG64/GEZBSYP11mPfo GuVQ== MIME-Version: 1.0 X-Received: by 10.194.172.233 with SMTP id bf9mr12448375wjc.107.1440780677253; Fri, 28 Aug 2015 09:51:17 -0700 (PDT) Received: by 10.28.9.195 with HTTP; Fri, 28 Aug 2015 09:51:17 -0700 (PDT) In-Reply-To: References: <55DF261C.80009@freebsd.org> <20150827200534.GH16003@e-new.0x20.net> <55E086D3.1040700@freebsd.org> Date: Fri, 28 Aug 2015 19:51:17 +0300 Message-ID: Subject: Re: How to control and setup service? From: Pavel Timofeev To: Allan Jude Cc: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 16:51:19 -0000 2015-08-28 19:17 GMT+03:00 Pavel Timofeev : > A special key, not defaul behaviour > > 28 =D0=B0=D0=B2=D0=B3. 2015 =D0=B3. 19:05 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7= =D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C "Allan Jude" > =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB: > >> On 2015-08-28 12:03, Pavel Timofeev wrote: >> > One more idea is to have a key that would delete from rc config file a= ny >> > other rcopts which are not being set by tool when user run it. >> > Like delete all of already defined rcopts and then set only requested >> > rcopts. >> >> That is a big vague. >> >> If I understand correctly, you are saying, if you 'service mysql >> disable', you want it to delete mysql_datadir=3D ? >> >> I am not sure I like that. There is no harm in having the leftover >> variables left in place, and there is harm if you remove stuff people >> were expecting to keep around (if I say, disable the sql server before >> upgrading, and I don't want it to restart until I am sure my upgrade and >> 3 reboots have all gone successfully) >> >> -- >> Allan Jude >> > Sorry for top posting! It's pretty hard to write email walking under heavy rain and umbrella. So, I talked about special key, not default behaviour. Let me give you an example. You got a server (or ten) which was/were somehow configured before you. You want to reconfigure it/them. You don't care how and where it's already configured, you just want to set particular rcvars and be sure that no other rcvars are set. Before you came it was: mysql_enable=3D"YES/NO" # no matter mysql_datadir=3D"/mycozystorage/db/mysql" mysql_defaults_extra_file=3D"/mycozystorage/mysql/my.cnf" mysql_plugin_dir=3D"/somewhere/lib/mysql/plugin" mysql_log_error=3D"/mycozystorage/db/mysql/hostname.err" then you run something like (look at -k key) # service -k mysql-server enable set datadir "/mysqldb" log_error "/mysqllogs/hostname.err" it becomes mysql_enable=3D"YES" mysql_datadir=3D"/mysqldb" mysql_log_error=3D"/mysqllogs/hostname.err" I. e. sets what requested and deletes rcvars which was not requested. From owner-freebsd-hackers@freebsd.org Sat Aug 29 09:50:12 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 662C59C55CA for ; Sat, 29 Aug 2015 09:50:12 +0000 (UTC) (envelope-from se@freebsd.org) Received: from mailout11.t-online.de (mailout11.t-online.de [194.25.134.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mailout00.t-online.de", Issuer "TeleSec ServerPass DE-1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 25C23CB2; Sat, 29 Aug 2015 09:50:12 +0000 (UTC) (envelope-from se@freebsd.org) Received: from fwd24.aul.t-online.de (fwd24.aul.t-online.de [172.20.26.129]) by mailout11.t-online.de (Postfix) with SMTP id DB8E3279944; Sat, 29 Aug 2015 11:50:09 +0200 (CEST) Received: from [192.168.119.17] (rfFR3TZHQhgaiFr7jr7PZm8T5fA5t3oQhiaft6NtGIQx6iu59G76Tl3JENzNP0MgCA@[87.151.208.233]) by fwd24.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-SHA encrypted) esmtp id 1ZVclv-0dSW800; Sat, 29 Aug 2015 11:50:03 +0200 Subject: Re: How to control and setup service? To: freebsd-hackers@freebsd.org References: <55DF261C.80009@freebsd.org> <20150827200534.GH16003@e-new.0x20.net> <55E086D3.1040700@freebsd.org> Cc: timp87@gmail.com From: Stefan Esser X-Enigmail-Draft-Status: N1110 Message-ID: <55E1803E.7080706@freebsd.org> Date: Sat, 29 Aug 2015 11:49:50 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-ID: rfFR3TZHQhgaiFr7jr7PZm8T5fA5t3oQhiaft6NtGIQx6iu59G76Tl3JENzNP0MgCA X-TOI-MSGID: 17a76186-65e0-41bd-8a30-8098a055041c X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 09:50:12 -0000 Am 28.08.2015 um 18:51 schrieb Pavel Timofeev: > Sorry for top posting! It's pretty hard to write email walking under > heavy rain and umbrella. > So, I talked about special key, not default behaviour. > Let me give you an example. > You got a server (or ten) which was/were somehow configured before you. > You want to reconfigure it/them. You don't care how and where it's > already configured, you just want to set particular rcvars and be sure > that no other rcvars are set. > > Before you came it was: > mysql_enable="YES/NO" # no matter > mysql_datadir="/mycozystorage/db/mysql" > mysql_defaults_extra_file="/mycozystorage/mysql/my.cnf" > mysql_plugin_dir="/somewhere/lib/mysql/plugin" > mysql_log_error="/mycozystorage/db/mysql/hostname.err" > > then you run something like (look at -k key) > # service -k mysql-server enable set datadir "/mysqldb" log_error > "/mysqllogs/hostname.err" > it becomes > mysql_enable="YES" > mysql_datadir="/mysqldb" > mysql_log_error="/mysqllogs/hostname.err" > > I. e. sets what requested and deletes rcvars which was not requested. I think that the removal of the previous config state should not come as the side-effect of some "set" command. I'd rather introduce a now verb for this purpose, which has the effect of clearing all previous settings for a service, instead of overloading the "set" operation. E.g.: # service mysql-server clearconfig Not sure about the best command name to use, it could also be "clean" or "initconfig" or "defaultconfig". The semantics is that all the rc.conf assignments for thise service are removed (including the enable line) and the defaults from defaults/rc.conf become effective again. Regards, STefan From owner-freebsd-hackers@freebsd.org Sat Aug 29 15:04:41 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5C6AA9C48C6 for ; Sat, 29 Aug 2015 15:04:41 +0000 (UTC) (envelope-from allanjude@freebsd.org) Received: from mx1.scaleengine.net (mx1.scaleengine.net [209.51.186.6]) by mx1.freebsd.org (Postfix) with ESMTP id 201121FE0 for ; Sat, 29 Aug 2015 15:04:40 +0000 (UTC) (envelope-from allanjude@freebsd.org) Received: from [10.1.1.2] (unknown [10.1.1.2]) (Authenticated sender: allanjude.freebsd@scaleengine.com) by mx1.scaleengine.net (Postfix) with ESMTPSA id 1560D95C7 for ; Sat, 29 Aug 2015 15:04:40 +0000 (UTC) Subject: Re: How to control and setup service? To: freebsd-hackers@freebsd.org References: <55DF261C.80009@freebsd.org> <20150827200534.GH16003@e-new.0x20.net> <55E086D3.1040700@freebsd.org> <55E1803E.7080706@freebsd.org> From: Allan Jude Message-ID: <55E1CA2D.5020203@freebsd.org> Date: Sat, 29 Aug 2015 11:05:17 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55E1803E.7080706@freebsd.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="StKRpSrtvQEjTk7udVAxIiN1p6gjTDStU" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 15:04:41 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --StKRpSrtvQEjTk7udVAxIiN1p6gjTDStU Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 2015-08-29 05:49, Stefan Esser wrote: > Am 28.08.2015 um 18:51 schrieb Pavel Timofeev: >> Sorry for top posting! It's pretty hard to write email walking under >> heavy rain and umbrella. >> So, I talked about special key, not default behaviour. >> Let me give you an example. >> You got a server (or ten) which was/were somehow configured before you= =2E >> You want to reconfigure it/them. You don't care how and where it's >> already configured, you just want to set particular rcvars and be sure= >> that no other rcvars are set. >> >> Before you came it was: >> mysql_enable=3D"YES/NO" # no matter >> mysql_datadir=3D"/mycozystorage/db/mysql" >> mysql_defaults_extra_file=3D"/mycozystorage/mysql/my.cnf" >> mysql_plugin_dir=3D"/somewhere/lib/mysql/plugin" >> mysql_log_error=3D"/mycozystorage/db/mysql/hostname.err" >> >> then you run something like (look at -k key) >> # service -k mysql-server enable set datadir "/mysqldb" log_error >> "/mysqllogs/hostname.err" >> it becomes >> mysql_enable=3D"YES" >> mysql_datadir=3D"/mysqldb" >> mysql_log_error=3D"/mysqllogs/hostname.err" >> >> I. e. sets what requested and deletes rcvars which was not requested. >=20 > I think that the removal of the previous config state should not come > as the side-effect of some "set" command. >=20 > I'd rather introduce a now verb for this purpose, which has the effect > of clearing all previous settings for a service, instead of overloading= > the "set" operation. >=20 > E.g.: >=20 > # service mysql-server clearconfig >=20 > Not sure about the best command name to use, it could also be "clean" > or "initconfig" or "defaultconfig". The semantics is that all the > rc.conf assignments for thise service are removed (including the > enable line) and the defaults from defaults/rc.conf become effective > again. >=20 > Regards, STefan > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.o= rg" >=20 I agree that that is a better design, as I would almost never actually want to remove those extra settings, and if it happened unexpectedly, I would be quite upset. --=20 Allan Jude --StKRpSrtvQEjTk7udVAxIiN1p6gjTDStU Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (MingW32) iQIcBAEBAgAGBQJV4coxAAoJEBmVNT4SmAt+hUAP/jcUpJzHnD2NiT7wQiXFc2+H 3KUtNzwc3UjDs5Xmw01iNJHZfrMcvltT4EgkaRuBIDE7h1JGrXJVuQ2fPmbRSLZw n9usA+NCOAD9iCw80rhdW4jltuADJ7/1e7HIUTHjZIgo3AdDYFYMcCRdFWzUiKhk 1lkAdOCZdu5T6KkNdNWbvudTnls1BzR6rL3UA6R/5GN9LREHEFPhbx3Flm1vypIm /fUR/e1NZu2uEdMTogmjv8qhikxSe80rx8UkMcJe10c2mNzvLsx7P4Ba0kiKgQcm rR33wzTyJq4LmaVRkyzeckXIzBVAVkQTYo+5TCiLmG13J19SVynQWx1K+GeH2TbG k6pOmCsdnyr2WUJq7Cturj/aeEFJiPJcs4QUfp8ucvw6UaJqBC8MRdjv3z3SD+Qz UzYd6/s59nRENhvjtqm+HaSqnsolspQZbgSQzvLHznEPSPwIprk77Ra783Mxl7uL 5HYMzsM0HH5CztD9wIPhWMqGDiPUua869rg8bGBntXox1f6SpgZouKB5hB74JcyB HxLOAqDHIfMhkE3LIufr1gBszx9l4liverTz9wmjxCL8VdASJXjNxDuOiRgtkwmq WPlsyHPIpcpyuJqRT0SNYOOgbzVrsWxS2iAn1QbscoB3nqHrjow2fxFGuFIwVOLv xhSldNonVCoz6jlCdETg =MtgZ -----END PGP SIGNATURE----- --StKRpSrtvQEjTk7udVAxIiN1p6gjTDStU--