From owner-freebsd-questions@FreeBSD.ORG Mon Feb 23 08:58:35 2015 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D85E12F0 for ; Mon, 23 Feb 2015 08:58:35 +0000 (UTC) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) (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 6F82E1FB for ; Mon, 23 Feb 2015 08:58:34 +0000 (UTC) Received: from r56.edvax.de (port-92-195-149-162.dynamic.qsc.de [92.195.149.162]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx02.qsc.de (Postfix) with ESMTPS id BED0A24D39; Mon, 23 Feb 2015 09:58:25 +0100 (CET) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id t1N8wOYG003166; Mon, 23 Feb 2015 09:58:25 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Mon, 23 Feb 2015 09:58:24 +0100 From: Polytropon To: Raimund Sacherer Subject: Re: Question regarding local scripts Message-Id: <20150223095824.ec1e20d8.freebsd@edvax.de> In-Reply-To: <1587845035.91715373.1424680950928.JavaMail.zimbra@logitravel.com> References: <1556736143.91711691.1424680724984.JavaMail.zimbra@logitravel.com> <1587845035.91715373.1424680950928.JavaMail.zimbra@logitravel.com> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Feb 2015 08:58:36 -0000 On Mon, 23 Feb 2015 09:42:30 +0100 (CET), Raimund Sacherer wrote: > Hello, > > I am rather new to FreeBSD, putting a couple of new servers in > production. I read a lot in the manuals, the man hier and googled > around, but I can't find best practices for storing local > scripts / apps. What do you mean by "local" in relation to apps? Software you install with the port collection (or via pkg) will be installed into /usr/local, and this will be recorded (!) by the system's package system. > In Debian this part was easy, Debian never touches /usr/local, > so I had this complete namespace for internal use. FreeBSD is different: /usr/local is for locally installed programs, as the name suggests, and those are managed by the system. In the "top level" directories only the OS is installed. So when you would remove /usr/local entirely, the OS would not be affected. > How to do this in FreeBSD the sane way? There are different ways to do this on FreeBSD, but they aren't standardized. Allow me to mention _one_ example. The use of the Solarisism /opt is possible. Inside /opt, you can basically do what you want. /opt/bin is a central "hub" for scripts and binaries, as well as for symlinks which are required by programs that reside in, let's say, /opt/foo/program. You can also have /opt/src for sources, /opt/lib for libraries and /opt/libexec for daemons; for example, my printer filters reside there. Keep in mind the OS does not record anything you do in /opt. You need to do things manually (like updating stuff), and even adding paths (like /opt/bin to $PATH). For things that you wish to be able to use by _one_ user only, you can put scripts in his ~/bin, and add that to $PATH. Also consider using version control for your scripts; just the mandatory sidenote. :-) But there's probably an easier way: Read the porter's handbook and create ports for your program or (collections of) scripts which you can't manage via ports/pkg. It's not that hard, and there are many advantages over /opt. > I thought of creating /scripts, but this seems odd, I thought > of /opt/scripts or /opt/scripts/[s]bin hierarchy, or > /opt/local/[s]bin hierarchy, but I am not sure how you are > doing this sort of thing. Don't make things more complicated than they need to be. :-) > I think what I like best would be to recreate a sort of > /usr/local hierarchy under /opt/local. You can root the hierarchy directly to /opt, because /opt does not exist to the system (in a sense of "man hier"). If you place /opt on an individual partition, it's also very easy to forbid executing (in case of security concerns) by a simple mount option, or entirely removing access to the local additions by unmounting it. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...