<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I am converting the init script (see below) for Linux DECnet (<a href="http://sourceforge.net/projects/linux-decnet">http://sourceforge.net/projects/linux-decnet</a>). This is my first exposure to systemd. Naturally, my first try failed. So, now I am taking baby steps.<div><br></div><div>The Linux DECnet init script can start either or both the dnetd or phoned daemons. (I do not use the phoned daemon.) I think the best thing to do with smartd is make them separate service units. I will create /etc/systemd/system/dnetd.service and .../phoned.service.</div><div><br></div><div>Prior to starting the daemons, the init script verifies the /etc/decnet.conf configuration file exists. I will use the [Unit] option ConditionFileNotEmpty=/etc/decnet.conf to replicate that behavior.</div><div><br></div><div>Then it looks for evidence that the decnet kernel module is loaded by testing for the file /proc/net/decnet. If necessary, it loads the decnet kernel module and checks again for /proc/net/decnet. I have already built the decnet kernel module and I can load it with modprobe. I do not wish to force an unconditional load of the decnet kernel module using /etc/modules-load.d/decnet.conf; I prefer the services that need it (dnetd and phoned) trigger the load. However, I find no mention of the standard systemd "load a kernel module" practice. I.e., there is no "systemd.module" unit. What is the recommended method in the systemd framework to trigger a unit that loads a kernel module? If the modprobe command fails, I presume that will cause the systemd start command to fail. I would also like the systemd start command to fail if /proc/net/decnet is not created (a sign that the module has not initialized itself correctly). Is there a syntax in a systemd unit for that as well?</div><div><br></div><div>Thank you in advance for your advice.</div><div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Helvetica Neue'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">Larry Baker<br>US Geological Survey<br>650-329-5608<br><a href="mailto:baker@usgs.gov">baker@usgs.gov</a><br><br><br></span>
</div>
<div>#!/bin/sh</div><div>#</div><div># decnet.sh</div><div>#</div><div># Starts/Stops DECnet processes</div><div>#</div><div># chkconfig: - 09 91</div><div># description: DECnet.</div><div># processname: dnetd</div><div># config: /etc/decnet.conf</div><div>#</div><div>#</div><div># This script should go in</div><div># /etc/init.d for redhat 7.0 onwards</div><div># /etc/rc.d/init.d for redhat up to 6.2</div><div>#</div><div># You can install it using the following command:</div><div>#</div><div># chkconfig --level 345 decnet on</div><div>#</div><div># -----------------------------------------------------------------------------</div><div>#</div><div># Daemons to start. You may remove the ones you don't want</div><div>#</div><div>#daemons="dnetd phoned"</div><div>daemons="dnetd"</div><div><br></div><div># Prefix for where the progs are installed. "make install" puts them</div><div># in /usr/local, the RPM has them in /usr</div><div>prefix=/usr/local</div><div><br></div><div>#</div><div># Interfaces to set the MAC address of. By default only the default interface</div><div># in /etc/decnet.conf will be set. If you want to set up more interfaces</div><div># for DECnet than add them here.</div><div>#</div><div>extra_interfaces=""</div><div><br></div><div>#</div><div># Set up some variables.</div><div>#</div><div>. /etc/rc.d/init.d/functions</div><div>startcmd="daemon"</div><div>stopcmd="killproc"</div><div>startendecho=""</div><div>stopendecho="done."</div><div><br></div><div>case $1 in</div><div> start)</div><div> if [ ! -f /etc/decnet.conf ]</div><div> then</div><div> echo $"DECnet not started as it is not configured."</div><div> exit 1</div><div> fi</div><div><br></div><div> # If there is no DECnet in the kernel then try to load it.</div><div> if [ ! -f /proc/net/decnet ]</div><div> then</div><div> modprobe decnet</div><div> if [ ! -f /proc/net/decnet ]</div><div> then</div><div> echo $"DECnet not started as it is not in the kernel."</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> exit 1</div><div> fi</div><div> fi</div><div><br></div><div> echo -n $"Starting DECnet: "</div><div><br></div><div> NODE=`grep executor /etc/decnet.conf| awk '{print $2}'`</div><div> echo "$NODE" > /proc/sys/net/decnet/node_address</div><div> CCT=`grep executor /etc/decnet.conf | awk '{print $6}'`</div><div> echo "$CCT" > /proc/sys/net/decnet/default_device</div><div> $prefix/sbin/setether $NODE $CCT $extra_interfaces </div><div><br></div><div> for i in $CCT $extra_interfaces</div><div> do</div><div> ip link set dev $i allmulticast on</div><div> done</div><div><br></div><div><br></div><div><br></div><div> for i in $daemons</div><div> do</div><div> $startcmd $prefix/sbin/$i</div><div> echo -n $" `eval echo $startecho`"</div><div> done</div><div> echo $"$startendecho"</div><div> ;;</div><div><br></div><div> stop)</div><div> echo -n $"Stopping DECnet... "</div><div> for i in $daemons</div><div> do</div><div> $stopcmd $prefix/sbin/$i</div><div> done</div><div> echo $"$stopendecho"</div><div> ;;</div><div><br></div><div> restart|reload|force-reload)</div><div> echo -n $"Restarting DECnet: "</div><div> for i in $daemons</div><div> do</div><div> $stopcmd $prefix/sbin/$i</div><div> $startcmd $prefix/sbin/$i</div><div> echo -n $"$startecho"</div><div> done</div><div> echo $"$stopendecho"</div><div> ;;</div><div><br></div><div> *)</div><div> echo $"Usage $0 {start|stop|restart|force-reload}"</div><div> ;;</div><div>esac</div><div><br></div><div>exit 0</div></div><div><br></div></body></html>