Sean O'Neill's Weblog

« Previous day (Jul 31, 2007) | Main | Next day (Aug 1, 2007) »
Wednesday Aug 01, 2007

OpenDNS: SMF Setup for inadyn

A bit more on my efforts with OpenDNS for home use.

When I setup my OpenDNS account, I enabled statistics collection.  I'm curious to see what the stats look like.  [ I do have to say though the statistics aren't what I expected ... I know my traffic is greather then what I'm seeing ... may need to open a ticket with the OpenDNS support folks ... ] To utilize this service, OpenDNS has to keep track of my ISP provided DHCP address.  To accomplish this, OpenDNS has its users use the inadyn DDNS client.

So I downloaded the v1.99 inadyn source tar ball from OpenDNS and initially compiled it using gcc.  I immediately hit a SIGSEGV when testing it out.  Annoying I tried recompiling it with Sun's GCC for SPARC Systems ... still got a SIGSEGV.  Someone suggested I try using the Sun Studio Runtime Checker feature so I did ... and the problem went away.  Not being a strong programmer and having more important things to do, I setup the SMF service to include the LD_FLAGS_32 variable as part of the startup initialization - no more SIGSEGV.  Interesting ... but still annoying.

This is my /etc/inadyn.conf file contents: 

--username <username>
--password <password>
--alias opendns
--secure
--background
--dyndns_server_name updates.opendns.com
--dyndns_server_url /account/ddns.php?
--verbose 0

Nothing really special here except to note that the --verbose flag is very nice for debugging inadyn when running it manually. 

Here is the inadyn SMF manifest I setup in /var/svc/manifest/application/inadyn.xml: 

<?xml version="1.0"?>
<!DOCTYPE service_bundle
  SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">

<service_bundle type='manifest' name='inadyn'>
  <service
    name='application/inadyn'
    type='service'
    version='1'>
    <create_default_instance enabled='false' />
    <single_instance />

    <dependency
      name='multi-user-server'
      grouping='optional_all'
      type='service'
      restart_on='none'>
        <service_fmri value='svc:/milestone/multi-user-server' />
    </dependency>
    <exec_method
      type='method'
      name='start'
      exec='/lib/svc/method/svc-inadyn %m'
      timeout_seconds='60'>
      <method_context>
        <method_credential user='nobody' />
      </method_context>
    </exec_method>

    <exec_method
      type='method'
      name='restart'
      exec='/lib/svc/method/svc-inadyn %m'
      timeout_seconds='60'>
      <method_context>
        <method_credential user='nobody' />
      </method_context>
    </exec_method>

    <exec_method
      type='method'
      name='stop'
      exec='/lib/svc/method/svc-inadyn %m'
      timeout_seconds='60' >
      <method_context>
        <method_credential user='nobody' />
      </method_context>
    </exec_method>

    <property_group name='startd' type='framework'>
      <propval name='duration' type='astring' value='contract' />
    </property_group>

  </service>
</service_bundle>

Here is the inadyn SMF method I created in /lib/svc/method/svc-inadyn.  [ The inclusion of the LD_FLAGS_32 variable is visible at the top of the script.  I have no clue at this point if this is necessary for other Solaris versions, just svn_67, or just me ... YMWPV ]

#!/sbin/sh
# Start/stop client inadyn DDNS Client
#
. /lib/svc/share/smf_include.sh

# The LD_FLAGS_32 is only necessary in Solaris 11 svn_67 currently
#
LD_FLAGS_32='preload=watchmalloc.so.1'
export LD_FLAGS_32

LD_LIBRARY_PATH=/usr/lib:/opt/csw/lib
export LD_LIBRARY_PATH

case "$1" in
'start')
        if pgrep -x -u nobody inadyn; then
           echo "$0: inadyn is already running"
           exit 1
        fi

        /usr/local/bin/inadyn
        ;;
'restart')
        pkill -x -u nobody inadyn
        sleep 2
        /usr/local/bin/inadyn
        ;;
'stop')
        if pgrep -x -u nobody inadyn; then
           pkill -x -u nobody inadyn
        fi
        ;;
*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac
exit $SMF_EXIT_OK

And finally, here are the simple steps I used to import the manifest and startup the inadyn service: 

# svccfg
svc:> validate /var/svc/manifest/application/inadyn.xml
svc:> import /var/svc/manifest/application/inadyn.xml
svc:> quit
# svcadm enable svc:/application/inadyn:default


And that's that.