From owner-freebsd-questions@freebsd.org Mon Feb 1 14:52:13 2016 Return-Path: Delivered-To: freebsd-questions@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 D19E6A750DC for ; Mon, 1 Feb 2016 14:52:13 +0000 (UTC) (envelope-from kraduk@gmail.com) Received: from mail-wm0-x233.google.com (mail-wm0-x233.google.com [IPv6:2a00:1450:400c:c09::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 6CF80797 for ; Mon, 1 Feb 2016 14:52:13 +0000 (UTC) (envelope-from kraduk@gmail.com) Received: by mail-wm0-x233.google.com with SMTP id l66so73989944wml.0 for ; Mon, 01 Feb 2016 06:52:13 -0800 (PST) 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=6NhsTGrjq6npot/nxQ+uHLiWfw0nSUaJMArdceAUmnI=; b=0rXFyYn36qamR9o4OlJ2DSZWxx1+EqGE/dG+Lk5m5DFJzb98ijZZsJFt6ihyzleRr6 1Mp/I9PAaeev8ofUfSYfQKmbK+fTVFKBUXLoY1XdxrjVHek+UfKE7B0/XUOQqjm40qmf T+5RqbrnkYBPYsCZETzGP9pQhcuERk8EbYphO7qhpEMBQvnB35Wp9haB1ML/DsztsklI jOX45e8gx5ghOKA/9GRJjILoO604A4ieGvd4gtXY6Es8RqejlklZxBTD9xZFnSbOaDq1 ZSuw0ffyLVM0/2qMm/ju+Ueh+SBsuj9HWQbTU0I45rstUw7nLQv8Ct4bHLw3BCaG4iL6 U/Hw== 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=6NhsTGrjq6npot/nxQ+uHLiWfw0nSUaJMArdceAUmnI=; b=U2zG3LOk7lYcbVFcAky0e6FShMIMvHmonFXCMKR2+QNGdDuAJbQFzqrLEtDIimPmNG 19PESJmN9LrhDv8qsIfJDdf/xo2tT2Q4Y20AsHJdtrzeIgrCe+IRnd2T32rwK/woa/Ts P6OEnZP8paZKEcAAa5WqilW6uy1hFBwWAXUrQ9apwZiLNs4wOKwHSO/CVfNMyDfErSmg vBA1+oWG8/MzSD8JwAb3Jl4v5grHg0nuGzXvIdrz2M+La7SP/Po2hxDqIuYE/fzieYRU Iw8wU8juayBe4yLJgBdF9FCpDvUwWMo2KDtbzATe9lJFkLAf1bG/o5jw1trErg355Aef Lt5A== X-Gm-Message-State: AG10YOR+s5ysL2Pze7oOuyAH3GOED2rGaruGu9EyvV9gnSx8AUmJKaCDx2MugHpVyCvWVo63C0hBuckTAUUsDQ== MIME-Version: 1.0 X-Received: by 10.194.103.164 with SMTP id fx4mr23238790wjb.56.1454338331669; Mon, 01 Feb 2016 06:52:11 -0800 (PST) Received: by 10.28.55.132 with HTTP; Mon, 1 Feb 2016 06:52:11 -0800 (PST) In-Reply-To: <63014.76.192.184.12.1454168056.squirrel@cosmo.uchicago.edu> References: <20160131000408.N51785@sola.nimnet.asn.au> <63014.76.192.184.12.1454168056.squirrel@cosmo.uchicago.edu> Date: Mon, 1 Feb 2016 14:52:11 +0000 Message-ID: Subject: Re: "epilogue" script? From: krad To: galtsev@kicp.uchicago.edu Cc: Ian Smith , Polytropon , FreeBSD Questions Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Feb 2016 14:52:14 -0000 Have you looked at the cloned_interfaces and autobridge_* rc.conf options, they might give you what you need? On 30 January 2016 at 15:34, Valeri Galtsev wrote: > > On Sat, January 30, 2016 8:19 am, Ian Smith wrote: > > In freebsd-questions Digest, Vol 608, Issue 6, Message: 20 > > On Sat, 30 Jan 2016 11:59:55 +0100 Polytropon wrote: > > > On Fri, 29 Jan 2016 16:35:07 -0600 (CST), Valeri Galtsev wrote: > > > > Dear Experts, > > > > > > > > How does one create "epoligue" script in FreeBSD. By "epoligue" > > script > > > > script I mean here the script that is executed after everything > > described > > > > in /etc/rc.conf is done (services started, interfaces initialized > > etc.). I > > [..] > > > > > a) RC framework: rc.d > > [..] > > > See "man rc" and "man rcorder" for details. > > > > Sure, if installing new daemon processes, this is the way to go. > > > > OTOH, for scripts needing running just once at startup, and/or possibly > > once at shutdown: > > Thanks to everybody who answered, you answers were very instructive! And > special thanks to Mr Polytropon and Mr Smith! Being quite long on this > list I have noticed that after reading your posts my knowledge improves as > after reading a chapter of a good book on the subject. Which leads me to > realizing that that is exactly what I had to do a few years ago, when I > migrated servers to FreeBSD: read a good book, and there were several > recommended on this list some time ago, so this is what I'll do next (plus > man on all things you all have mentioned). > > > > > > b) rc.local and rc.shutdown.local > > > > > > Those files, located in /etc, are "real" shell scripts that will be > > > executed "quite late", but not at the lastest possible point. Here > > > is an example: > > > > > > Creating and/or trimming log files. > > > Starting syslogd. > > > No core dumps found. > > > Additional ABI support: linux. > > > Starting named. > > > Clearing /tmp (X related). > > > Starting local daemons: activity. <--- /etc/rc.local runnung > now! > > > Starting ntpd. > > > Starting dhcpd. > > > Starting cupsd. > > > Configuring syscons: keymap keyrate font8x16 font8x14 font8x8. > > > Starting sshd. > > > Starting cron. > > > Starting inetd. > > > > > > As you can see, there are other services started _after_ rc.local has > > > been run. This might cause a problem for you when you need those > > services > > > running. > > > > Yes. I was preparing to post a very similar segment, which also wrote > > something to stdout when /etc/rc.local was sourced - so thanks! > > > > > See from "man rc": > > > > > > The rc.local script contains commands which are pertinent only > > > to a specific site. Typically, the /usr/local/etc/rc.d/ mechanism > > > is used instead of rc.local these days but if you want to use > > rc.local, > > > it is still supported. In this case, it should source /etc/rc.conf > > > and contain additional custom startup code for your system. The > best > > > way to handle rc.local, however, is to separate it out into rc.d/ > > > style scripts and place them under /usr/local/etc/rc.d/. The > rc.conf > > > file contains the global system configuration information > referenced > > > by the startup scripts, while rc.conf.local contains the local > system > > > configuration. See rc.conf(5) for more information. > > > > > > So this might not be "stable". > > > > It's stable; been there since the dawn of time and isn't going away :) > > > > Valeri, picking up on the above, if you run, say: > > > > % rcorder /etc/rc.d/* /usr/local/etc/rc.d/* | less > > > > and find 'local', you'll see where /etc/rc.d/rc/local runs, and that's > > what runs (sources inline) /etc/rc.local on startup (or in reverse order > > on shutdown, /etc/rc.shutdown.local) > > > > You only need source /etc/rc.conf if using rc.conf variables of course. > > > > > c) /etc/rc hook > > > > Totally agree; don't go anywhere near there :) > > > > > > I'm left clueless. As Linux refugee I have a feeling that this is > > doable > > > > without a hack, like making init script, and having "sleep ..." in > it > > > > before payload. In Linux this is done using /etc/rc.d/rc.local which > > is > > > > executed _after_ everything else is done. > > > > > > As you can see, an rc.d style mechanism will probably be the best > > > solution here, except you are fully sure that the time when rc.local > > > is run you will be provided with everything you need. > > > > We don't really know what Valeri wants to run, and whether it's one or > > more daemons, maybe including long-running background scripts, that may > > need start|stop|status control via service(8), or whether it's more > > simply one or more one-off tasks to be run sometime after startup? > > It is rather simple thing which I need. I'm trying to set up openvpn, and > I need _after_ starting openvpn daemon to add tap0 interface to the bridge > then set IP on the bridge and on tap0 interface the same as that of real > interface which is member of this bridge. This is the only way I managed > to make openvpn really work (by trial and error). I'm kind of not inclined > to use openvpn's mechanism (which they seemingly have) to do it (it is not > a first time I spent this long setting up something on FreeBSD, but it was > the first time I spent this time... hm, not that productive. My ignorance > is to blame, still...) > > Thanks again, everybody. I'm set on right tracks, and should be able to > successfully finish what I'm doing now. > > Valeri > > > > > If the latter, there's nothing at all wrong with starting a script that > > runs in the background including sleep(1), so long as you don't have an > > inline sleep that would just pause the whole startup. Something like .. > > > > /etc/rc.local: (do not use exit or return, this runs within > /etc/rc) > > wait=20 > > ( sleep $wait # sleep 5 should usually be more than enough > > # perhaps wait for something or other to be running or exist? > > # do stuff, maybe including starting further bg jobs, whatever .. > > ) & > > echo "my rc.local stuff starts in $wait seconds" > > > > cheers, Ian > > > > > ++++++++++++++++++++++++++++++++++++++++ > Valeri Galtsev > Sr System Administrator > Department of Astronomy and Astrophysics > Kavli Institute for Cosmological Physics > University of Chicago > Phone: 773-702-4247 > ++++++++++++++++++++++++++++++++++++++++ > _______________________________________________ > freebsd-questions@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to " > freebsd-questions-unsubscribe@freebsd.org" >