<?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>Rafael Liu Blog &#187; fedora</title>
	<atom:link href="http://rafaelliu.net/category/fedora/feed/" rel="self" type="application/rss+xml" />
	<link>http://rafaelliu.net</link>
	<description>Café, pinguins e outras coisas</description>
	<lastBuildDate>Wed, 28 Mar 2012 21:54:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Agente JON/Jopr não sobre no boot</title>
		<link>http://rafaelliu.net/2010/01/26/agente-jonjopr-nao-sobre-no-boot/</link>
		<comments>http://rafaelliu.net/2010/01/26/agente-jonjopr-nao-sobre-no-boot/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 15:50:58 +0000</pubDate>
		<dc:creator>rafaelliu</dc:creator>
				<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[fedora]]></category>

		<guid isPermaLink="false">http://rafaelliu.net/?p=328</guid>
		<description><![CDATA[JON 2.3.0.GA O jeito mais comun de se adicionar o JON/Jopr para subir no boot (Red Hat Enterprise Linux) criar um link simbólico: ln -sf $RHQ_AGENT_HOME/bin/rhq-agent-wrapper.sh /etc/init.d/rhq-agent adicionar à lista de serviços: chkconfig --add rhq-agent Agora basta rebootar e&#8230; Não funciona. Agora tente executar /etc/init.d/rhq-agent start. Funciona!! A razão é que o bash script rhq-agent-wrapper.sh [...]]]></description>
			<content:encoded><![CDATA[<p>JON 2.3.0.GA</p>
<p>O jeito mais comun de se adicionar o JON/Jopr para subir no boot (Red Hat Enterprise Linux)</p>
<ol>
<li>criar um link simbólico:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-sf</span> <span style="color: #007800;">$RHQ_AGENT_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rhq-agent-wrapper.sh <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>rhq-agent</pre></div></div>

</li>
<li>adicionar à lista de serviços:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">chkconfig <span style="color: #660033;">--add</span> rhq-agent</pre></div></div>

</li>
</ol>
<p>Agora basta rebootar e&#8230; Não funciona. Agora tente executar /etc/init.d/rhq-agent start. Funciona!!</p>
<p>A razão é que o bash script rhq-agent-wrapper.sh tenta achar o $RHQ_AGENT_HOME automaticamente através do path do script. Dá para ver isso na linha:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">_DOLLARZERO</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">readlink</span> <span style="color: #ff0000;">&quot;$0&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;$0&quot;</span><span style="color: #000000; font-weight: bold;">`</span></pre></div></div>

<p>Para quem não conhece bash script o $0 é o argumento 0, que corresponde ao caminho do arquivo sendo executado. O que acontece nessa linha é que a variável recebe o caminho do link derreferenciado, caso o arquivo seja um link, ou o caminho do arquivo, caso seja um arquivo mesmo (aliás é por isso que usamos um link no passo 1, senão o script acharia que /etc/init.d é o $RHQ_AGENT_HOME).</p>
<p>O chkconfig é a ferramenta usada no RHEL para registrar serviços. Nela registramos que serviços queremos subir em que níveis de inicialização. Esses níveis são (direto do inittab):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#   0 - halt (Do NOT set initdefault to this)</span>
<span style="color: #666666; font-style: italic;">#   1 - Single user mode</span>
<span style="color: #666666; font-style: italic;">#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)</span>
<span style="color: #666666; font-style: italic;">#   3 - Full multiuser mode</span>
<span style="color: #666666; font-style: italic;">#   4 - unused</span>
<span style="color: #666666; font-style: italic;">#   5 - X11</span>
<span style="color: #666666; font-style: italic;">#   6 - reboot (Do NOT set initdefault to this)</span></pre></div></div>

<p>O problema é que o chkconfig usa, para registrar os serviços, links simbólicos nas pastas /etc/rcX.d (onde X é o nível de inicialização). O que acontece então é o que é executado é um link simbólico em /etc/rc3.d apontando para o link simbólico /etc/init.d apontando para $RHQ_AGENT_HOME/bin. Algo do tipo:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc3.d<span style="color: #000000; font-weight: bold;">/</span>S93rhq-agent -<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <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>rhq-agent -<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$RHQ_AGENT_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rhq-agent-wrapper.sh</pre></div></div>

<p>E o comando readlink não é recursivo por padrão, ou seja, se o link derreferenciado apontar para outro link, o readlink não o derreferencia.. A solução está no readlink &#8211;help: adicionar a flag -e.</p>
<p>Ou seja, basta mudar a linha 102 para:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">_DOLLARZERO</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">readlink</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;$0&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;$0&quot;</span><span style="color: #000000; font-weight: bold;">`</span></pre></div></div>

<p>Fonte: <a title="rhq-agent-wrapper.sh needs to be modified to work with SYSV init systems and chkconfig " href="http://jira.rhq-project.org/browse/RHQ-2444" target="_blank">JIRA</a></p>
]]></content:encoded>
			<wfw:commentRss>http://rafaelliu.net/2010/01/26/agente-jonjopr-nao-sobre-no-boot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

