<?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>TommyBlue.it &#187; How-To</title>
	<atom:link href="http://www.tommyblue.it/category/informatica/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tommyblue.it</link>
	<description>Bombardare per la pace è un po' come trombare per la verginità...</description>
	<lastBuildDate>Tue, 24 Jan 2012 09:34:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Notifiche SMS gratis con Nagios/Icinga e Skebby</title>
		<link>http://www.tommyblue.it/2012/01/18/notifiche-sms-gratis-con-nagiosicinga-e-skebby/</link>
		<comments>http://www.tommyblue.it/2012/01/18/notifiche-sms-gratis-con-nagiosicinga-e-skebby/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 11:26:25 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Icinga]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Skebby]]></category>
		<category><![CDATA[SMS]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1291</guid>
		<description><![CDATA[Ho scritto un po&#8217; di codice Ruby in grado di mandare SMS gratis con Skebby utilizzando due account per privati (funziona anche con uno soltanto sia come mittente che destinatario). L&#8217;account Skebby deve essere attivo attivo e dovete aver abilitato username e password (dal pannello di gestione utente). Lo script è questo: #!/usr/bin/env ruby # [...]]]></description>
			<content:encoded><![CDATA[<p>Ho scritto un po&#8217; di codice Ruby in grado di mandare SMS gratis con <a href="http://smsgratis.skebby.it/" target="_blank">Skebby</a> utilizzando due account per privati (funziona anche con uno soltanto sia come mittente che destinatario).<br />
L&#8217;account Skebby deve essere attivo attivo e dovete aver abilitato username e password (dal pannello di gestione utente).</p>
<p>Lo script è questo:</p>
<div class="codecolorer-container ruby railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span><br />
<span style="color:#008000; font-style:italic;"># Copyright 2012 by Tommaso Visconti</span><br />
<span style="color:#008000; font-style:italic;">#</span><br />
<span style="color:#008000; font-style:italic;"># This code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License</span><br />
<span style="color:#008000; font-style:italic;"># as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</span><br />
<span style="color:#008000; font-style:italic;">#</span><br />
<span style="color:#008000; font-style:italic;"># This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty</span><br />
<span style="color:#008000; font-style:italic;"># of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</span><br />
<span style="color:#008000; font-style:italic;">#</span><br />
<span style="color:#008000; font-style:italic;"># The full text of the GNU General Public License can be found here: http://www.gnu.org/licenses/gpl.txt</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'net/http'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'uri'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cgi'</span><br />
<span style="color:#ff6633; font-weight:bold;">$SENDER</span> = <span style="color:#996600;">'393XXXXXXXXX'</span><br />
<span style="color:#ff6633; font-weight:bold;">$RECIPIENT</span> = <span style="color:#996600;">'393XXXXXXXXY'</span><br />
<span style="color:#ff6633; font-weight:bold;">$USERNAME</span> = <span style="color:#996600;">'my_username'</span><br />
<span style="color:#ff6633; font-weight:bold;">$PASSWORD</span> = <span style="color:#996600;">'my_password'</span><br />
<span style="color:#008000; font-style:italic;"># The class sends free SMS using the Skebby API</span><br />
<span style="color:#008000; font-style:italic;"># @author Tommaso Visconti</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">class</span> SkebbyGatewaySendSMS<br />
<br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Initializes the object</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @param username [String] The Skebby username</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @param text [String] The text of the SMS</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @param recipients [Array] The recipients of the message</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @param sender [String] The SMS sender</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>username = <span style="color:#996600;">''</span>, text = <span style="color:#996600;">''</span>, recipient = <span style="color:#996600;">''</span>, sender = <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@url</span> = <span style="color:#996600;">'http://gateway.skebby.it/api/send/smsskebby/advanced/http.php'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; sms_method = <span style="color:#996600;">'send_sms'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#008000; font-style:italic;">#@recipients = getRecipients(recipients) &nbsp; &nbsp; &nbsp; </span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@parameters</span> = <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'method'</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">=&gt;</span> sms_method,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'username'</span> &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">=&gt;</span> username,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'password'</span> &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">getPassword</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'text'</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">=&gt;</span> text,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'recipients[]'</span> &nbsp;<span style="color:#006600; font-weight:bold;">=&gt;</span> recipient,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'sender_number'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> sender<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Sends the HTTP request</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @return [Boolean] The result of the HTTP request</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @note It returns the result of the HTTP request, not the result of the sending. Use getResponse() or printResponse() to check that!</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> sendSMS<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@response</span> = <span style="color:#6666ff; font-weight:bold;">Net::HTTP</span>.<span style="color:#9900CC;">post_form</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">URI</span><span style="color:#006600; font-weight:bold;">&#40;</span>@url<span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#0066ff; font-weight:bold;">@parameters</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@response</span>.<span style="color:#9900CC;">message</span> == <span style="color:#996600;">&quot;OK&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Return the response from the server</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @return [Hash] The hash containing the result of the sending</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> getResponse<br />
&nbsp; &nbsp; &nbsp; &nbsp; result = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@response</span>.<span style="color:#9900CC;">body</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'&amp;'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>res<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> res != <span style="color:#996600;">''</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = res.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'='</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> temp.<span style="color:#9900CC;">size</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result<span style="color:#006600; font-weight:bold;">&#91;</span>temp<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = temp<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">return</span> result<br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Prints the response in human-readable format</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @return [Boolean] The result of the SMS sending</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> printResponse<br />
&nbsp; &nbsp; &nbsp; &nbsp; result = <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">getResponse</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> result.<span style="color:#9900CC;">has_key</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'status'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">and</span> result<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'status'</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#996600;">'success'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;SMS sent successfully&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Error sending the SMS, printing the full trace:&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>key,value<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\t</span>#{key} =&gt; #{CGI::unescape(value)}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Encodes the recipients in the correct format</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @param recipients [Array] The Array containing the recipients as String in the format 3912345678 (without + or 00 at the beginning)</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @return [String] The String in the format accepted by the server</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @note This method uses CGI::escape to escape the recipients</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> getRecipients<span style="color:#006600; font-weight:bold;">&#40;</span>recipients<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; recipients.<span style="color:#9900CC;">inject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>result, number<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#996600;">'&amp;'</span> <span style="color:#9966CC; font-weight:bold;">unless</span> number == recipients.<span style="color:#9900CC;">first</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;recipients[]=#{CGI::escape(number)}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Obtains the password from the command line hiding the input</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @return (String) The given password</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> getPassword<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#ff6633; font-weight:bold;">$PASSWORD</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; password = <span style="color:#ff6633; font-weight:bold;">$PASSWORD</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Password:&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;stty -echo&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; password = <span style="color:#ff6633; font-weight:bold;">$stdin</span>.<span style="color:#CC0066; font-weight:bold;">gets</span>.<span style="color:#CC0066; font-weight:bold;">chomp</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;stty echo&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; password<br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Example method to send SMS fast</span><br />
<span style="color:#9966CC; font-weight:bold;">def</span> send_my_sms<span style="color:#006600; font-weight:bold;">&#40;</span>text = <span style="color:#996600;">'Empty'</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; gw = SkebbyGatewaySendSMS.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>$USERNAME, text, <span style="color:#ff6633; font-weight:bold;">$RECIPIENT</span>, <span style="color:#ff6633; font-weight:bold;">$SENDER</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> gw.<span style="color:#9900CC;">sendSMS</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; gw.<span style="color:#9900CC;">printResponse</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Error in the HTTP request&quot;</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Send SMS with Icinga/Nagios</span><br />
<span style="color:#9966CC; font-weight:bold;">if</span> ARGV.<span style="color:#9900CC;">size</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span><br />
&nbsp; &nbsp; text = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; send_my_sms<span style="color:#006600; font-weight:bold;">&#40;</span>text<span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>Il programma può essere usato da linea di comando passandogli il messaggio come primo argomento oppure potete includerlo in un altro script ruby e usare la classe <em>SkebbyGatewaySendSMS</em>.<br />
Se invece salvate questo script, ad esempio, in <em>/usr/local/icinga/libexec/sms_gateway</em> e lo rendete eseguibile, potete usarlo per far mandare SMS a Icinga. Bisogna intanto definire due comandi in <em>etc/objects/commands.cfg</em>:</p>
<pre># 'notify-service-by-sms' command definition
define command{
        command_name    notify-service-by-sms
        command_line      /usr/local/icinga/libexec/sms_gateway "--Nagios Service Notification-- Host: $HOSTNAME$, State: $HOSTSTATE$ Service $SERVICEDESC$ Description: $SERVICESTATE$ Time: $LONGDATETIME$"
}
# 'notify-host-by-sms' command definition
define command{
        command_name    notify-host-by-sms
        command_line      /usr/local/icinga/libexec/sms_gateway "--Nagios Host Notification-- Host: $HOSTNAME$, State: $HOSTSTATE$, Time: $LONGDATETIME$"
}</pre>
<p>Quindi in <em>etc/objects/contacts.cfg</em> aggiungere all&#8217;utente icingaadmin (o chi per lui) le notifiche via SMS:</p>
<pre>define contact{
        contact_name                    icingaadmin
        use                             generic-contact
        alias                           Icinga Admin
        email                           my_email@domain.com
        host_notification_commands      notify-host-by-sms,notify-host-by-email
        service_notification_commands      notify-service-by-sms,notify-service-by-email
        }</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2012/01/18/notifiche-sms-gratis-con-nagiosicinga-e-skebby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to fix redmine-mylyn-connector &#8220;Server Error: undefined method `visible_by&#8217;&#8221;</title>
		<link>http://www.tommyblue.it/2011/12/14/how-to-fix-redmine-mylyn-connector-server-error-undefined-method-visible_by/</link>
		<comments>http://www.tommyblue.it/2011/12/14/how-to-fix-redmine-mylyn-connector-server-error-undefined-method-visible_by/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 13:11:08 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Mylyn]]></category>
		<category><![CDATA[Redmine]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1266</guid>
		<description><![CDATA[With version 5324 the method Project.visible_by has been deprecated in favor of Project.visible_condition and redmine-mylyn-connector plugin stopped working with error: Server Error: undefined by `visible_by&#8217;. Here&#8217;s the patch you need to fix the plugin: diff -r redmine-mylyn-connector-2.7.5/app/controllers/mylyn_connector/issues_controller.rb redmine-mylyn-connector-2.7.5-patched/app/controllers/mylyn_connector/issues_controller.rb 63c63 &#60; :conditions =&#62; &#91;&#34;#{Issue.table_name}.id in (?) and #{Issue.table_name}.updated_on &#62;= ? and &#34; &#60; &#60; Project.visible_by, issues, [...]]]></description>
			<content:encoded><![CDATA[<p>With <a href="http://www.redmine.org/projects/redmine/repository/revisions/5324" target="_blank">version 5324</a> the method <strong>Project.visible_by</strong> has been <a href="http://www.redmine.org/projects/redmine/repository/revisions/5324/diff/trunk/app/models/project.rb" target="_blank">deprecated in favor of <strong>Project.visible_condition</strong></a> and <a href="http://sourceforge.net/apps/wordpress/redmin-mylyncon/" target="_blank">redmine-mylyn-connector</a> plugin stopped working with error:<strong><em> Server Error: undefined by `visible_by&#8217;</em></strong>.</p>
<p>Here&#8217;s the patch you need to fix the plugin:</p>
<pre>
<div class="codecolorer-container ruby railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">diff <span style="color:#006600; font-weight:bold;">-</span>r redmine<span style="color:#006600; font-weight:bold;">-</span>mylyn<span style="color:#006600; font-weight:bold;">-</span>connector<span style="color:#006600; font-weight:bold;">-</span>2.7.5<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>controllers<span style="color:#006600; font-weight:bold;">/</span>mylyn_connector<span style="color:#006600; font-weight:bold;">/</span>issues_controller.<span style="color:#9900CC;">rb</span> redmine<span style="color:#006600; font-weight:bold;">-</span>mylyn<span style="color:#006600; font-weight:bold;">-</span>connector<span style="color:#006600; font-weight:bold;">-</span>2.7.5<span style="color:#006600; font-weight:bold;">-</span>patched<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>controllers<span style="color:#006600; font-weight:bold;">/</span>mylyn_connector<span style="color:#006600; font-weight:bold;">/</span>issues_controller.<span style="color:#9900CC;">rb</span><br />
63c63<br />
<span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{Issue.table_name}.id in (?) and #{Issue.table_name}.updated_on &gt;= ? and &quot;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> Project.<span style="color:#9900CC;">visible_by</span>, issues, cond<span style="color:#006600; font-weight:bold;">&#93;</span><br />
<span style="color:#006600; font-weight:bold;">---</span><br />
<span style="color:#006600; font-weight:bold;">&gt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{Issue.table_name}.id in (?) and #{Issue.table_name}.updated_on &gt;= ? and &quot;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> Project.<span style="color:#9900CC;">visible_condition</span><span style="color:#006600; font-weight:bold;">&#40;</span>User.<span style="color:#9900CC;">current</span><span style="color:#006600; font-weight:bold;">&#41;</span>, issues, cond<span style="color:#006600; font-weight:bold;">&#93;</span><br />
79c79<br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{Issue.table_name}.id in (?) and &quot;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> Project.<span style="color:#9900CC;">visible_by</span>, issues<span style="color:#006600; font-weight:bold;">&#93;</span><br />
<span style="color:#006600; font-weight:bold;">---</span><br />
<span style="color:#006600; font-weight:bold;">&gt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{Issue.table_name}.id in (?) and &quot;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> Project.<span style="color:#9900CC;">visible_condition</span><span style="color:#006600; font-weight:bold;">&#40;</span>User.<span style="color:#9900CC;">current</span><span style="color:#006600; font-weight:bold;">&#41;</span>, issues<span style="color:#006600; font-weight:bold;">&#93;</span><br />
diff <span style="color:#006600; font-weight:bold;">-</span>r redmine<span style="color:#006600; font-weight:bold;">-</span>mylyn<span style="color:#006600; font-weight:bold;">-</span>connector<span style="color:#006600; font-weight:bold;">-</span>2.7.5<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>controllers<span style="color:#006600; font-weight:bold;">/</span>mylyn_connector<span style="color:#006600; font-weight:bold;">/</span>projects_controller.<span style="color:#9900CC;">rb</span> redmine<span style="color:#006600; font-weight:bold;">-</span>mylyn<span style="color:#006600; font-weight:bold;">-</span>connector<span style="color:#006600; font-weight:bold;">-</span>2.7.5<span style="color:#006600; font-weight:bold;">-</span>patched<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>controllers<span style="color:#006600; font-weight:bold;">/</span>mylyn_connector<span style="color:#006600; font-weight:bold;">/</span>projects_controller.<span style="color:#9900CC;">rb</span><br />
16c16<br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">&quot;enabled_modules.name = 'issue_tracking' AND #{Project.visible_by}&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#006600; font-weight:bold;">---</span><br />
<span style="color:#006600; font-weight:bold;">&gt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">&quot;enabled_modules.name = 'issue_tracking' AND #{Project.visible_condition(User.current)}&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
diff <span style="color:#006600; font-weight:bold;">-</span>r redmine<span style="color:#006600; font-weight:bold;">-</span>mylyn<span style="color:#006600; font-weight:bold;">-</span>connector<span style="color:#006600; font-weight:bold;">-</span>2.7.5<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>controllers<span style="color:#006600; font-weight:bold;">/</span>mylyn_connector<span style="color:#006600; font-weight:bold;">/</span>queries_controller.<span style="color:#9900CC;">rb</span> redmine<span style="color:#006600; font-weight:bold;">-</span>mylyn<span style="color:#006600; font-weight:bold;">-</span>connector<span style="color:#006600; font-weight:bold;">-</span>2.7.5<span style="color:#006600; font-weight:bold;">-</span>patched<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>controllers<span style="color:#006600; font-weight:bold;">/</span>mylyn_connector<span style="color:#006600; font-weight:bold;">/</span>queries_controller.<span style="color:#9900CC;">rb</span><br />
18c18<br />
<span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;(#{Query.table_name}.is_public = ? OR #{Query.table_name}.user_id = ?) AND (project_id IS NULL OR &quot;</span> &nbsp;<span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> Project.<span style="color:#9900CC;">visible_by</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;)&quot;</span>, <span style="color:#0000FF; font-weight:bold;">true</span>, User.<span style="color:#9900CC;">current</span>.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<br />
<span style="color:#006600; font-weight:bold;">---</span><br />
<span style="color:#006600; font-weight:bold;">&gt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;(#{Query.table_name}.is_public = ? OR #{Query.table_name}.user_id = ?) AND (project_id IS NULL OR &quot;</span> &nbsp;<span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> Project.<span style="color:#9900CC;">visible_condition</span><span style="color:#006600; font-weight:bold;">&#40;</span>User.<span style="color:#9900CC;">current</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;)&quot;</span>, <span style="color:#0000FF; font-weight:bold;">true</span>, User.<span style="color:#9900CC;">current</span>.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#93;</span>,</div></div>
</pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/12/14/how-to-fix-redmine-mylyn-connector-server-error-undefined-method-visible_by/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accesso SSH inverso</title>
		<link>http://www.tommyblue.it/2011/11/10/accesso-ssh-inverso/</link>
		<comments>http://www.tommyblue.it/2011/11/10/accesso-ssh-inverso/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 11:09:40 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Memoria usiliaria]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1260</guid>
		<description><![CDATA[Può tornare utile accedere via SSH ad un pc/server non pubblico. Capita ad esempio quando un cliente disperato sta provando a mettere le mani sul server impallato e tu stai cercando di dettargli i comandi al telefono (generalmente con pessimi risultati). Quindi basta avere un server SSH a cui il cliente possa arrivare con un [...]]]></description>
			<content:encoded><![CDATA[<p>Può tornare utile accedere via SSH ad un pc/server non pubblico. Capita ad esempio quando un cliente disperato sta provando a mettere le mani sul server impallato e tu stai cercando di dettargli i comandi al telefono (generalmente con pessimi risultati).</p>
<p>Quindi basta avere un server SSH a cui il cliente possa arrivare con un utente da utilizzare.<br />
Supponendo che il server da raggiungere sia <em>ssh-server.test.com</em> e l&#8217;utente <em>test</em>, basta che digiti il comando:</p>
<pre>ssh -R 9000:127.0.0.1:22 -p 22 -l test ssh-server.test.com -N</pre>
<p>Una volta inserita la password la sua console rimarrà &#8220;appesa&#8221; e voi, dal vostro server, potrete accedere alla sua macchina con:</p>
<pre>ssh utente@127.0.0.1 -p 9000</pre>
<p>Chiaramente avrete bisogno di un utente sulla sua macchina.</p>
<p>Et voilà, cliente contento e nessuna crisi di nervi per voi nel tentare di spiegargli dove mettere spazi e slash :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/11/10/accesso-ssh-inverso/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installare ChiliProject e Gitolite</title>
		<link>http://www.tommyblue.it/2011/10/12/installare-chiliproject-e-gitolite/</link>
		<comments>http://www.tommyblue.it/2011/10/12/installare-chiliproject-e-gitolite/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 16:36:58 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[ChiliProject]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[Gitolite]]></category>
		<category><![CDATA[gitorious]]></category>
		<category><![CDATA[Redmine]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1241</guid>
		<description><![CDATA[In questa guida spiegherò come installare ChiliProject (il fork del più famoso Redmine), Gitolite e come gestire i repository GIT da ChiliProject grazie al plugin (che funziona anche con Redmine) redmine_git_hosting. Il tutto verrà installato su Ubuntu server 10.04 LTS. A differenza delle guide che si trovano in giro la mia configurazione farà tutto con [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tommyblue.it/wp-content/uploads/2011/10/chili-e1318437213274.jpg" rel="lightbox[1241]"><img class="aligncenter size-full wp-image-1253" title="ChiliProject" src="http://www.tommyblue.it/wp-content/uploads/2011/10/chili-e1318437213274.jpg" alt="" width="400" height="266" /></a>In questa guida spiegherò come installare <a title="ChiliProject Home" href="http://www.chiliproject.org" target="_blank">ChiliProject</a> (il fork del più famoso <a title="Redmine" href="http://www.redmine.org" target="_blank">Redmine</a>), <a title="Gitolite" href="https://github.com/sitaramc/gitolite" target="_blank">Gitolite</a> e come gestire i repository GIT da ChiliProject grazie al plugin (che funziona anche con Redmine) <a href="https://github.com/ericpaulbishop/redmine_git_hosting" target="_blank">redmine_git_hosting</a>.</p>
<p>Il tutto verrà installato su <strong>Ubuntu server 10.04 LTS</strong>.</p>
<p>A differenza delle guide che si trovano in giro la mia configurazione farà tutto con i permessi di un utente utilizzando RVM e Passenger. Tutti i comandi che citerò sono lanciati dalla shell dell&#8217;utente, quindi quando ho bisogno di permessi elevati utilizzo <strong>sudo</strong>. L&#8217;utente usato sarà lo stesso che userà gitolite, quindi se non volete &#8220;sporcare&#8221; il vostro potete crearne uno ad-hoc, ad esempio <em>git</em>.</p>
<h2>Installare RVM</h2>
<p>La wiki del progetto è molto dettagliata. I passaggi, in breve, sono questi.</p>
<p>Iniziamo installando un po&#8217; di pacchetti:</p>
<pre>sudo aptitude install build-essential curl libssl-dev zlib1g-dev libreadline5-dev libxml2-dev git-core imagemagick libmagick-dev libmagickcore-dev</pre>
<p>Si può quindi installare RVM:</p>
<pre>bash &lt; &lt;(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)</pre>
<p>Se lo script non lo avesse fatto inserite la seguente riga in fondo a .bashrc (o .zshrc, a seconda di quale shell usate):</p>
<pre>[[ -s "/home/drwolf/.rvm/scripts/rvm" ]] &amp;&amp; source "/home/drwolf/.rvm/scripts/rvm"</pre>
<p>Date comunque una lettura all&#8217;output dello script di installazione di RVM.<br />
Riloggatevi e potrete lanciare il comando <strong>rvm</strong>. Fatelo per installare Ruby, io userò Ruby Enterprise Edition, volendo si può usare Ruby 1.8.7:</p>
<pre>rvm install ree
rvm use --default ree</pre>
<p>La mia scelta per il database è MySQL, voi fate la vostra:</p>
<pre>sudo aptitude install mysql-server libmysqlclient-dev</pre>
<p>A questo punto il necessario è installato e posso creare il gemset per ChiliProject e installare le gemme necessarie:</p>
<pre>rvm gemset create chiliproject
rvm gemset use chiliproject
gem install bundler</pre>
<h2>Installare ChiliProject</h2>
<p>Come spiegato farò tutto da utente, quindi posso clonare il repository di ChiliProject direttamente nella home:</p>
<pre>cd
git clone git://github.com/chiliproject/chiliproject.git
cd chiliproject
git checkout stable</pre>
<p>Con bundle è immediato installare le gemme necessarie:</p>
<pre>bundle install --without=test sqlite postgres mysql</pre>
<p>Se non avete scelto MySQL 5.1 come me guardate la <a href="https://www.chiliproject.org/projects/chiliproject/wiki/Bundler" target="_blank">pagina della wiki</a> per lanciare bundler con le giuste opzioni.<br />
A questo punto bisogna creare il database e l&#8217;utente per usarlo:</p>
<pre>create database chiliproject character set utf8;
grant all on chiliproject.* to 'chiliproject'@'localhost' identified by 'my_password' with grant option;</pre>
<p>Questi dati vanno inseriti in ChiliProject, in <em>config/database.yml</em> (fate attenzione all&#8217;adapter, che ho cambiato in <strong>mysql2</strong>):</p>
<pre>production:
  adapter: mysql2
  database: chiliproject
  host: localhost
  port: 3306
  username: chiliproject
  password: my_password</pre>
<p>Il file database <em>config/database.yml.example</em> è il template da usare per <em>config/database.yml</em>. Stessa cosa dicasi per <em>config/configuration.yml.example</em>. Usate <a href="https://www.chiliproject.org/projects/chiliproject/wiki/Configuration_File" target="_blank">l&#8217;apposita pagina della wiki</a> per configurare quest&#8217;ultimo file.<br />
Per concludere lanciate questi rake:</p>
<pre>bundle exec rake generate_session_store
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake redmine:load_default_data</pre>
<p>Per testare l&#8217;installazione si può lanciare Webrick e collegarsi via HTTP al server sulla porta 3000:</p>
<pre>bundle exec script/server -e production</pre>
<h2>Installare Passenger per Apache</h2>
<p>Per servire ChiliProject sulla porta 80 bisogna installare Apache e Passenger:</p>
<pre>sudo apt-get install apache2 apache2-threaded-dev libcurl4-openssl-dev
gem install passenger
passenger-install-apache2-module</pre>
<p>Terminata l&#8217;installazione bisogna creare il file del modulo di apache (<em>/etc/apache2/mods-available/passenger.load</em>) con il contenuto suggerito dall&#8217;installer, nel mio caso:</p>
<pre>LoadModule passenger_module /home/tommyblue/.rvm/gems/ree-1.8.7-2011.03@chiliproject/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
PassengerRoot /home/tommyblue/.rvm/gems/ree-1.8.7-2011.03@chiliproject/gems/passenger-3.0.9
PassengerRuby /home/tommyblue/.rvm/wrappers/ree-1.8.7-2011.03@chiliproject/ruby</pre>
<p>Per attivare il modulo:</p>
<pre>sudo a2enmod passenger</pre>
<p>Infine bisogna creare un <em>VirtualHost</em> (o modificare, come ho fatto io, quello di default) facendo puntare la <em>DocumentRoot</em> alla cartella <em>/public</em> di ChiliProject:</p>
<pre>&lt;VirtualHost *:80&gt;
        ServerAdmin webmaster@localhost

        DocumentRoot /home/tommyblue/chiliproject/public
        &lt;Directory /home/tommyblue/chiliproject/public&gt;
                AllowOverride all              
                Options -MultiViews            
                Order allow,deny
                allow from all
        &lt;/Directory&gt;

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined
&lt;/VirtualHost&gt;</pre>
<p>Riavviamo Apache e ChiliProject sarà sulla porta 80. I dati per il primo accesso sono <em>admin/admin</em>.</p>
<h2>Installare Gitolite</h2>
<p>Come citato nella stessa <a href="https://github.com/sitaramc/gitolite#_quick_install" target="_blank">documentazione di Gitolite</a> i passaggi sono pochi e semplici:</p>
<pre>git clone git://github.com/sitaramc/gitolite
cd gitolite
src/gl-system-install
gl-setup ~/YourName.pub</pre>
<p>Dove <em>YourName.pub</em> è la vostra chiave pubblica.<br />
La documentazione completa si trova qui: <a href="http://sitaramc.github.com/gitolite/" target="_blank">http://sitaramc.github.com/gitolite/</a></p>
<h2>Combinare le due cose</h2>
<p>Per permettere la gestione di Gitolite a ChiliProject è necessario il plugin <a href="https://github.com/ericpaulbishop/redmine_git_hosting" target="_blank"><em>Redmine Git Hosting</em></a>. Per iniziare bisogna creare una coppia di chiavi per un utente <em>gitolite</em>:</p>
<pre>ssh-keyget -t rsa -f gitolite</pre>
<p>Si clona quindi il repository di gestione di Gitolite:</p>
<pre>git clone YourName@server:gitolite-admin</pre>
<p>dove <em>YourName</em> è l&#8217;utente che ha la chiave privata della chiave pubblica che avevamo inserito durante l&#8217;installazione di Gitolite.<br />
Si sposta il file <em>gitolite.pub</em> in <em>gitolite-admin/keydir</em> e si modifica <em>gitolite-admin/conf/gitolite.conf</em> aggiungendo l&#8217;utente gitolite al repository <em>gitolite-admin</em>:</p>
<pre>repo    gitolite-admin
        RW+     =   YourName gitolite</pre>
<p>Si committa e si pusha. Adesso l&#8217;utente <em>gitolite</em> ha i giusti permessi per configurare Gitolite.</p>
<p>A questo punto si torna a lavorare su ChiliProject, creando la cartella <em>~/chiliproject/.ssh</em> e spostandoci le chiavi pubblica/privata generate precedentemente:</p>
<pre>cd ~/chiliproject
mkdir .ssh
cp /somewhere/gitolite .ssh/gitolite
cp /somewhere/gitolite.pub .ssh/gitolite.pub
chmod 700 .ssh
chmod 600 .ssh/gitolite
chmod 644 .ssh/gitolite.pub</pre>
<p>Finalmente si può installare il plugin:</p>
<pre>cd ~/chiliproject/vendor/plugins
git clone https://github.com/ericpaulbishop/redmine_git_hosting.git
rm -rf redmine_git_hosting/.git</pre>
<p>Prima di lanciare la migrazione bisogna modificare il file <em>redmine_git_hosting/init.rb</em> per adattarlo al proprio sistema. Consiglio di leggere direttamente nella <a href="https://github.com/ericpaulbishop/redmine_git_hosting" target="_blank">wiki</a> il significato dei vari parametri.<br />
Si può quindi lanciare la migrazione, nel mio caso mi ha anche chiesto di aggiungere alcune gemme, quindi:</p>
<pre>bundle install
RAILS_ENV=production rake db:migrate_plugins
touch tmp/restart.txt</pre>
<p>Adesso loggandosi in Chiliproject, nella pagina &#8220;Il mio utente&#8221; è possibile inserire la propria chiave pubblica, che deve essere unica (quindi non tra quelle usate finora).</p>
<p>Per concludere si va in <em>Amministrazione &gt; Plugin</em> e si configura il plugin. Le opzioni sono le stesse che si trovano in <em>init.rb</em>. In più ho abilitato <em>Automatically Initialize Git Repositories For New Projects</em>: in questo modo ogni volta che creo un progetto, ChiliProject mi crea un repository Git su cui posso lavorare.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/10/12/installare-chiliproject-e-gitolite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IPv6 in pochi passi con ALIX e SixXS</title>
		<link>http://www.tommyblue.it/2011/08/03/ipv6-in-pochi-passi-con-alix-e-sixxs/</link>
		<comments>http://www.tommyblue.it/2011/08/03/ipv6-in-pochi-passi-con-alix-e-sixxs/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 15:41:51 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Software Libero]]></category>
		<category><![CDATA[ALIX]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[SixXs]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1190</guid>
		<description><![CDATA[Come ormai saprete (1 &#8211; 2) ho un debole per gli embedded ALIX di PcEngines. In questo caso userò una scheda 2d13 con RTC, indispensabile perché se il vostro orologio non è sincronizzato con quello del broker IPv4-IPv6 (±30 secondi) non avrete la connessione IPv6! Come da tradizione il sistema operativo è Debian Voyage, ma tutta la [...]]]></description>
			<content:encoded><![CDATA[<p>Come ormai saprete (<a href="http://www.tommyblue.it/2010/05/25/endian-firewall-su-alix/">1</a> &#8211; <a href="http://www.tommyblue.it/2010/02/12/costruirsi-un-sistema-di-monitoraggio-casalingo-con-nagios-parte-1/">2</a>) ho un debole per gli embedded ALIX di <a title="PC Engines" href="http://pcengines.ch/" target="_blank">PcEngines</a>. In questo caso userò una scheda <a href="http://pcengines.ch/alix2d13.htm" target="_blank">2d13</a> con <strong>RTC</strong>, indispensabile perché se il vostro orologio non è sincronizzato con quello del broker IPv4-IPv6 (±30 secondi) non avrete la connessione IPv6!</p>
<p>Come da tradizione il sistema operativo è <a href="http://linux.voyage.hk/" target="_blank">Debian Voyage</a>, ma tutta la procedura può comunque essere applicata ad una qualsiasi macchina con installato un os <em>Debian-based</em> (a meno di qualche piccola modifica). Per altri sistemi operativi guardate la <a title="Wiki di SixXS" href="https://www.sixxs.net/wiki/" target="_blank">wiki di SixXS</a>.</p>
<h2>SixXS</h2>
<p>Il primo passo è, per l&#8217;appunto, quello di <a href="http://www.sixxs.net/signup/create/" target="_blank">registrarsi su SixXS</a> e richiedere un account. La registrazione, prima di essere accettata, deve essere verificata manualmente quindi probabilmente potrebbe passare qualche giorno (nel mio caso ci sono voluti pochi minuti).</p>
<p>Una volta ottenuti i dati di accesso bisogna richiedere un tunnel. In questa guida coprirò la configurazione di un tunnel heartbeat con Aiccu. Anche la richiesta del tunnel richiede approvazione, quindi in attesa possiamo configurare il sistema (una volta approvato il tunnel basta inserirne il nome in <em>/etc/aiccu.conf</em> e gli ip in <em>/etc/network/interfaces</em>).</p>
<h2>AICCU</h2>
<p>Come premesso il sistema deve avere l&#8217;ora corretta con uno scarto massimo di 30 secondi, altrimenti AICCU non stabilisce la connessione. Nel più semplice dei casi per farlo basta installare il pacchetto <strong>ntp</strong>. AICCU logga in <em>/var/log/syslog</em>, ecco il tipico errore per problemi di sincronizzazione:</p>
<div class="codecolorer-container bash railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">~<span style="color: #666666; font-style: italic;"># cat /var/log/syslog | grep aiccu</span><br />
<br />
Apr <span style="color: #000000;">28</span> 08:<span style="color: #000000;">50</span>:<span style="color: #000000;">19</span> voyage aiccu<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1731</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: sock_getline<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> : <span style="color: #ff0000;">&quot;200 Client Identity accepted&quot;</span><br />
Apr <span style="color: #000000;">28</span> 08:<span style="color: #000000;">50</span>:<span style="color: #000000;">19</span> voyage aiccu<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1731</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: sock_printf<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>  : <span style="color: #ff0000;">&quot;get unixtime&quot;</span><br />
Apr <span style="color: #000000;">28</span> 08:<span style="color: #000000;">50</span>:<span style="color: #000000;">19</span> voyage aiccu<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1731</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: sock_getline<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> : <span style="color: #ff0000;">&quot;200 1312374039&quot;</span><br />
Apr <span style="color: #000000;">28</span> 08:<span style="color: #000000;">50</span>:<span style="color: #000000;">19</span> voyage aiccu<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1731</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: The clock is off by <span style="color: #000000;">355469420</span> seconds, use NTP to <span style="color: #c20cb9; font-weight: bold;">sync</span> it<span style="color: #000000; font-weight: bold;">!</span><br />
Apr <span style="color: #000000;">28</span> 08:<span style="color: #000000;">50</span>:<span style="color: #000000;">19</span> voyage aiccu<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1731</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: sock_printf<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>  : <span style="color: #ff0000;">&quot;QUIT Aborting: Clock is off by 355469420 seconds &quot;</span><br />
Apr <span style="color: #000000;">28</span> 08:<span style="color: #000000;">50</span>:<span style="color: #000000;">19</span> voyage aiccu<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1731</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Couldn<span style="color: #ff0000;">'t retrieve first tunnel for the above reason, aborting</span></div></div>
<p>Una volta sincronizzato l&#8217;orario si può procedere installando il pacchetto <strong>aiccu</strong><em> </em>. All&#8217;installazione vi verranno chiesti i dati di accesso a SixXS. Oltre a questo ho scommentato soltanto due righe in <em>/etc/aiccu.conf</em>, riporto tutto il file:</p>
<pre>username MY_USERNAME
password MY_PASSWORD
protocol tic
server tic.sixxs.net
ipv6_interface sixxs
tunnel_id MY_TUNNEL
verbose false
daemonize true
automatic true
requiretls false
makebeats true</pre>
<p>Basta adattare le variabili <em>username</em>, <em>password</em> e <em>tunnel_id</em> (tutti dati che vi devono essere dati da SixXS) e il gioco è fatto.<br />
Molte informazioni le potete trovare anche nella wiki di SixXS: <a href="http://www.sixxs.net/wiki/Aiccu" target="_blank">http://www.sixxs.net/wiki/Aiccu</a></p>
<h2>Interfaccia di rete</h2>
<p>Quando il tunnel ci verrà attivato potremo configurare l&#8217;interfaccia, nello specifico inserendo questa configurazione in <em>/etc/network/interfaces</em> (utilizzando i dati che abbiamo ottenuto):</p>
<div class="codecolorer-container bash railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">auto sixxs<br />
iface sixxs inet6 v4tunnel<br />
address MY_IPV6_IP<br />
netmask <span style="color: #000000;">64</span><br />
endpoint 213.254.12.34<br />
ttl <span style="color: #000000;">64</span><br />
up <span style="color: #c20cb9; font-weight: bold;">ip link</span> <span style="color: #000000; font-weight: bold;">set</span> mtu <span style="color: #000000;">1280</span> dev sixxs<br />
up <span style="color: #c20cb9; font-weight: bold;">ip route</span> add default via MY_IPV6_GATEWAY dev sixxs</div></div>
<p>L&#8217;IPv4 dell&#8217;endpoint è quello italiano, ad ogni modo nella mail di conferma attivazione del tunnel c&#8217;è scritto tutto. Il vostro indirizzo IP e quello del gateway differiscono soltanto per l&#8217;ultima cifra: <strong>:1</strong> per il gateway e <strong>:2</strong> per il vostro IP.</p>
<h2>Test IPv6</h2>
<p>Terminati questi passaggi il nostro IPv6 dovrebbe essere pronto. Riavviamo AICCU e la rete (<em>/etc/init.d/networking restart</em>) e testiamo il tutto pingando (occhio, ci vuole <em>ping6</em>) il gateway IPv6.<br />
Per ulteriore prova si può visitare ﻿ la home page di <a title="SixXS" href="http://www.sixxs.net/" target="_blank">SixXS</a> dove un blocchetto verde ci accoglierà con un festante <strong>&#8220;You&#8217;ve got IPv6!&#8221;</strong>.<br />
Se siete a terminale e volete testare qualche sito in IPv6 fate attenzione che <strong>lynx</strong> supporta IPv6 mentre <strong>links2</strong> no.</p>
<h2>Subnet, routing e assegnazione IP</h2>
<p>Ora che abbiamo un IPv6 e lo usiamo per navigare da un pc, è giunto il momento di ottenere una subnet <strong>/48</strong> per poter assegnare un IPv6 ad ogni nostro apparato (ovvero ai nostri<strong> <a title="IPv6 Subnet Size Reference Table" href="http://www.potato-people.com/blog/2009/02/ipv6-subnet-size-reference-table/" target="_blank">1.208.925.819.614.629.500.000.000</a> </strong>apparati).</p>
<p>Come al solito il primo passo è richiedere a SixXS una subnet. Una volta ottenuta la rete /48, seguendo la <a href="https://www.sixxs.net/wiki/Installing_a_Subnet" target="_blank">guida nella wiki di Sixxs</a>, andiamo a configurare una /64 per la nostra rete.<br />
Assegniamo staticamente uno di questi indirizzi in <em>/etc/network/interfaces</em>:</p>
<div class="codecolorer-container bash railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iface eth0 inet6 static<br />
address MY_IP_FROM_SUBNET<br />
netmask <span style="color: #000000;">64</span></div></div>
<p>Riavviata la rete, il nostro ALIX avrà un secondo IPv6 (oltre a quello del tunnel). Per permettere il routing e l&#8217;advertising degli indirizzi ip usiamo <strong>radvd</strong>: non si tratta di un DHCPv6 (al momento non esiste un DHCPv6 veramente funzionante) ma di un router IPv6 che periodicamente invia pacchetti multicast di Router Advertisement per permettere l&#8217;autoconfigurazione degli apparati di rete utilizzando gli ip della nostra subnet.<br />
Dopo aver installato il pacchetto <strong>radvd</strong> bisogna creare il file <em>/etc/radvd.conf</em> con il seguente contenuto:</p>
<div class="codecolorer-container bash railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">﻿interface eth0<span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
AdvSendAdvert on;<br />
prefix MY_IP_FROM_SUBNET<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">64</span><br />
<span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
AdvOnLink on;<br />
AdvAutonomous on;<br />
AdvRouterAddr on;<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span>;<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span>;</div></div>
<p>Avviamo radvd e abilitiamo il forwarding:</p>
<div class="codecolorer-container bash railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;net.ipv6.conf.all.forwarding=1&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<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>sysctl.conf<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;net.ipv6.conf.default.forwarding=1&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<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>sysctl.conf<br />
sysctl <span style="color: #660033;">-p</span></div></div>
<p>Se tutto è andato come doveva le macchine nella vostra rete dovrebbero ottenere un indirizzo IPv6 (parlo di Mac e Linux, per Windows arrangiatevi.. :) e navigare IPv6.<br />
Provate ad aprire il sito SixXS per averne conferma:</p>
<p><a href="http://www.tommyblue.it/wp-content/uploads/2011/08/Youve-got-ipv6.png" rel="lightbox[1190]"><img class="aligncenter size-full wp-image-1223" title="You've got IPv6!" src="http://www.tommyblue.it/wp-content/uploads/2011/08/Youve-got-ipv6.png" alt="" width="219" height="78" /></a></p>
<h2>Firewall IPv6</h2>
<p>Una cosa che ben presto si capisce di IPv6 è che le tanto odiate NAT in certi casi facevano comodo. Uno di questi è che un IP privato era <strong>privato</strong>. Con IPv6 quasi tutto è pubblico e quindi un firewall è indispensabile.</p>
<p>Ho scritto un breve script per <strong>ip6tables</strong> prendendo spunto dalla wiki si SixXS, dopo averlo personalizzato (dovete settare qualche IP) basta metterlo in <em>/etc/init.d</em> e aggiungerlo al runlevel di default (<em>update-rc.d firewall-ipv6 defaults</em>):</p>
<div class="codecolorer-container bash railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#! /bin/bash</span><br />
<br />
<span style="color: #666666; font-style: italic;">### BEGIN INIT INFO</span><br />
<span style="color: #666666; font-style: italic;"># Provides: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; firewall-ipv6</span><br />
<span style="color: #666666; font-style: italic;"># Required-Start: &nbsp; &nbsp; &nbsp; $remote_fs $syslog</span><br />
<span style="color: #666666; font-style: italic;"># Required-Stop: &nbsp; &nbsp; &nbsp; &nbsp;$remote_fs $syslog</span><br />
<span style="color: #666666; font-style: italic;"># Default-Start: &nbsp; &nbsp; &nbsp; &nbsp;2 3 4 5</span><br />
<span style="color: #666666; font-style: italic;"># Default-Stop: &nbsp; &nbsp; &nbsp; &nbsp; 0 1 6</span><br />
<span style="color: #666666; font-style: italic;"># Short-Description: &nbsp; &nbsp;IPTables-based IPv6 firewall</span><br />
<span style="color: #666666; font-style: italic;">### END INIT INFO</span><br />
<br />
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-e</span><br />
<br />
<span style="color: #666666; font-style: italic;"># /etc/init.d/firewall-ipv6: start and stop the ip6tables firewall</span><br />
<br />
<span style="color: #007800;">IP6</span>=<span style="color: #ff0000;">&quot;/sbin/ip6tables&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># L'indirizzo IP di questa macchina</span><br />
<span style="color: #007800;">THIS_HOST</span>=<span style="color: #ff0000;">&quot;2001:1418:AAAA:AAAA::2&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># La subnet assegnata da SixXS</span><br />
<span style="color: #007800;">SUBNET_PREFIX</span>=<span style="color: #ff0000;">&quot;2001:1418:BBBB::/48&quot;</span><br />
<br />
stop_firewall<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
<span style="color: #666666; font-style: italic;"># First, delete all:</span><br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-F</span><br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-X</span><br />
<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-P</span> INPUT &nbsp; ACCEPT<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-P</span> FORWARD ACCEPT<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-P</span> OUTPUT &nbsp;ACCEPT<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
start_firewall<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
stop_firewall<br />
<br />
<span style="color: #666666; font-style: italic;"># Allow anything on the local link</span><br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> INPUT &nbsp;<span style="color: #660033;">-i</span> lo <span style="color: #660033;">-j</span> ACCEPT<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-o</span> lo <span style="color: #660033;">-j</span> ACCEPT<br />
<br />
<span style="color: #666666; font-style: italic;"># Allow anything out on the internet</span><br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-o</span> sixxs <span style="color: #660033;">-j</span> ACCEPT<br />
<br />
<span style="color: #666666; font-style: italic;"># Allow the localnet access us:</span><br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> INPUT &nbsp; &nbsp;<span style="color: #660033;">-i</span> eth0 &nbsp; <span style="color: #660033;">-j</span> ACCEPT<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> OUTPUT &nbsp; <span style="color: #660033;">-o</span> eth0 &nbsp; <span style="color: #660033;">-j</span> ACCEPT<br />
<br />
<span style="color: #666666; font-style: italic;"># Filter all packets that have RH0 headers:</span><br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-m</span> rt <span style="color: #660033;">--rt-type</span> <span style="color: #000000;">0</span> <span style="color: #660033;">-j</span> DROP<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-m</span> rt <span style="color: #660033;">--rt-type</span> <span style="color: #000000;">0</span> <span style="color: #660033;">-j</span> DROP<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-m</span> rt <span style="color: #660033;">--rt-type</span> <span style="color: #000000;">0</span> <span style="color: #660033;">-j</span> DROP<br />
<br />
<span style="color: #666666; font-style: italic;"># Allow Link-Local addresses</span><br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-s</span> fe80::<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> <span style="color: #660033;">-j</span> ACCEPT<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-s</span> fe80::<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> <span style="color: #660033;">-j</span> ACCEPT<br />
<br />
<span style="color: #666666; font-style: italic;"># Allow multicast</span><br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-s</span> ff00::<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span> <span style="color: #660033;">-j</span> ACCEPT<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-s</span> ff00::<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span> <span style="color: #660033;">-j</span> ACCEPT<br />
<br />
<span style="color: #666666; font-style: italic;"># Allow ICMPv6 everywhere</span><br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-I</span> INPUT &nbsp;<span style="color: #660033;">-p</span> icmpv6 <span style="color: #660033;">-j</span> ACCEPT<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-I</span> OUTPUT <span style="color: #660033;">-p</span> icmpv6 <span style="color: #660033;">-j</span> ACCEPT<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-I</span> FORWARD <span style="color: #660033;">-p</span> icmpv6 <span style="color: #660033;">-j</span> ACCEPT<br />
<br />
<span style="color: #666666; font-style: italic;"># Allow forwarding</span><br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> NEW <span style="color: #660033;">-i</span> eth0 <span style="color: #660033;">-o</span> sixxs <span style="color: #660033;">-s</span> <span style="color: #007800;">$SUBNET_PREFIX</span> <span style="color: #660033;">-j</span> ACCEPT<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT<br />
<br />
<span style="color: #666666; font-style: italic;"># SSH verso questa macchina</span><br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> sixxs <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> <span style="color: #007800;">$THIS_HOST</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> ACCEPT<br />
<br />
<span style="color: #666666; font-style: italic;"># Accesso a macchine della rete</span><br />
<span style="color: #666666; font-style: italic;">#$IP6 -A FORWARD -i sixxs -p tcp -d $IP_DA_RAGGIUNGERE --dport $PORTA_DA_RAGGIUNGERE -j ACCEPT</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Set the default policy</span><br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-P</span> INPUT &nbsp; DROP<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-P</span> FORWARD DROP<br />
<span style="color: #007800;">$IP6</span> <span style="color: #660033;">-P</span> OUTPUT &nbsp;ACCEPT<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-x</span> <span style="color: #007800;">$IP6</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span><br />
<br />
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-e</span><br />
<br />
<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><br />
start<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Starting Firewall&quot;</span><br />
stop_firewall<br />
start_firewall<br />
<span style="color: #000000; font-weight: bold;">;;</span><br />
stop<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Stopping Firewall&quot;</span><br />
stop_firewall<br />
<span style="color: #000000; font-weight: bold;">;;</span><br />
restart<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Restarting Firewall&quot;</span><br />
stop_firewall<br />
start_firewall<br />
<span style="color: #000000; font-weight: bold;">;;</span><br />
<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #007800;">N</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><span style="color: #007800;">$NAME</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: <span style="color: #007800;">$N</span> {start|stop|restart}&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">2</span><br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">;;</span><br />
<span style="color: #000000; font-weight: bold;">esac</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></div></div>
<p>Per essere sicuri che il firewall funzioni si può usare questa applicazione web: <a title="Tim's Free IPv6 TCP Port Scanner (Firewall Tester)" href="http://ipv6.chappell-family.com/ipv6tcptest/" target="_blank">http://ipv6.chappell-family.com/ipv6tcptest/</a>. Se tutto va bene il risultato dovrebbe essere questo:</p>
<p><a href="http://www.tommyblue.it/wp-content/uploads/2011/08/Firewall-check.png" rel="lightbox[1190]"><img class="aligncenter size-medium wp-image-1224" title="IPv6 firewall check" src="http://www.tommyblue.it/wp-content/uploads/2011/08/Firewall-check-300x144.png" alt="" width="300" height="144" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/08/03/ipv6-in-pochi-passi-con-alix-e-sixxs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SASS facile con Compass.app</title>
		<link>http://www.tommyblue.it/2011/08/02/sass-facile-con-compass-app/</link>
		<comments>http://www.tommyblue.it/2011/08/02/sass-facile-con-compass-app/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 19:56:29 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[SASS]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1205</guid>
		<description><![CDATA[Compass.app è un&#8217;applicazione per MacOSX che aiuta nella compilazione dei file SASS. Una volta configurata tiene sotto controllo i file SASS e li compila al volo in CSS. Il progetto, scritto in Ruby, è open-source e ospitato su GitHub. Viene venduta l&#8217;applicazione compilata a 7$, ma dato che compilarlo è piuttosto semplice (e sono tirchio) [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-1206" title="Compass.App" src="http://www.tommyblue.it/wp-content/uploads/2011/08/128.png" alt="" width="128" height="128" /><a title="Compass.app" href="http://compass.handlino.com/" target="_blank">Compass.app</a> è un&#8217;applicazione per MacOSX che aiuta nella compilazione dei file <a title="SASS" href="http://sass-lang.com/" target="_blank">SASS</a>. Una volta configurata tiene sotto controllo i file SASS e li compila al volo in CSS.</p>
<p>Il progetto, scritto in Ruby, è open-source e <a href="https://github.com/handlino/CompassApp" target="_blank">ospitato su GitHub</a>. Viene venduta l&#8217;applicazione compilata a 7$, ma dato che compilarlo è piuttosto semplice (e sono tirchio) me lo sono compilato.</p>
<p>Ecco come ho fatto:</p>
<p>Il primo passo è installare <a title="JRuby" href="http://www.jruby.org/" target="_blank">JRuby</a>, che con <a href="http://www.tommyblue.it/?s=rvm">RVM</a> si limita ad un semplice:</p>
<pre>rvm install jruby</pre>
<p>Una volta installato creiamo un gemset e installiamo l&#8217;unica gemma necessaria: <a title="Rawr" href="http://rawr.rubyforge.org/" target="_blank">rawr</a></p>
<pre>rvm use jruby
rvm gemset create compassapp
rvm gemset use compassapp
gem install rawr</pre>
<p>Fatto questo bisogna clonare il repository git e lanciare qualche rake:</p>
<pre>git clone https://github.com/handlino/CompassApp.git
cd CompassApp
rake rawr:compile
rake rawr:bundle:app</pre>
<p>Ecco fatto, adesso spostiamo l&#8217;app dalla cartella <em>package/osx</em> a <em>Applicazioni</em> e il gioco è fatto :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/08/02/sass-facile-con-compass-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Impedire a Spotlight di cercare nel dizionario</title>
		<link>http://www.tommyblue.it/2011/07/27/impedire-a-spotlight-di-cercare-nel-dizionario/</link>
		<comments>http://www.tommyblue.it/2011/07/27/impedire-a-spotlight-di-cercare-nel-dizionario/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 00:15:22 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Memoria usiliaria]]></category>
		<category><![CDATA[Mac OSX]]></category>
		<category><![CDATA[Spotlight]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1192</guid>
		<description><![CDATA[C&#8217;è una cosa che odio in maniera viscerale su Spotlight: il fatto che quando si effettuano delle ricerche viene effettuata anche una ricerca sul dizionario (che, personalmente, non ho mai usato). La cosa perdipiù impedisce anche il corretto funzionamento dello stesso Spotlight. Un esempio: se cerco la parola &#8220;App&#8221; probabilmente sto cercando App Store. Quel [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-1193" title="Spotlight" src="http://www.tommyblue.it/wp-content/uploads/2011/07/Spotlight.png" alt="" width="128" height="128" />C&#8217;è una cosa che odio in maniera viscerale su <strong>Spotlight</strong>:<br />
il fatto che quando si effettuano delle ricerche viene effettuata anche una ricerca sul dizionario (che, personalmente, non ho mai usato).</p>
<p>La cosa perdipiù impedisce anche il corretto funzionamento dello stesso Spotlight. Un esempio: se cerco la parola &#8220;App&#8221; probabilmente sto cercando <em>App Store</em>. Quel che accade è che viene cercata la definizione di <em>App</em> ma l&#8217;applicazione <em>App Store</em> non viene neanche visualizzata.</p>
<p>Mi segno quindi questo utilissimo comando da console per disabilitare le ricerche di Spotlight nel dizionario:</p>
<pre>defaults write com.apple.spotlight DictionaryLookupEnabled NO</pre>
<p>P.S. Per i più curiosi la definizione di <em>App</em> è:</p>
<pre>app |ap|
noun Computing
short for application (sense 5).</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/07/27/impedire-a-spotlight-di-cercare-nel-dizionario/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installazione di Gitorious su Ubuntu server 10.04</title>
		<link>http://www.tommyblue.it/2011/06/01/installazione-di-gitorious-su-ubuntu-server-10-04/</link>
		<comments>http://www.tommyblue.it/2011/06/01/installazione-di-gitorious-su-ubuntu-server-10-04/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 14:17:14 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[gitorious]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1160</guid>
		<description><![CDATA[Oggi ho bestemmiato un paio d&#8217;ore per installare Gitorious, progetto che mi ha incuriosito e di cui volevo capirne le potenzialità (in ottica di fargli sostituire l&#8217;ottimo Redmine). Dato che alla fine sono riuscito a farlo funzionare e non ho trovato una guida fatta a modo, ho deciso di mettere nero su bianco ciò che [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-1161" title="Gitorious" src="http://www.tommyblue.it/wp-content/uploads/2011/06/Gitorious.png" alt="" width="95" height="95" />Oggi ho bestemmiato un paio d&#8217;ore per installare <a title="Gitorious" href="http://www.gitorious.org/" target="_blank">Gitorious</a>, progetto che mi ha incuriosito e di cui volevo capirne le potenzialità (in ottica di fargli sostituire l&#8217;ottimo <a title="Remine" href="http://www.redmine.org/" target="_blank">Redmine</a>). Dato che alla fine sono riuscito a farlo funzionare e non ho trovato una guida fatta a modo, ho deciso di mettere nero su bianco ciò che ho fatto.</p>
<p>L&#8217;installazione è stata effettuata su un server virtuale pulito Ubuntu server 10.04 x86_64. Ho provato ad utilizzare <a title="RVM" href="https://rvm.beginrescueend.com/" target="_blank">RVM</a> e ruby 1.9.2 ma non ci sono riuscito&#8230; Ho quindi utilizzato <a title="Ruby Enterprise Edition" href="http://www.rubyenterpriseedition.com/" target="_blank">Ruby Enterprise Edition</a> 1.8.7<span id="more-1160"></span></p>
<p>Per cominciare ho installato un po&#8217; di pacchetti:</p>
<pre>apt-get install build-essential zlib1g-dev tcl-dev libexpat-dev libcurl4-openssl-dev postfix apache2 mysql-server mysql-client apg geoip-bin libgeoip1 libgeoip-dev libaspell-dev aspell sqlite3 libsqlite3-dev imagemagick libpcre3 libpcre3-dev zlib1g zlib1g-dev libyaml-dev libmysqlclient15-dev apache2-dev libonig-dev libmagick++-dev zip unzip memcached git-core git-svn git-doc git-cvs irb sphinxsearch uuid uuid-dev openjdk-6-jre</pre>
<p>Ho scaricato e installato <a title="ActiveMQ" href="http://activemq.apache.org/" target="_blank">ActiveMQ</a> 5.5.0:</p>
<pre>wget http://www.powertech.no/apache/dist/activemq/apache-activemq/5.5.0/apache-activemq-5.5.0-bin.tar.gz
sudo -s
tar xzvf apache-activemq-5.5.0-bin.tar.gz -C /usr/local/
echo "export ACTIVEMQ_HOME=/usr/local/apache-activemq-5.5.0" &gt;&gt; /etc/activemq.conf﻿
echo "export JAVA_HOME=/usr/" &gt;&gt; /etc/activemq.conf
dduser --system --no-create-home activemq
chown -R activemq /usr/local/apache-activemq-5.5.0/data</pre>
<p>Per lanciare ActiveMQ ho utilizzato <a href="http://www.tommyblue.it/wp-content/uploads/2011/06/activemq.txt" target="_blank">questo</a> file, copiato in <em>/etc/init.d</em>:</p>
<pre>wget http://www.tommyblue.it/wp-content/uploads/2011/06/activemq.txt
sudo mv activemq.txt /etc/init.d/activemq
sudo chmod +x /atc/init.d/activemq
sudo update-rc.d activemq defaults
sudo service activemq start</pre>
<p>A questo punto ho scaricato da <a title="REE" href="http://www.rubyenterpriseedition.com/download.html" target="_blank">qui</a> REE e l&#8217;ho installato:</p>
<pre>sudo dpkg -i ﻿﻿ruby-enterprise_1.8.7-2011.03_amd64_ubuntu10.04.deb</pre>
<p>dopodichè ho installato <a title="RubyGems" href="http://rubygems.org/" target="_blank">RubyGems</a>. Come dicevo prima non sono riuscito ad utilizzare RVM proprio a causa di problemi con le gemme. Per far funzionare il tutto ho dovuto installare tutte le gemme da root:</p>
<pre>wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.5.tgz
tar xzf  ﻿rubygems-1.8.5.tgz
cd rubygems-1.8.5/
sudo ruby setup.rb
echo "gem: --no-ri --no-rdoc" &gt; ~/.gemrc</pre>
<p>Installato RubyGems bisogna installare le gemme. <strong>ATTENZIONE</strong>: se fin qui ho più o meno seguito le guide che trovate nella webografia, per le gemme ho fatto tutt&#8217;altro. Infatti per far funzionare Gitorious, che è scritto con Rails 2.3.x, non è possibile installare le gemme <em>as is</em> dato che molte sono ormai incompatibili con Rails 2. Meglio far fare tutto a Bundler o specificare gemma per gemma la versione da installare. Quindi prima cloniamo il repository di Gitorious:</p>
<pre>sudo -s
git clone git://gitorious.org/gitorious/mainline.git /var/www/gitorious
cd /var/www/gitorious
gem install bundler
bundle install
gem install -b -v 1.1 stomp
gem install rmagick passenger stompserver raspell
gem install -v=0.8.7 rake
passenger-install-apache2-module</pre>
<p>Al termine dell&#8217;ultimo passaggio creare il file <em>/etc/apache2/mods-available/passenger.load</em> con quanto suggerito dallo script precedente. Nel mio caso:</p>
<pre>LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.7
PassengerRuby /usr/local/bin/ruby</pre>
<p>Per attivare il modulo:</p>
<pre>a2enmod passenger
a2enmod rewrite
a2enmod ssl
a2enmod expires
service apache2 restart</pre>
<p>Ok, adesso ho copiato i necessari script di avvio:</p>
<pre>cp /var/www/gitorious/doc/templates/ubuntu/git-daemon /etc/init.d/
cp /var/www/gitorious/doc/templates/ubuntu/git-ultrasphinx /etc/init.d/</pre>
<p>In <em>/etc/init.d/git-daemon</em> modificare GIT_DAEMON come segue:</p>
<pre>GIT_DAEMON="/usr/bin/local/ruby /var/www/gitorious/script/git-daemon -d"</pre>
<p>Creare anche <em>/etc/init.d/stomp</em>:</p>
<pre>#!/bin/sh
# Start/stop the stompserver
#
### BEGIN INIT INFO
# Provides:          stomp
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      1
# Short-Description: Stomp
# Description:       Stomp
### END INIT INFO   

test -f /usr/local/bin/stompserver || exit 0    

. /lib/lsb/init-functions    

case "$1" in
start)  log_daemon_msg "Starting stompserver" "stompserver"
    start-stop-daemon --start --name stompserver --startas /usr/local/bin/stompserver --background --user git
    log_end_msg $?
    ;;
stop)  log_daemon_msg "Stopping stompserver" "stompserver"
    start-stop-daemon --stop --name stompserver
    log_end_msg $?
    ;;
restart) log_daemon_msg "Restarting stompserver" "stompserver"
    start-stop-daemon --stop --retry 5 --name stompserver
    start-stop-daemon --start --name stompserver --startas /usr/local/bin/stompserver --background --user git
    log_end_msg $?
    ;;
status)
    status_of_proc /usr/local/bin/stompserver stompserver &amp;&amp; exit 0 || exit $?
    ;;
*)      log_action_msg "Usage: /etc/init.d/stomp {start|stop|restart|status}"
    exit 2
    ;;
esac
exit 0</pre>
<p>e <em>/etc/init.d/git-poller</em>:</p>
<pre>#!/bin/sh
# Start/stop the git poller
#
### BEGIN INIT INFO
# Provides:          git-poller
# Required-Start:    stomp
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      1
# Short-Description: Gitorious poller
# Description:       Gitorious poller
### END INIT INFO    

/bin/su - git -c "cd /var/www/gitorious;RAILS_ENV=production script/poller $@"</pre>
<p>Si possono quindi aggiungere tutti all&#8217;avvio:</p>
<pre>chmod 755 /etc/init.d/git-ultrasphinx /etc/init.d/git-daemon /etc/init.d/stomp /etc/init.d/git-poller
update-rc.d stomp defaults
update-rc.d git-daemon defaults
update-rc.d git-ultrasphinx defaults
update-rc.d git-poller defaults</pre>
<p>Bisogna creare la configurazione di apache. Gitorious utilizza SSL per il login, quindi i VirtualHost sono 2, io ho creato il file <em>/etc/apache2/sites-available/gitorious</em>:</p>
<pre>&lt;VirtualHost *:80&gt;
  ServerName MIODOMINIO
  DocumentRoot /var/www/gitorious/public
&lt;/VirtualHost&gt;
&lt;IfModule mod_ssl.c&gt;
  &lt;VirtualHost _default_:443&gt;
    ServerName MIODOMINIO
    DocumentRoot /var/www/gitorious/public
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
    BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
  &lt;/VirtualHost&gt;
&lt;/IfModule&gt;</pre>
<p>e quindi l&#8217;ho attivato:</p>
<pre>a2dissite default
a2ensite gitorious</pre>
<p>Torniamo a Gitorious che abbiamo un po&#8217; lasciato indietro. Serve un utente git che sarà il proprietario dell&#8217;applicazione:</p>
<pre>adduser --system --home /var/www/gitorious/ --no-create-home --group --shell /bin/bash git
chown -R git:git /var/www/gitorious
su - git
cd /var/www/gitorious
mkdir .ssh
touch .ssh/authorized_keys
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
mkdir -p tmp/pids repositories tarballs
cp config/database.sample.yml config/database.yml
cp config/gitorious.sample.yml config/gitorious.yml
cp config/broker.yml.example config/broker.yml</pre>
<p>Modificare <em>config/database.yml</em> lasciando soltanto la sezione production e le sue configurazioni. Inserire un utente MySQL con permessi sul database <em>gitorious_production</em> (se non volete creare a mano questo db utilizzate un utente in grado di creare database). Nel file <em>config/gitorious.yml</em> inserite:</p>
<pre>production:
  cookie_secret: "FRASESEGRETISSIMAELUNGHISSIMA"
  repository_base_path: "/var/www/gitorious/repositories"
  gitorious_client_port: 80
  gitorious_client_host: gitorious.dw
  gitorious_host: gitorious.dw
  archive_cache_dir: "/var/www/gitorious/tarballs"
  archive_work_dir: "/tmp/tarballs-work"
  hide_http_clone_urls: true
  is_gitorious_dot_org: false</pre>
<p>Per il valore di <em>cookie_secret</em> utilizzate l&#8217;output del comando <em>apg -m 64</em>.<br />
Ho avuto dei problemi con ActiveSupport, del tipo:</p>
<pre>uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)</pre>
<p>come suggerito <a href="http://makandra.com/notes/1051-fixing-uninitialized-constant-activesupport-dependencies-mutex-nameerror" target="_blank">qui</a> li ho superati inserendo <em>require &#8216;thread&#8217;</em> in <em>config/boot.rb</em> dopo RAILS_ROOT.</p>
<p>A questo punto si può procedere con la migrazione:</p>
<pre>su - git
cd /var/www/gitorious
export RAILS_ENV=production
rake db:create
rake db:migrate
rake ultrasphinx:bootstrap</pre>
<p>L&#8217;ultimo comando dovrebbe restituire un errore ma comunque crea il file di configurazione, che va editato per evitare l&#8217;errore. Il file è  <em>config/ultrasphinx/production.conf</em> in cui va sostituito <em>base_tags</em> con <em>tags</em>. Effettuata la sostituizione su può lanciare Sphinx con:</p>
<pre>rake ultrasphinx:index RAILS_ENV=production
rake ultrasphinx:daemon:start RAILS_ENV=production</pre>
<p>Per l&#8217;aggiornamento degli indici ho creato il file<em> /etc/cron.d/ultrasphinx</em>:</p>
<pre>* */1 * * *       git     cd /var/www/gitorious &amp;&amp; /usr/local/bin/rake ultrasphinx:index RAILS_ENV=production</pre>
<p>Prima di accedere a Gitorious bisogna creare l&#8217;utente admin lanciando, come <em>git</em>, il comando:</p>
<pre>env RAILS_ENV=production ruby script/create_admin</pre>
<p>Riavviamo i servizi (ed eventualmente il server per essere sicuri che al riavvio Gitorious funzioni correttamente):</p>
<pre>service git-daemon start
service apache2 restart</pre>
<p>Colleghiamoci al sito e, se tutto è andato bene, iniziamo ad utilizzare Gitorious!</p>
<p>Resta un&#8217;ultima cosa da fare per poter pushare correttamente, ovvero creare un link simbolico al file <em>/var/www/gitorious/script/gitorious</em> in una cartella presente nella PATH dell&#8217;utente git, io l&#8217;ho creato in<em> /usr/local/bin</em>:</p>
<pre>﻿﻿﻿ln -s /var/www/gitorious/script/gitorious /usr/local/bin/</pre>
<p>Senza questo passaggio al momento del push ottenevo un singolare quanto criptico errore da git:</p>
<pre>bash: gitorious: comando non trovato</pre>
<h3>﻿Webografia</h3>
<ul>
<li><a href="http://www.silly-science.co.uk/2010/12/12/installing-gitorious-on-ubuntu-10-04-howto/">http://www.silly-science.co.uk/2010/12/12/installing-gitorious-on-ubuntu-10-04-howto/</a></li>
<li><a href="http://www.gitorious.org/gitorious/pages/UbuntuInstallation">http://www.gitorious.org/gitorious/pages/UbuntuInstallation</a></li>
<li><a href="http://cjohansen.no/en/ruby/setting_up_gitorious_on_your_own_server">http://cjohansen.no/en/ruby/setting_up_gitorious_on_your_own_server</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/06/01/installazione-di-gitorious-su-ubuntu-server-10-04/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Backup di Zimbra Open Source 7.1.0 con LVM e rsnapshot</title>
		<link>http://www.tommyblue.it/2011/04/21/backup-di-zimbra-open-source-7-1-0-con-lvm-e-rsnapshot/</link>
		<comments>http://www.tommyblue.it/2011/04/21/backup-di-zimbra-open-source-7-1-0-con-lvm-e-rsnapshot/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 14:25:25 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[Rsnapshot]]></category>
		<category><![CDATA[zimbra]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1127</guid>
		<description><![CDATA[Chiunque abbia mai fatto il backup di un server di posta sa che l&#8217;imperativo è &#8220;Ridurre il downtime!&#8221;. Ho recentemente modificato lo script di backup che utilizzavo per il server Zimbra (preso da quelli disponibili qui) in modo da utilizzare gli snapshot di LVM e rsnapshot. Adesso il downtime è limitato al tempo di stop/start [...]]]></description>
			<content:encoded><![CDATA[<p>Chiunque abbia mai fatto il backup di un server di posta sa che l&#8217;imperativo è &#8220;Ridurre il downtime!&#8221;.<br />
Ho recentemente modificato lo script di backup che utilizzavo per il server Zimbra (preso da quelli disponibili <a href="http://wiki.zimbra.com/wiki/Open_Source_Edition_Backup_Procedure" target="_blank">qui</a>) in modo da utilizzare gli snapshot di LVM e rsnapshot. Adesso il downtime è limitato al tempo di stop/start di Zimbra e al tempo di snapshot di LVM (circa 2 minuti in totale, di cui pochi istanti di snapshot) e posso con calma effettuare il backup utilizzando rsnapshot che permette di effettuare backup incrementali con uno &#8220;spreco&#8221; di spazio veramente minimo.</p>
<p>La parte riguardante <strong>rsnapshot</strong> è molto semplice: si deve effettuare il backup della cartella in cui viene montato lo snapshot, ovvero <em>/mnt/tmp_backup/ZimbraBackup/</em>. Il resto della configurazione è standard.</p>
<p>Ecco invece lo script da inserire in <em>/etc/cron.daily/</em>:</p>
<pre>#!/bin/bash

# Where the temporary snapshot will be mounted
TEMPDIR="/mnt/tmp_backup"

# The size of the snapshot volume
VOLSIZE="10G"
# Dynamic volsize, change the mountpoint to fit your conf
#VOLSIZE=`df -h | grep /opt | awk '{print $4}'`

# what to backup, in my case: /dev/vg0/opt
VG="vg0"
LV="opt"

# snapshot name
LV_SNAP="ZimbraBackup"

# lvcreate and lvremove commands path
lvcreate_cmd="/sbin/lvcreate"
lvremove_cmd="/sbin/lvremove"

# Choose the backup
#
# monthly =&gt; first day of month
# weekly =&gt; on sunday
# daily =&gt; daily :)

BACKUP_TYPE="daily"

if [ `date +%d` == "01" ]; then
 BACKUP_TYPE="monthly"
elif [ `date +%u` == "7" ]; then
 BACKUP_TYPE="weekly"
fi

echo -e "Backup started at `date`"

# Stop the Zimbra services
before="$(date +%s)"
echo -e "Stopping the Zimbra services..."
/etc/init.d/zimbra stop || exit
echo -e "Creating a snapshot called $LV_SNAP"

# depending on the time it takes to create the backup and the traffic of your server, you may need to increase the 2G value
$lvcreate_cmd -L$VOLSIZE -s -n $LV_SNAP /dev/$VG/$LV

# Create a mountpoint to mount the logical volume to
echo -e "Creating a mountpoint for the LV..."
mkdir -p $TEMPDIR/$LV_SNAP

# Mount the logical volume to the mountpoint
echo -e "Mounting the snapshot..."

# WARNING: if you use xfs you MUST add nouuid option here!
mount -o ro,nouuid /dev/$VG/$LV_SNAP $TEMPDIR/$LV_SNAP/

# Start the Zimbra services
echo -e "Restarting the Zimbra services..."
/etc/init.d/zimbra start || echo -e "ERROR restarting zimbra"

# Calculates and outputs amount of time the server was down for
after="$(date +%s)"
elapsed="$(expr $after - $before)"
hours=$(($elapsed / 3600))
elapsed=$(($elapsed - $hours * 3600))
minutes=$(($elapsed / 60))
seconds=$(($elapsed - $minutes * 60))
echo -e "Server was down for: $hours hours $minutes minutes $seconds seconds"

# Launch rsnapshot to backup
echo -e "Executing $BACKUP_TYPE backup..."
echo -e "rsnapshot $BACKUP_TYPE"
rsnapshot $BACKUP_TYPE

# Unmount /tmp/$lv_zimbra and remove the logical volume
echo -e "Unmounting and removing the snapshot."
umount /dev/$VG/$LV_SNAP
$lvremove_cmd --force /dev/$VG/$LV_SNAP
echo -e "$lvremove_cmd /dev/$VG/$LV_SNAP"

# Done!
echo -e "Backup ended at `date`"</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/04/21/backup-di-zimbra-open-source-7-1-0-con-lvm-e-rsnapshot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Realizzare un sistema di monitoraggio con Icinga</title>
		<link>http://www.tommyblue.it/2011/03/08/realizzare-un-sistema-di-monitoraggio-con-icinga/</link>
		<comments>http://www.tommyblue.it/2011/03/08/realizzare-un-sistema-di-monitoraggio-con-icinga/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 16:45:38 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Software Libero]]></category>
		<category><![CDATA[Icinga]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Nagios]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1108</guid>
		<description><![CDATA[In questa breve guida spiegherò come installare Icinga (un fork di Nagios che ha ormai superato il genitore) e Icinga Web su Ubuntu 10.04 server. Molti passi sono uguali a quelli che ho già descritto nelle due guide sull&#8217;installazione di Nagios (1 e 2). Operazioni preliminari Installare i pacchetti necessari: apt-get install apache2 bsd-mailx build-essential [...]]]></description>
			<content:encoded><![CDATA[<p>In questa breve guida spiegherò come installare Icinga (un fork di Nagios che ha ormai superato il <em>genitore</em>) e Icinga Web su Ubuntu 10.04 server.</p>
<p>Molti passi sono uguali a quelli che ho già descritto nelle due guide sull&#8217;installazione di Nagios (<a href="http://www.tommyblue.it/2010/02/12/costruirsi-un-sistema-di-monitoraggio-casalingo-con-nagios-parte-1/">1</a> e <a href="http://www.tommyblue.it/2010/02/17/costruirsi-un-sistema-di-monitoraggio-casalingo-con-nagios-parte-2/">2</a>).</p>
<h2>Operazioni preliminari</h2>
<p>Installare i pacchetti necessari:</p>
<pre>apt-get install apache2 bsd-mailx build-essential libgd2-xpm-dev libjpeg62 libjpeg62-dev libpng12-0 libpng12-0-dev snmp libsnmp-base git-core mysql-server mysql-client libdbi0 libdbi0-dev libdbd-mysql</pre>
<p>Aggiungere utenti e gruppi:</p>
<pre>addgroup --system icinga
adduser --system --no-create-home --home /usr/local/icinga --ingroup icinga --disabled-password icinga
addgroup --system icinga-cmd
usermod -a -G icinga-cmd icinga
usermod -a -G icinga-cmd www-data</pre>
<p>Creare il database:</p>
<pre> #&gt; mysql -u root -p
 mysql&gt; CREATE DATABASE icinga;
 GRANT USAGE ON *.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
 GRANT SELECT , INSERT , UPDATE , DELETE ON icinga.* TO 'icinga'@'localhost';
 FLUSH PRIVILEGES ;
 quit</pre>
<p>Scaricare Icinga:</p>
<pre>cd /usr/src
git clone git://git.icinga.org/icinga-core.git
cd icinga-core/
git submodule init
git submodule update
./configure --with-command-group=icinga-cmd --enable-idoutils
make all
make fullinstall
make install-api
cd /usr/local/icinga/etc/
cp idomod.cfg-sample idomod.cfg
cp ido2db.cfg-sample ido2db.cfg</pre>
<p>Editare i due ultimi file per adattarli alle configurazioni del database. Nel file <em>/usr/local/icinga/etc/icinga.cfg</em> scommentare la riga:</p>
<pre>broker_module=/usr/local/icinga/bin/idomod.o config_file=/usr/local/icinga/etc/idomod.cfg</pre>
<p>Creare le tabelle:</p>
<pre> #&gt; cd /path/to/icinga-src/module/idoutils/db/mysql
 #&gt; mysql -u root -p icinga &lt; mysql.sql</pre>
<p><strong>Edit 15/03/11:</strong><br />
Ho dovuto modificare il file <em>/usr/local/icinga/etc/objects/commands.cfg</em> perchè il path al comando <em>mail</em> era sbagliato, quindi modificate le definizioni di <em>notify-host-by-email</em> e <em>notify-service-by-email</em> per utilizzare<em> /usr/bin/mail</em> e non <em>/bin/mail</em>.</p>
<p>Per terminare aggiungere Icinga ai servizi di avvio e lanciare Ido2db e Icinga:</p>
<pre>update-rc.d icinga defaults
/etc/init.d/ido2db start
/etc/init.d/icinga restart</pre>
<h2>Plugins</h2>
<p>Scaricare e installare i <a href="http://www.nagiosplugins.org/" target="_blank">plugin di Nagios</a>. Si faccia riferimento alla<a href="http://www.tommyblue.it/2010/02/12/costruirsi-un-sistema-di-monitoraggio-casalingo-con-nagios-parte-1/" target="_blank"> guida di Nagios</a> per l&#8217;installazione, si presti solo attenzione alle differenti opzioni di configurazione:</p>
<pre>./configure --prefix=/usr/local/icinga --with-cgiurl=/icinga/cgi-bin --with-htmurl=/icinga --with-nagios-user=icinga --with-nagios-group=icinga</pre>
<h2>Configurazione dei check</h2>
<p>Per la configurazione degli host e dei servizi potete vedere le mie precedenti guide per Nagios: <a href="http://www.tommyblue.it/2010/02/12/costruirsi-un-sistema-di-monitoraggio-casalingo-con-nagios-parte-1/">parte 1</a> e <a href="http://www.tommyblue.it/2010/02/17/costruirsi-un-sistema-di-monitoraggio-casalingo-con-nagios-parte-2/">parte 2</a>.</p>
<h2>Le interfacce web</h2>
<p>Icinga ha a disposizione due interfacce web: la classica interfaccia CGI e la nuova Icinga Web. Le due installazioni possono convivere tranquillamente.</p>
<h3>Icinga</h3>
<p>Installare i CGI:</p>
<pre>make cgis
make install-cgis
make install-html
make install-webconf</pre>
<p>Creare l&#8217;utente e la password per l&#8217;accesso:</p>
<pre>htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin</pre>
<h3>Icinga Web</h3>
<p>Installare il necessario:</p>
<pre>apt-get install php5 php5-cli php-pear php5-xmlrpc php5-xsl php5-gd php5-ldap php5-mysql
a2enmod rewrite</pre>
<p>Scaricare e installare Icinga Web:</p>
<pre>cd /usr/src
git clone git://git.icinga.org/icinga-web.git
cd icinga-web
./configure
make install
make install-apache-config</pre>
<p>Creare il database e lo schema:</p>
<pre># mysql -u root -p

mysql&gt; CREATE DATABASE icinga_web;
       GRANT USAGE ON *.* TO 'icinga_web'@'localhost' IDENTIFIED BY 'icinga_web' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
       GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, INDEX ON icinga_web.* TO 'icinga_web'@'localhost';
       quit

# make db-initialize</pre>
<p>E, per finire:</p>
<pre>/etc/init.d/icinga restart
/etc/init.d/apache2 restart</pre>
<p>Se avete utilizzato le impostazioni di default non dovete fare altro, altrimenti date una lettura alla <a title="Installation of the Icinga Web Frontend" href="http://docs.icinga.org/latest/en/icinga-web-scratch.html" target="_blank">guida ufficiale</a>. Riavviate apache e connettetevi al server: <em>http://&lt;hostname&gt;/icinga-web</em></p>
<h2>Webografia</h2>
<ul>
<li><a title="Icinga with IDOUtils Quickstart" href="http://docs.icinga.org/latest/en/quickstart-idoutils.html" target="_blank">http://docs.icinga.org/latest/en/quickstart-idoutils.html</a></li>
<li><a title="Installation of the Icinga Web Frontend" href="http://docs.icinga.org/latest/en/icinga-web-scratch.html" target="_blank">http://docs.icinga.org/latest/en/icinga-web-scratch.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/03/08/realizzare-un-sistema-di-monitoraggio-con-icinga/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

