From owner-freebsd-rc@FreeBSD.ORG Sat Jul 19 16:08:15 2014 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3D4B1D0E; Sat, 19 Jul 2014 16:08:15 +0000 (UTC) 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 did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 95F312753; Sat, 19 Jul 2014 16:08:14 +0000 (UTC) Received: from e-new.0x20.net (mail.0x20.net [IPv6:2001:aa8:fffb:1::3]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.0x20.net (Postfix) with ESMTPS id 9D5EC6A6005; Sat, 19 Jul 2014 18:08:10 +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 s6JG8A6t024494; Sat, 19 Jul 2014 18:08:10 +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 s6JG89x0023382; Sat, 19 Jul 2014 18:08:09 +0200 (CEST) (envelope-from lars) Date: Sat, 19 Jul 2014 18:08:09 +0200 From: Lars Engels To: Adrian Chadd Subject: [PATCHES] Extend service(8) and rc(8) was: Re: HOWTO articles for migrating from Linux to FreeBSD, especially for pkg? Message-ID: <20140719160809.GU96250@e-new.0x20.net> Mail-Followup-To: Lars Engels , Adrian Chadd , Andreas Nilsson , Navdeep Parhar , Craig Rodrigues , freebsd-doc@freebsd.org, Alberto Mijares , freebsd-current Current , ports , freebsd-rc@freebsd.org References: <53C82EC4.8060304@gmail.com> <20140718142835.GF96250@e-new.0x20.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ElEgulhWJDonIdTi" Content-Disposition: inline In-Reply-To: X-Editor: VIM - Vi IMproved 7.4 X-Operation-System: FreeBSD 8.4-RELEASE-p4 User-Agent: Mutt/1.5.23 (2014-03-12) Cc: freebsd-rc@freebsd.org, ports , freebsd-doc@freebsd.org, Alberto Mijares , freebsd-current Current , Andreas Nilsson , Navdeep Parhar X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jul 2014 16:08:15 -0000 --ElEgulhWJDonIdTi Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 18, 2014 at 12:10:34PM -0700, Adrian Chadd wrote: > Hi! >=20 >=20 > On 18 July 2014 07:28, Lars Engels wrote: > > On Thu, Jul 17, 2014 at 10:21:17PM +0200, Andreas Nilsson wrote: > >> On Thu, Jul 17, 2014 at 10:15 PM, Navdeep Parhar w= rote: > >> > >> > On 07/17/14 13:12, Adrian Chadd wrote: > >> > > On 17 July 2014 13:03, Alberto Mijares wrote: > >> > >> On Thu, Jul 17, 2014 at 2:58 PM, Adrian Chadd > >> > wrote: > >> > >>> Hi! > >> > >>> > >> > >>> 3) The binary packages need to work out of the box > >> > >>> 4) .. which means, when you do things like pkg install apache, it > >> > >>> can't just be installed and not be enabled, because that's a bit= of a > >> > >>> problem; > >> > >> > >> > >> > >> > >> No. Please NEVER do that! The user must be able to edit the files= and > >> > >> start the service by himself. > >> > > > >> > > Cool, so what's the single line command needed to type in to start= a > >> > > given package service? > >> > > >> > Aren't sysrc(8) and service(8) for this kind of stuff? > >> > > >> > >> They sure are. > >> > >> Well, pkg install $service ; sysrc ${service}_enable=3D"YES" would do. > >> Although some services have different names than the packge, which is = sort > >> of annoying. > > > > I hacked up a solution for service(8): > > > > http://bsd-geek.de/FreeBSD/service.sh.enable-disable.patch > > > > The patch adds the following directives to service(8): > > > > enable: Grabs an rc script's rcvar value and runs "sysrc foo_enable=3DY= ES" > > disable: The opposite of enable > > rcdelete: Deletes an rc script's rcvar value from /etc/rc.conf using > > "sysrc -x foo_enable" > > > > The nice thing about is that you can use one of the new directives on > > one line with the old ones, as long as the new are the first argument: > > > > # service syslogd enable > > # service apache24 disable stop > > # service apache24 rcdelete stop > > # service nginx enable start > > > > > > So after installing a package, to start and enable a daemon permanently > > all you have to run is > > # service foo enable start > > > > Lars > > > > P.S.: Thansk to Devin for his hard work on sysrc! >=20 > Having a way for sysrc and service to know what particular options and > services are exposed by a given package or installed "thing" would be > nice. Right now the namespace is very flat and it's not obvious in all > instances what needs to happen to make it useful and what the options > are. >=20 > "Oh, hm, I'd like to know what options there are for controlling the > installed apache24 package, let's see"... >=20 > I remember IRIX having that command to list services, stop them and > start them, configure them enabled and disabled. Solaris grew > something like that with Solaris 10 and after the initial learning > curve it was great. Hving something like that would be 100% awesome. I've updated the patch and extended it a little: https://phabric.freebsd.org/D451 It can now print the rc options for a service. It needs however to have the options listed as comments between the KEYWORDS section and the sourcing of /etc/rc.subr. And I've made some changes to rc.subr itself: https://phabric.freebsd.org/D452 So now you can use # service sshd describe Secure Shell Daemon and # service sshd extracommands configtest keygen reload Sorry for the mess in phabricator's SUMMARY. I will learn the markup syntax later... Lars --ElEgulhWJDonIdTi Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQF8BAEBCgBmBQJTypfpXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ4RjQwMDE3RTRERjUzMTI1N0FGRTUxNDlF NTRDQjM3RDNBMDg5RDZEAAoJEOVMs306CJ1twRoH/jnqPDvSF3PxNhIqJPM9zmaa afViSj5ONY67Y1KsU39vZcM0eqfCSYWoPlZXB93Cj5mK01BcdaxDDMYOrNhx2rwT dq4ZRzYbtuCKNIrwkCqBrLHUmlzGoRP1txv9fpX/skAVN1Ftf9DcDZHsw+CoLbfI DrxeVu0OnTNqX6SjqeY/cEjgcmC2uUEpk4os7axaY5PDmGkmxfeHD0gWMazOqrJT /4G1C7WBBdyNJrGI9D1Llfk76IuVZicy9uj9BXpp6CeVL+sFt48F+DRzOpdx+sIM DwcEOItw6MI6cD4kV59+/3OhiB4dws2ZYI5mNl2jmXm9jVwAmrk/4Ip1nVytNFs= =ij8V -----END PGP SIGNATURE----- --ElEgulhWJDonIdTi-- From owner-freebsd-rc@FreeBSD.ORG Sat Jul 19 19:56:44 2014 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3FDC6BAE; Sat, 19 Jul 2014 19:56:44 +0000 (UTC) Received: from mail-qa0-x22d.google.com (mail-qa0-x22d.google.com [IPv6:2607:f8b0:400d:c00::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3F8A72935; Sat, 19 Jul 2014 19:56:43 +0000 (UTC) Received: by mail-qa0-f45.google.com with SMTP id cm18so3909063qab.4 for ; Sat, 19 Jul 2014 12:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=N9f9rWoHVKJDOpFI/JymFxXkffO4Xe3MkhRqycxthLI=; b=Wu7VIef+qaAJjPfGMmzMkJyJTNzwgTjVdueJpG4iJwPyHHINBY6NOSnO3NtWPfNseY hT4/QjZvKjF8L+mm+2xoMTR7mUSEAOc9q13AznS/aYwXfayRR7S/hNNmPxChwjvSg+kh EIn41Tq8GBSfy1Q9ovTEwYWYp+hBGNfsCPDot8T4yRbzfrrsjhP5KhOtErd+dJIQp7Ov Y3nJBFAc3hT12vsYklOg9EeoX32e1xF9d2tcg6GFU6cqYfc6syzbZufn/AbWaN3D4Sef BrmKv6pVMPo8u4PFaXxeU2VIWWnfBdKV1+CSA7HchrUQg6woqkzzLBL4K6KiXjCK2+VK D3Kg== MIME-Version: 1.0 X-Received: by 10.224.55.131 with SMTP id u3mr6888928qag.98.1405799802382; Sat, 19 Jul 2014 12:56:42 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.224.1.6 with HTTP; Sat, 19 Jul 2014 12:56:42 -0700 (PDT) In-Reply-To: <20140719160809.GU96250@e-new.0x20.net> References: <53C82EC4.8060304@gmail.com> <20140718142835.GF96250@e-new.0x20.net> <20140719160809.GU96250@e-new.0x20.net> Date: Sat, 19 Jul 2014 12:56:42 -0700 X-Google-Sender-Auth: PDfK75sIuDebJ6pOReNsY4AUKBA Message-ID: Subject: Re: [PATCHES] Extend service(8) and rc(8) was: Re: HOWTO articles for migrating from Linux to FreeBSD, especially for pkg? From: Adrian Chadd To: Lars Engels , Adrian Chadd , Andreas Nilsson , Navdeep Parhar , Craig Rodrigues , freebsd-doc@freebsd.org, Alberto Mijares , freebsd-current Current , ports , freebsd-rc@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Mailman-Approved-At: Sat, 19 Jul 2014 23:28:52 +0000 X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jul 2014 19:56:44 -0000 Hi! I like it! It's a useful command line API. Eventually people will realise there needs to be a more formal method for describing/controlling the underlying framework, but I leave that up to bapt to figure out and .. well, push people to do. :) Thanks! -a On 19 July 2014 09:08, Lars Engels wrote: > On Fri, Jul 18, 2014 at 12:10:34PM -0700, Adrian Chadd wrote: >> Hi! >> >> >> On 18 July 2014 07:28, Lars Engels wrote: >> > On Thu, Jul 17, 2014 at 10:21:17PM +0200, Andreas Nilsson wrote: >> >> On Thu, Jul 17, 2014 at 10:15 PM, Navdeep Parhar wrote: >> >> >> >> > On 07/17/14 13:12, Adrian Chadd wrote: >> >> > > On 17 July 2014 13:03, Alberto Mijares wrote: >> >> > >> On Thu, Jul 17, 2014 at 2:58 PM, Adrian Chadd >> >> > wrote: >> >> > >>> Hi! >> >> > >>> >> >> > >>> 3) The binary packages need to work out of the box >> >> > >>> 4) .. which means, when you do things like pkg install apache, it >> >> > >>> can't just be installed and not be enabled, because that's a bit of a >> >> > >>> problem; >> >> > >> >> >> > >> >> >> > >> No. Please NEVER do that! The user must be able to edit the files and >> >> > >> start the service by himself. >> >> > > >> >> > > Cool, so what's the single line command needed to type in to start a >> >> > > given package service? >> >> > >> >> > Aren't sysrc(8) and service(8) for this kind of stuff? >> >> > >> >> >> >> They sure are. >> >> >> >> Well, pkg install $service ; sysrc ${service}_enable="YES" would do. >> >> Although some services have different names than the packge, which is sort >> >> of annoying. >> > >> > I hacked up a solution for service(8): >> > >> > http://bsd-geek.de/FreeBSD/service.sh.enable-disable.patch >> > >> > The patch adds the following directives to service(8): >> > >> > enable: Grabs an rc script's rcvar value and runs "sysrc foo_enable=YES" >> > disable: The opposite of enable >> > rcdelete: Deletes an rc script's rcvar value from /etc/rc.conf using >> > "sysrc -x foo_enable" >> > >> > The nice thing about is that you can use one of the new directives on >> > one line with the old ones, as long as the new are the first argument: >> > >> > # service syslogd enable >> > # service apache24 disable stop >> > # service apache24 rcdelete stop >> > # service nginx enable start >> > >> > >> > So after installing a package, to start and enable a daemon permanently >> > all you have to run is >> > # service foo enable start >> > >> > Lars >> > >> > P.S.: Thansk to Devin for his hard work on sysrc! >> >> Having a way for sysrc and service to know what particular options and >> services are exposed by a given package or installed "thing" would be >> nice. Right now the namespace is very flat and it's not obvious in all >> instances what needs to happen to make it useful and what the options >> are. >> >> "Oh, hm, I'd like to know what options there are for controlling the >> installed apache24 package, let's see"... >> >> I remember IRIX having that command to list services, stop them and >> start them, configure them enabled and disabled. Solaris grew >> something like that with Solaris 10 and after the initial learning >> curve it was great. Hving something like that would be 100% awesome. > > I've updated the patch and extended it a little: > > https://phabric.freebsd.org/D451 > > It can now print the rc options for a service. > It needs however to have the options listed as comments between the > KEYWORDS section and the sourcing of /etc/rc.subr. > > > And I've made some changes to rc.subr itself: > > https://phabric.freebsd.org/D452 > > So now you can use > > # service sshd describe > Secure Shell Daemon > > and > > # service sshd extracommands > configtest keygen reload > > > Sorry for the mess in phabricator's SUMMARY. I will learn the markup > syntax later... > > > Lars