<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Source Allies Blog &#187; OpenSolaris</title>
	<atom:link href="http://blogs.sourceallies.com/category/unix/opensolaris-unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.sourceallies.com</link>
	<description>Technical and process thinking from Source Allies employees</description>
	<lastBuildDate>Mon, 06 Feb 2012 17:40:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating Services using SMF in OpenSolaris</title>
		<link>http://blogs.sourceallies.com/2010/01/creating-services-using-smf-in-opensolaris/</link>
		<comments>http://blogs.sourceallies.com/2010/01/creating-services-using-smf-in-opensolaris/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 14:00:30 +0000</pubDate>
		<dc:creator>Paris Holley</dc:creator>
				<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[OpenSolaris]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=997</guid>
		<description><![CDATA[OpenSolaris has by far, one of the best service management interfaces that I have used. Below I am going to go over a simple way to turn in shell script into a service managed by the OS.

Step 1: Create the Service Manifest

&#60;?xml version='1.0'?&#62;;
&#60;!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'&#62;
&#60;service_bundle type='manifest' name='mynewservices'&#62;
        [...]]]></description>
			<content:encoded><![CDATA[<p>OpenSolaris has by far, one of the best service management interfaces that I have used. Below I am going to go over a simple way to turn in shell script into a service managed by the OS.<br />
<span id="more-997"></span></p>
<h1>Step 1: Create the Service Manifest</h1>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">'1.0'</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>;
<span style="color: #00bbdd;">&lt;!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;service_bundle</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">'manifest'</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">'mynewservices'</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;service</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">'application/service1'</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">'service'</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;method_context<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;method_credential</span> <span style="color: #000066;">user</span>=<span style="color: #ff0000;">'root'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;method_environment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>;
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;envvar</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;MY_VAR&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;--flag1 --flag2&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/method_environment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/method_context<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec_method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">'start'</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">'method'</span> <span style="color: #000066;">exec</span>=<span style="color: #ff0000;">'/opt/myscript.sh start'</span> <span style="color: #000066;">timeout_seconds</span>=<span style="color: #ff0000;">'0'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec_method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">'stop'</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">'method'</span> <span style="color: #000066;">exec</span>=<span style="color: #ff0000;">'/opt/myscript.sh stop'</span> <span style="color: #000066;">timeout_seconds</span>=<span style="color: #ff0000;">'120'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/service_bundle<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>Service Bundle</h2>
<p>A service bundle is just a collection of services which can be very useful if you have a suite of applications that you wish to manage within on manifest.xml file.</p>
<h2>Service</h2>
<p>The attributes you define on your service can be anything and are only useful for when you invoke administrative commands on them ( start, stop, etc ).</p>
<h2>Method Context</h2>
<p>The method context allows you to define the environment in which the executed methods will be called within. The example above shows the ability to define what user will be used to execute the method and the environment variables available to the script. This can be very handy when you want to leave an installation directory&#8217;s bin alone, and configure everything through the service. Keep in mind that what you see is a global method context and will apply to all executed methods. You may also customize the context per method by moving the tags out of <strong>service</strong> and into the <strong>exec_method</strong> tags.</p>
<h2>Executable Method</h2>
<p>Its purpose is self explanatory. Note that in one entry, the timeout is 0 and the other is 120 seconds. A timeout with a value of 0 will wait indefinitely for the script to start-up, however the service manager will always assume that it is online when in fact it could be hanging.</p>
<p>Also, there are three common commands used when invoking the service manager; enable, disable, and restart.</p>
<ul>
<li>When enabled, the start method will be executed.</li>
<li>When disabled, the stop method will be executed.</li>
<li>When restarted/refreshed, both the stop and the start method will be executed unless there is a method named restart/refresh.</li>
</ul>
<h1>Step 2: Import the Manifest</h1>
<p>Once you have your manifest xml file completed and ready to import, all you need to do is run the following commands:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">svccfg validate manifest.xml</pre></div></div>

<p>That will run the configuration through validation and make sure you didn&#8217;t make any typo&#8217;s.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">svcfg import manifest.xml</pre></div></div>

<h1>Step 3: Enable the Service</h1>
<p>Now that your manifest has been imported, it is available to be enabled within the service admin.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">svcadm enable service1</pre></div></div>

<h1>Step 4: Testing the Service</h1>
<p>After the service has started the run, you need to make sure it is executing properly and can handle a machine restart and/or service restart.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">svcs -x</pre></div></div>

<p>That command will tell you which services are currently broken and the log files to view the errors. Make sure that your service is not in that list. You may also do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">svcs service1
svcs -x service1</pre></div></div>

<p>to determine the state of that particular service. If it isn&#8217;t working, I suggest taking a look at the log files and fix it <img src='http://blogs.sourceallies.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h1>Step 5: Updating the Service</h1>
<p>Say that while testing, you noticed that you passed the wrong parameter to your shell script or maybe in the future you need to add additional environment variables to your service, its the same process. Even if you no longer have the manifest xml file, SMF will give you a copy when you ask for it so that you can modify it and re-import.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">svccfg export myservices &gt; manifest.xml</pre></div></div>

<p>After you have made your changes, validate and import the xml file and restart your service.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/01/creating-services-using-smf-in-opensolaris/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building Perl modules on OpenSolaris</title>
		<link>http://blogs.sourceallies.com/2010/01/building-perl-modules-on-opensolaris/</link>
		<comments>http://blogs.sourceallies.com/2010/01/building-perl-modules-on-opensolaris/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 14:00:02 +0000</pubDate>
		<dc:creator>Scott Peshak</dc:creator>
				<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[OpenSolaris]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=846</guid>
		<description><![CDATA[Anyone that&#8217;s worked with Perl is probably familiar with CPAN.pm.  CPAN.pm is the bundled module that handles downloading and installing modules from the CPAN repository.  It usually works flawlessly but I&#8217;ve noticed that on OpenSolaris the process can be a bit more spotty.

Let&#8217;s try installing Mason as an example:

perl -MCPAN -e &#34;install HTML::Mason&#34;

Generally [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone that&#8217;s worked with Perl is probably familiar with CPAN.pm.  CPAN.pm is the bundled module that handles downloading and installing modules from the CPAN repository.  It usually works flawlessly but I&#8217;ve noticed that on OpenSolaris the process can be a bit more spotty.<br />
<span id="more-846"></span><br />
Let&#8217;s try installing <a href="http://www.masonhq.com">Mason</a> as an example:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">perl -MCPAN -e &quot;install HTML::Mason&quot;</pre></div></div>

<p>Generally the first thing I notice is that all (or a large number) of the tests are failing.  For example here is the output of one of the tests:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">t/20-plugins.......................Can't locate HTML/Entities.pm in @INC (@INC
 contains: /root/.cpan/build/HTML-Mason-1.42/blib/lib /root/.cpan/build/H
TML-Mason-1.42/blib/arch t/lib inc /usr/perl5/5.8.4/lib/i86pc-solaris-64int
 /usr/perl5/5.8.4/lib/i86pc-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_
perl/5.8.4/i86pc-solaris-64int /usr/perl5/site_perl/5.8.4/i86pc-solaris-64int
 /usr/perl5/site_perl/5.8.4 /usr/perl5/site_perl/5.8.4/i86pc-solaris-64int /u
sr/perl5/site_perl/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.8.4/i8
6pc-solaris-64int /usr/perl5/vendor_perl/5.8.4/i86pc-solaris-64int /usr/per
l5/vendor_perl/5.8.4 /usr/perl5/vendor_perl/5.8.4/i86pc-solaris-64int /usr
/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl . /usr/perl5/5.8.4/lib/i86pc
-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/i86pc-solaris-6
4int /usr/perl5/site_perl/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.
8.4/i86pc-solaris-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl 
.) at /root/.cpan/build/HTML-Mason-1.42/blib/lib/HTML/Mason/Escapes.pm
 line 14.</pre></div></div>

<p>Hmm, because we&#8217;re not installing HTML::Entities this means that it should have been brought in when CPAN.pm was building the dependencies.  I trust CPAN.pm got this right, if for no other reason than that I remember it prompting to install that module.  After digging around in the sea of output eventually I find that installing Digest::SHA1 failed because of this error:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">cc -c   -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TS_ERRNO -xO3 -xspace -xildoff   -DVERSION=\&quot;2.12\&quot; -DXS_VERSION=\&quot;2.12\&quot; -KPIC &quot;-I/usr/perl5/5.8.4/lib/i86pc-solaris-64int/CORE&quot;   SHA1.c
cc: unrecognized option `-KPIC'
cc: language ildoff not recognized
cc: SHA1.c: linker input file unused because linking not done</pre></div></div>

<p>Our C compiler isn&#8217;t happy with how it&#8217;s being called.  Now we need to find out which compiler we&#8217;re using:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;"> bash-3.2$ which cc
/usr/gnu/bin/cc</pre></div></div>

<p>While the GCC compiler is a fine fine compiler, the way CPAN.pm tries to build things on OpenSolaris involves params that only SunStudio understands.  At this point there are two options. We can either patch the generated Makefile so that it doesn&#8217;t include stuff GCC can&#8217;t understand or we can switch the compiler to SunStudio.  I prefer the latter because it is easiest:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">pkg install sunstudio  # Install it if not already done
export PATH=&quot;/opt/SUNWspro/bin:$PATH&quot; # Put it first on the path</pre></div></div>

<p>Now that we&#8217;re using the correct compiler the build goes slightly less awful.  We get a new error.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">/usr/bin/perl &quot;-Iblib/arch&quot; &quot;-Iblib/lib&quot; Build.PL Build
Too early to specify a build action 'Build'.  Do 'Build Build' instead.</pre></div></div>

<p>This is caused by the ExtUtils::MakeMaker module not being installed.  I don&#8217;t know how my system got into such a state, but it is easy enough to fix:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">perl -MCPAN -e &quot;install 'ExtUtils::MakeMaker' &quot;</pre></div></div>

<p>Let&#8217;s try one more time:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">perl -MCPAN -e &quot;install HTML::Mason&quot;
...Huge Snip...
 /usr/gnu/bin/make install  -- OK</pre></div></div>

<p>Success!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/01/building-perl-modules-on-opensolaris/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

