🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #74305

Re: Starting INN automatically on Mac os x

#74305
From: Bill Cole
Date: Fri, 29 Sep 2006 14:08
95 lines
4438 bytes
In article <C1420D49.416E%swissmininature@bluewin.ch>,
 Daniel Guntli <swissmininature@bluewin.ch> wrote:

> Hello
> 
> I'd like to have starting my INN newsserver at each system startup
> autmatically on my mac. The command is:
> 
> sudo su - news -c /usr/local/news/bin/rc.news
> 
> How to have it executed automatically at each startup??

It depends to some degree on which version of MacOS X you are running, 
since 10.4 (Tiger) introduced a new startup system (launchd) that is 
unlike anything else anywhere. In principle, launchd is the way to start 
up a daemon of any sort under Tiger, but in practice it is broken 
because your startup script has to manage all of its own dependencies 
like storage and networking initialization. If you use launchd, you need 
to rewrite rc.news to fit your circumstances and the rather different 
environment of running on MacOS X under launchd. That would be a good 
thing for someone to do and perhaps to contribute to the INN project, 
but it is not really necessary if "working" is all you need. 

What I do instead is to use the older 'SystemStarter' subsystem (which 
still works in Tiger) which still requires me to check for spool disks 
if they are automounted, but at least I can be certain that the INN 
startup is running at a point where those disks can be easily mounted 
and I have all of my network interfaces configured, because 
SystemStarter supports explicit dependencies. The best docs I've seen 
for a SystemStarter "StartupItem" are at 
http://www.afp548.com/article.php?story=20041018090215552 and 
http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartu
p/index.html

The missing bit in those is the actual code to start a specific daemon, 
obviously. My /Library/StartupItems/INN/INN looks like this:

#!/bin/sh 
. /etc/rc.common


if [ ${1:-noset} == "stop" ] || [ ${1:-noset} == "restart" ]; then
   ConsoleMessage "Stopping INN"
   su - news -c 'rc.news stop'
fi


if [ ${1:-noset} == "start" ] || [ ${1:-noset} == "restart" ]; then
   ConsoleMessage "Starting INN"
   STORAGE=`grep -v "^#" ~news/etc/*|grep Volumes|
      sed 's#.*/Volumes/\([^/ ]*\).*#\1#'|sort -u`
   for DISK in $STORAGE
   do
      /usr/sbin/disktool -l | grep $DISK | 
         sed "s/.*'\(disk[0-9]*s[0-9]*\)'.*/\1/" |
         xargs /usr/sbin/diskutil mount
   done      
   su - news -c 'rc.news start'
fi


And StartupParameters.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Description</key>
        <string>INN News Server</string>
        <key>Messages</key>
        <dict>
                <key>restart</key>
                <string>Restarting INN News server</string>
                <key>start</key>
                <string>Starting INN News server</string>
                <key>stop</key>
                <string>Stopping INN News server</string>
        </dict>
        <key>OrderPreference</key>
        <string>Last</string>
        <key>Provides</key>
        <array>
                <string>News</string>
        </array>
        <key>Requires</key>
        <array>
                <string>Resolver</string>
                <string>Disks</string>
        </array>
</dict>
</plist>

-- 
Now where did I hide that website...
Technical Details
Message-ID: <bill-27CAE3.10084429092006@toaster.scconsult.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.tele.dk!feed118.news.tele.dk!news.scconsult.com!bill
References: <C1420D49.416E%swissmininature@bluewin.ch>

Show Full Headers
Complete Article Headers
Message-ID: <bill-27CAE3.10084429092006@toaster.scconsult.com>
Subject: Re: Starting INN automatically on Mac os x
Date: Fri, 29 Sep 2006 10:08:44 -0400
From: Bill Cole <bill@scconsult.com>
References: <C1420D49.416E%swissmininature@bluewin.ch>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.tele.dk!feed118.news.tele.dk!news.scconsult.com!bill
Newsgroups: news.software.nntp
Organization: Solid Clues
Lines: 95
NNTP-Posting-Host: bigsky.scconsult.com
X-Trace: toaster.scconsult.com 1159538925 8325 192.168.2.102 (29 Sep 2006
X-Complaints-To: news@scconsult.com
NNTP-Posting-Date: Fri, 29 Sep 2006 14:08:45 +0000 (UTC)
User-Agent: MT-NewsWatcher/3.5.2 (Intel Mac OS X)