<?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>diginc &#187; init.d</title>
	<atom:link href="http://diginc.us/tag/init-d/feed/" rel="self" type="application/rss+xml" />
	<link>http://diginc.us</link>
	<description>\'dij-iŋk\</description>
	<lastBuildDate>Thu, 19 May 2011 14:49:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>GNUmp3d init.d with PIDs for running multiple instances of GNUmp3d</title>
		<link>http://diginc.us/linux/2009/gnump3d-init-d-with-pids-for-running-multiple-instances-of-gnump3d/</link>
		<comments>http://diginc.us/linux/2009/gnump3d-init-d-with-pids-for-running-multiple-instances-of-gnump3d/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 05:07:15 +0000</pubDate>
		<dc:creator>diginc</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[gnump3d]]></category>
		<category><![CDATA[init.d]]></category>
		<category><![CDATA[invoke-rc.d]]></category>
		<category><![CDATA[service]]></category>

		<guid isPermaLink="false">http://diginc.us/?p=73</guid>
		<description><![CDATA[I made some modifications to my original gnump3d init.d script when I needed more than one instance of GNUmp3d running (for multiple folders completely separated). I still haven&#8217;t quite figured out how to get the tag database to work for &#8230; <a href="http://diginc.us/linux/2009/gnump3d-init-d-with-pids-for-running-multiple-instances-of-gnump3d/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I made some modifications to my original gnump3d init.d script when I needed more than one instance of GNUmp3d running (for multiple folders completely separated).  I still haven&#8217;t quite figured out how to get the tag database to work for my second GNUmp3d instance, if anyone can help please leave a comment.  Here&#8217;s the script and some brief instructions:</p>
<p><span id="more-73"></span></p>
<p>/etc/init.d/gnump3d :</p>

<div class="wp_codebox"><table><tr id="p738"><td class="code" id="p73code8"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">gmconfig</span>=<span style="color: #ff0000;">&quot;/etc/gnump3d/gnump3d.conf&quot;</span>
<span style="color: #007800;">gmport</span>=<span style="color: #ff0000;">&quot;54321&quot;</span>
<span style="color: #007800;">gmpidfile</span>=<span style="color: #ff0000;">&quot;/var/run/gnump3d_<span style="color: #007800;">$gmport</span>.pid&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$gmpidfile</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;GNUmp3d already running on port <span style="color: #007800;">$gmport</span>&quot;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Starting GNUmp3d.&quot;</span>
    <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gnump3d <span style="color: #660033;">--background</span> <span style="color: #660033;">-config</span> <span style="color: #007800;">$gmconfig</span> <span style="color: #660033;">--port</span> <span style="color: #007800;">$gmport</span>
    <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>
    <span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-ef</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #ff0000;">&quot;grep&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;config <span style="color: #007800;">$gmconfig</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-c10-15</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$gmpidfile</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">;;</span>
stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$gmpidfile</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Shutting down GNUmp3d.&quot;</span>
    <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-9</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$gmpidfile</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$gmpidfile</span>
  <span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;GNUmp3d isn't running on port <span style="color: #007800;">$gmport</span> yet&quot;</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">;;</span>
restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #007800;">$0</span> stop
  <span style="color: #007800;">$0</span> start
<span style="color: #000000; font-weight: bold;">;;</span>
status<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$gmpidfile</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;GNUmp3d running on port <span style="color: #007800;">$gmport</span> with config <span style="color: #007800;">$gmconfig</span> and pid <span style="color: #007800;">$(cat $gmpidfile)</span>&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-ef</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #ff0000;">&quot;grep&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;config <span style="color: #007800;">$gmconfig</span>&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #666666; font-style: italic;">#echo</span>
    <span style="color: #666666; font-style: italic;"># code to display the other instance of gnump3d here...</span>
  <span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;GNUmp3d isn't running yet&quot;</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: $0 {start|stop|restart|status}&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></td></tr></table></div>

<p>To run more than one copy of gnump3d with this simply make a copy of this script and call it something like gnump3d_2.</p>

<div class="wp_codebox"><table><tr id="p739"><td class="code" id="p73code9"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-vip</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>gnump3d <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>gnump3d_2</pre></td></tr></table></div>

<p>Then change the new init.d script to point to your new config and port (pid file auto updates by port #).</p>

<div class="wp_codebox"><table><tr id="p7310"><td class="code" id="p73code10"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">gmconfig</span>=<span style="color: #ff0000;">&quot;/etc/gnump3d/gnump3d_2.conf&quot;</span>
<span style="color: #007800;">gmport</span>=<span style="color: #ff0000;">&quot;54322&quot;</span></pre></td></tr></table></div>

<p>Make a copy of the stock gnump3d config and modify the necessary lines.</p>

<div class="wp_codebox"><table><tr id="p7311"><td class="code" id="p73code11"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-vip</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>gnump3d<span style="color: #000000; font-weight: bold;">/</span>gnump3d.conf <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>gnump3d<span style="color: #000000; font-weight: bold;">/</span>gnump3d_2.conf</pre></td></tr></table></div>

<p>In my config I modified these lines:</p>

<div class="wp_codebox"><table><tr id="p7312"><td class="code" id="p73code12"><pre class="bash" style="font-family:monospace;">port = <span style="color: #000000;">54322</span>
root = <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>gnump3d_2
user = gnump3d_2
logfile = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>gnump3d<span style="color: #000000; font-weight: bold;">/</span>access_2.log
errorlog = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>gnump3d<span style="color: #000000; font-weight: bold;">/</span>error_2.log
now_playing_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span>gnump3d_2<span style="color: #000000; font-weight: bold;">/</span>serving
tag_cache = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span>gnump3d_2<span style="color: #000000; font-weight: bold;">/</span>song.tags</pre></td></tr></table></div>

<p>And lastly we&#8217;ll need to make the cache drectories:</p>

<div class="wp_codebox"><table><tr id="p7313"><td class="code" id="p73code13"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span>gnump3d_2<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span>gnump3d_2<span style="color: #000000; font-weight: bold;">/</span>serving
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> <span style="color: #000000;">777</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span>gnump3d_2
<span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span>gnump3d_2<span style="color: #000000; font-weight: bold;">/</span>song.tags</pre></td></tr></table></div>

<p>And then you&#8217;re set to startup the second gnump3d instance.</p>

<div class="wp_codebox"><table><tr id="p7314"><td class="code" id="p73code14"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>gnump3d_2 start</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://diginc.us/linux/2009/gnump3d-init-d-with-pids-for-running-multiple-instances-of-gnump3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: diginc.us @ 2012-02-06 01:00:08 -->
