<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<?xml-stylesheet type="text/css" href="http://linuxevolution.org/styles/feed.css"?>


<title type="html">Filed under: NSLU2 | Linux Evolution dot org and the NSLU2</title>
<subtitle type="html"></subtitle>
<link rel="alternate" type="text/html" href="http://linuxevolution.org"/>
<link rel="self" type="application/atom+xml" href="http://linuxevolution.org/archives/nslu2/index-atom.xml"/>
<updated>2010-12-26T18:50:23-05:00</updated>
<author>
<name>orvtech</name>
<uri>http://linuxevolution.org</uri>
</author>
<id>http://linuxevolution.org/</id>
<generator uri="http://nanoblogger.sourceforge.net" version="3.4">
NanoBlogger
</generator>

<entry>
<title type="html">Find the biggest file or folder inside a directory.</title>
<author>
<name>orvtech</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2010/05/18/find_the_biggest_file_or_folder_inside_a_directory/index.html"/>

<id>http://linuxevolution.org/archives/2010/05/18/find_the_biggest_file_or_folder_inside_a_directory/index.html</id>
<published>2010-05-18T10:57:05-05:00</published>
<updated>2010-05-18T10:57:05-05:00</updated>
<category term="OneLiners" />
<category term="Scripts" />
<category term="NSLU2" />
<category term="Linux" />
<category term="iPhone" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
By using the `du` command we can find the biggest file or directory inside a folder. The next example shows how to list the 10 most biggest files and floders inside 'HOME'
</p>

<pre>du -a ~/ | sort -n -r | head -n 10</pre>

<br />

<p>
If we use the `find` command we can list the 10 biggest files inside a directory, even if they are inside sub-folders.
</p>

<pre>find ~/ -type f -exec ls -ls {} \; | awk '{print $6"\t"$9}' | sort -k1 -n -r | head -n 10</pre>
</div>
</content>

</entry>
<entry>
<title type="html">Web interface for NanoBlogger: Add entries.</title>
<author>
<name>orvtech</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2010/04/21/web_interface_for_nanoblogger_add_entries/index.html"/>

<id>http://linuxevolution.org/archives/2010/04/21/web_interface_for_nanoblogger_add_entries/index.html</id>
<published>2010-04-21T15:55:50-05:00</published>
<updated>2010-04-21T15:55:50-05:00</updated>
<category term="Scripts" />
<category term="NSLU2" />
<category term="nanoblogger" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
Please bare in mind that this is a proof of concept (that works) but here it is a web interface that allows you to submit entries to NanoBlogger through a BASH CGI. The script is rather simple, it just takes the fields title, description and body then writes it to a text file, you can latter process it through a cronjob or just leave it there for then you get a chance parse it by nb.
</p>

<p>
For this we will be using 3 code segments, the first would be the HTML form that will allow us to enter the content and pass those values to the CGI besides those two we have a javascript segment that allow us to preview the actual article that we are submitting.

</p>

<p>
<b>The Form.</b><br />
In other to have a bit of eye-candy i decided to use the heather and cascade style sheet from the actual style i am using for NanoBlogger. I found that the easiest way was to create a file by running `nb -b /path/of/the/blog/ make-file nb_send_entry.txt`. This will create a template that we can use to add the form HTML inside the 'BODY' section.
</p>


<textarea  style="height: 140px"  class="bashcode">
<form name="nb_entrada_send" method="post" ACTION="http://orvtech.com/send_nb_entry.cgi"><table border="0" width="600">
<tr>
<td width="100px">Titulo:</td>
<td width="500px"><input type="text" size="60" maxlength="50" id="title" name="entrada_title" value="Enter Title Here"></td>
</tr>
<tr>
<td width="100px">Descripcion:</td>
<td width="500px"><input type="text" size="60" maxlength="100" id="description" name="entrada_description" value="Enter Description Here"></td>
</tr>
<tr>
<td colspan="2">Contenido:<br />
< textarea cols="75" rows="30" id="body" name="entrada_body">
HTML esta permitido.
</ textarea>
</td>
</tr>
<tr>
<td width="600" colspan="2">
<div align="center "style="margin: auto; align: center; width: 600px;">
<input type="button" name="preview" value="Vista Previa" onclick="return openPreview();" />
&nbsp;&nbsp;<input type=submit value="Enviar" />&nbsp;&nbsp;
<input type="reset" value="Cancelar" />
</div>
</td>
</tr>
</table></form></textarea>


<p>
The product of this code is a web page with the same look and feel that the blog has. Here is a sample from our Spanish site:
</p>
<div><img src="http://orvtech.com/images/entry_form_screensho1.png" /></div>
<p>
<b>The JavaScript.</b><br />
If you take a look at above source code we have a 'preview' button; this button calls the function openPreview. The idea of this function is to show how would the HTML that we are codding look using the current style. You can get a good idea on how would this entry look before you submit it. Here is the code:
</p>



<textarea  style="height: 140px"  class="bashcode">
<script language="JavaScript">
function openPreview()
{
features = 'width=800, height=600, toolbar=no, menubar=no, resizable=no, location=no, directories=no, status=no';
var popWin = window.open ('','Preview_Entry', features);

var popTitleText = popWin.document.getElementById("title");
var titleText = document.getElementById("title");
var popBodyText = popWin.document.getElementById("body");
var bodyText = document.getElementById("body");

popWin.document.writeln('<head><title>Submit an Entry | Linux y el NSLU2</title><link rel="stylesheet" href="/styles/nb_default.css" type="text/css" media="all" /><link rel="shortcut icon" href="/favicon.ico" /></head><body> <div class="border"> <div class="container">  <div id="topmenu">  <ul>  <li><a href="/index.html" title="Inicio"><span>Inicio</span></a></li>  <li><a href="/gallery.html" title="Galería"><span>Galería</span></a></li>  <li><a href="/archives/scripts/index.html" title="BASH Scripts"><span>Scripts</span></a></li>  <li><a href="/articles/el_nslu2/" title="El NSLU2"><span>El NSLU2</span></a></li> <li><a href="/archives/scripts/index.html" title="Linux"><span>Linux</span></a></li> <li><a href="http://orvtech.com/index.html" title="orvtech.com in english"><span>In English</span></a></li>  </ul>  </div> <div id="header"></div><div class="container"><div class="archives"><div class="blogbody"> <h3 class="title">' + titleText.value + '</h3>' + bodyText.value + '</div></div></div></div></div></body>');

popTitleText.value = titleText.value;
popWin.document.close();
}
</script></textarea>



<p>
As you can see we are defining a new window and opening it with the content we entered on the form, it uses the nb_default.css. Most of the customizations can be done on in popWin.document.writeln in case you want to adapt it to your blog.
Remember that this is a proof of concept and that it can still be improved, perhaps we can latter make it to read the blog.conf file. Here is a screenshot of how it looks. 
</p>
<div><img src="http://orvtech.com/images/entry_form_screensho1.png" /></div>

<p>
<b>All you need is BASH.</b><br />
A CGI codded in bash to create the new entry for the blog. Here is the source code of send_nb_entry.cgi
</p>



<textarea  style="height: 140px"  class="bashcode">

#!/bin/bash

echo "Content-type: text/html"
echo -e "Status: 200 \n"
echo -e "<html><head><meta http-equiv=\"refresh\" content=\"2;url=http://orvtech.com\"></head><body><p>ENTRY ACCEPTED IN FOR QUEUE</p></body></html>"

DRAFT_ENTRY_DIRECTORY="/tmp"
POST_DATA=$(</dev/stdin)
TEMP_FILE="/tmp/nb_cgi_send_nb_entry.tmp"

nb_entrada_title=`echo $POST_DATA | sed -n 's/^.*entrada_title=\([^&]*\).*$/\1/p' | sed -e 's/%20/ /g'| sed 's/+/ /g'| sed 's/\%0[dD]//g' | awk '/%/{while(match($0,/\%[0-9a-fA-F][0-9a-fA-F]/)) {$0=substr($0,1,RSTART-1)sprintf("%c",0+("0x"substr($0,RSTART+1,2)))substr($0,RSTART+3);}}{print}'`
nb_entrada_description=`echo $POST_DATA | sed -n 's/^.*entrada_description=\([^&]*\).*$/\1/p' | sed -e 's/%20/ /g'| sed 's/+/ /g'| sed 's/\%0[dD]//g' | awk '/%/{while(match($0,/\%[0-9a-fA-F][0-9a-fA-F]/)) {$0=substr($0,1,RSTART-1)sprintf("%c",0+("0x"substr($0,RSTART+1,2)))substr($0,RSTART+3);}}{print}'`
name_entrada_tmp=`date +%Y-%m-%dT%H_%M_%S.tmp`
echo "TITLE: $nb_entrada_title" > $TEMP_FILE
echo "AUTHOR:" >> $TEMP_FILE
echo "DATE:" >> $TEMP_FILE
echo "DESC: $nb_entrada_description" >> $TEMP_FILE
echo "FORMAT: raw" >> $TEMP_FILE
echo "-----" >> $TEMP_FILE
echo "BODY:" >> $TEMP_FILE

echo $POST_DATA | sed -n 's/^.*entrada_body=\([^&]*\).*$/\1/p' | sed -e 's/%20/ /g'| sed 's/+/ /g'| sed 's/\%0[dD]//g' |\
   awk '/%/{while(match($0,/\%[0-9a-fA-F][0-9a-fA-F]/))\
       {$0=substr($0,1,RSTART-1)sprintf("%c",0+("0x"substr(\
       	      $0,RSTART+1,2)))substr($0,RSTART+3);}}{print}' >> $TEMP_FILE

	      echo "END-----" >> $TEMP_FILE
	      mv `echo -e $TEMP_FILE` `echo -e $DRAFT_ENTRY_DIRECTORY/$name_entrada_tmp`</textarea>




<p>
We can latter import the file defined by $DRAFT_ENTRY_DIRECTORY/$name_entrada_tmp issuing the command:
</p>


<textarea  style="height: 14px"  class="bashcode">
nb -b /path/to/your/blog import entry /tmp/2010-03-02T15_02_01.tmp</textarea>


<p>
This will add the entry to our blog. I though about automating this in the CGI but at this point i prefer to create a central control panel and keep things separated.
</p>
<br /><br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/archives/2010/04/06/interfaz_web_para_agregar_entradas_a_nanoblogger/index.html">Interfaz web para agregar entradas a NanoBlogger.</a>
</i></p><br />
</div>
</content>

</entry>
<entry>
<title type="html">ZNC IRC Bouncer start up script.</title>
<author>
<name>orvtech</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2010/04/21/znc_irc_bouncer_start_up_script/index.html"/>

<id>http://linuxevolution.org/archives/2010/04/21/znc_irc_bouncer_start_up_script/index.html</id>
<published>2010-04-21T12:52:16-05:00</published>
<updated>2010-04-21T12:52:16-05:00</updated>
<category term="Scripts" />
<category term="IRC" />
<category term="NSLU2" />
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
A few weeks a go I published an article about how to have push notifications to your iPhone from an IRC channel events. After installing and configuring ZNC I was a bit disappointed that it didn't had a start up script so I decided to write one. 
</p>
<p>
This script allows you to start, stop, reload the configuration and restart the service. lets take a look at /etc/init.d/zncd
</p>
<textarea class="bashcode"> 
#!/bin/bash
 
 ZNC_FOLDER="/usr/bin"
 ZNC_OWNR="your_user_here"
 
 if [ ! -f $ZNC_FOLDER/znc -o ! -d $ZNC_FOLDER ]
 then
 echo "ZNC startup: cannot start, it appears that it is not installed"
 exit 1
 fi
 
 case "$1" in
 start)
 echo -n "Starting ZNC: "
 su - $ZNC_OWNR -c "$ZNC_FOLDER/znc"
 touch /var/lock/subsys/ZNC
 echo "OK"
 ;;
 stop)
 echo -n "Shutdown ZNC: "
 kill -9 `ps -C znc | awk '{print $1}' | grep ^[0-9]`
 rm -f /var/lock/subsys/ZNC
 echo "OK"
 ;;
 reload)
 echo -n "Reloading ZNC:"
 kill -HUP `ps -C znc | awk '{print $1}' | grep ^[0-9]`
 echo "OK"
 ;;
 status)
 if ps -C znc > /dev/null
 then 
 echo "ZNC Bouncer is running"
 else 
 echo "ZNC Bouncer is not running"
 fi
 ;;
 restart)
 $0 stop
 sleep 2
 $0 start
 ;;
 *)
 echo "Usage: $0 start|stop|restart|reload|status"
 exit 1
 esac
 exit 0</textarea> 
<br /><p>
If your NSLU2 is running gentoo you could add it to the default run level like this:
</p>
<textarea style="height: 18px" class="bashcode"> 
rc-update add zncd default</textarea>
<br /><p>
The output should be something like this:
</p>
<textarea style="height: 18px" class="bashcode"> * zncd added to runlevel default</textarea> 
<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/general/script-de-arranque-para-znc-bouncer/" hreflang="es" rel="friend">script de arranque para ZNC bouncer.</a>
</i></p>
</div>
</content>

</entry>
<entry>
<title type="html">Bluetooh Audio Through the NSLU2.  </title>
<author>
<name>orvtech</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2010/04/11/bluetooh_audio_through_the_nslu2/index.html"/>

<id>http://linuxevolution.org/archives/2010/04/11/bluetooh_audio_through_the_nslu2/index.html</id>
<published>2010-04-11T19:11:00-05:00</published>
<updated>2010-04-11T19:11:00-05:00</updated>
<category term="Scripts" />
<category term="NSLU2" />
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>
<a href="http://twitter.com/POTUSCamacho" rev="Original author of this guide">@POTUSCamacho</a> has an interesting article about how to use the NSLU2 in combination with a USB bluetooth adapter as an audio server. POTUSCamacho explains how to do it with a mono audio adapter but clarifies that it should be possible to do it using a stereo adapter.
</p>

<p>Lets take a look at this interesting howto:</p>

<blockquote cite="http://potuscamacho-industries.blogspot.com/2010/04/linksys-nslu2-utilizing-bluetooth-audio.html">

<p>Once you have installed Ubuntu, log in and update your packages:
</p>
<textarea style="height: 18px"  class="bashcode">
sudo -i apt-get update</textarea>
<p>
Then install the following packages:
</p>
<textarea style="height: 35px" class="bashcode">
sudo -i apt-get install linux-sound-base bluetooth bluez bluez-alsa bluez-btsco bluez-compat bluez-utils python python-bluez vlc</textarea>
<p><i>
Note: I do alot of other development stuff on my unit. I may have left off something, and if so let me know if you try it and it doesn't work.
</i><br />

Now that the needed packages are installed, an .asoundrc needs to be created in your user home directory. An example:
</p>
<textarea style="height: 50px" class="bashcode">
pcm.bluetooth {
type bluetooth
device 00:00:00:00:00:00
}</textarea>
<p>
Edit the device section with the MAC address of your bluetooth headset. To find this, issue a reset of the bluetooth adapter by issuing the command:
</p>
<textarea style="height: 18px" class="bashcode">
hciconfig hci0 reset</textarea>
<p>
Then place your headset in pairing mode and issue the following command:
</p>
<textarea style="height: 18px"  class="bashcode">
sdptool browse</textarea>
<p>
Now copy the following python script into a file named pair.py:
</p>
<textarea style="height: 480px" class="bashcode">
#!/usr/bin/python

import gobject

import sys
import dbus
import dbus.service
import dbus.mainloop.glib

class Rejected(dbus.DBusException):
_dbus_error_name = "org.bluez.Error.Rejected"

class Agent(dbus.service.Object):
exit_on_release = True

def set_exit_on_release(self, exit_on_release):
self.exit_on_release = exit_on_release

@dbus.service.method("org.bluez.Agent",
in_signature="", out_signature="")
def Release(self):
print "Release"
if self.exit_on_release:
mainloop.quit()

@dbus.service.method("org.bluez.Agent",
in_signature="os", out_signature="")
def Authorize(self, device, uuid):
print "Authorize (%s, %s)" % (device, uuid)
authorize = raw_input("Authorize connection (yes/no): ")
if (authorize == "yes"):
return
raise Rejected("Connection rejected by user")

@dbus.service.method("org.bluez.Agent",
in_signature="o", out_signature="s")
def RequestPinCode(self, device):
print "RequestPinCode (%s)" % (device)
return raw_input("Enter PIN Code: ")

@dbus.service.method("org.bluez.Agent",
in_signature="o", out_signature="u")
def RequestPasskey(self, device):
print "RequestPasskey (%s)" % (device)
passkey = raw_input("Enter passkey: ")
return dbus.UInt32(passkey)

@dbus.service.method("org.bluez.Agent",
in_signature="ou", out_signature="")
def DisplayPasskey(self, device, passkey):
print "DisplayPasskey (%s, %d)" % (device, passkey)

@dbus.service.method("org.bluez.Agent",
in_signature="ou", out_signature="")
def RequestConfirmation(self, device, passkey):
print "RequestConfirmation (%s, %d)" % (device, passkey)
confirm = raw_input("Confirm passkey (yes/no): ")
if (confirm == "yes"):
return
raise Rejected("Passkey doesn't match")

@dbus.service.method("org.bluez.Agent",
in_signature="s", out_signature="")
def ConfirmModeChange(self, mode):
print "ConfirmModeChange (%s)" % (mode)

@dbus.service.method("org.bluez.Agent",
in_signature="", out_signature="")
def Cancel(self):
print "Cancel"

def create_device_reply(device):
print "New device (%s)" % (device)
mainloop.quit()

def create_device_error(error):
print "Creating device failed: %s" % (error)
mainloop.quit()

if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.bluez.Manager")

if len(sys.argv) > 1:
path = manager.FindAdapter(sys.argv[1])
else:
path = manager.DefaultAdapter()

adapter = dbus.Interface(bus.get_object("org.bluez", path),
"org.bluez.Adapter")

path = "/test/agent"
agent = Agent(bus, path)

mainloop = gobject.MainLoop()

if len(sys.argv) > 2:
if len(sys.argv) > 3:
device = adapter.FindDevice(sys.argv[2])
adapter.RemoveDevice(device)

agent.set_exit_on_release(False)
adapter.CreatePairedDevice(sys.argv[2], path, "DisplayYesNo",
reply_handler=create_device_reply,
error_handler=create_device_error)
else:
adapter.RegisterAgent(path, "DisplayYesNo")
print "Agent registered"

mainloop.run()

#adapter.UnregisterAgent(path)
#print "Agent unregistered"</textarea>

<p>
Now place your headset into pairing mode again and issue the follow command:
</p>
<textarea style="height: 18px" class="bashcode">sudo -i python pair.py hci0 00:00:00:00:00:00</textarea>

<p>
Once again replacing the address above with your headsets MAC.
The last step involves editing the vlcrc. To do this, issue the command:
</p>

<textarea style="height: 18px" class="bashcode">
pico .vlc/vlcrc
</textarea>

<p>
Scroll down and replace:
</p>

<textarea style="height: 18px" class="bashcode">
alsadev=(default soundcard) </textarea>

<p>To:</p>

<textarea style="height: 18px" class="bashcode">
alsadev=bluetooth</textarea>

<p>
If it does not exist then create it.
</p>

<p>
Now you should be ready to listen to audio. To listen to the audio from NASA TV's online video stream, issue the command:
</p>

<textarea style="height: 18px" class="bashcode">
cvlc --aout-rate 8000 --novideo http://www.nasa.gov/55644main_NASATV_Windows.asx</textarea>

<p>
If everything is working you should hear audio. Keep in mind that the sample rate needs to be 8000Hz since that is the sample rate the headset can handle.
</p>

<p>
To pair another headset, or to re-pair the current, the /var/lib/bluetooth/(your MAC)/linkkeys file must be deleted. It will regenerate once you have paired the devices. Also remember that the .asoundrc file must be edited to match a different headset as the MAC will be different.
</p></blockquote>

<p>
To find out more info about this article, please visit <a href="http://potuscamacho-industries.blogspot.com/2010/04/linksys-nslu2-utilizing-bluetooth-audio.html">POTUSCamacho Industries</a> blog.
</p>
<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/archives/2010/04/12/audio_via_bluetooh_desde_el_nslu2/index.html">Audio vía bluetooh desde el NSLU2.</a>
</i></p>
</div>
</content>

</entry>
<entry>
<title type="html">A BASH CGI as a workaround to .htaccess files on lighttpd</title>
<author>
<name>orvtech</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2010/03/26/a_bash_cgi_as_a_workaround_to__htaccess_files_on_lighttpd/index.html"/>

<id>http://linuxevolution.org/archives/2010/03/26/a_bash_cgi_as_a_workaround_to__htaccess_files_on_lighttpd/index.html</id>
<published>2010-03-26T12:49:32-05:00</published>
<updated>2010-03-26T12:49:32-05:00</updated>
<category term="Scripts" />
<category term="NSLU2" />
<category term="Linux" />
<category term="nanoblogger" />
<category term="lighttp" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
As you might remember, in a previous post I explained how to maintain a permanent link which always points 
to the latest submission on your nanoblogger website. Since I decided to migrate from apache to lighttp I 
lost the ability to use .htacees files thus .htacees file based redirects do not work anymore.
</p>
<p>
<br /><b>The workaround.</b><br />

We will keep using the /latest url for the redirects the only thing is that we will use a CGI written in 
BASH to accomplish the redirect. The script will parse our RSS feed (rss.xml) to check which is the latest 
post and redirect to that url. The redirect is accomplished by sending the HTTP headers 'Location' and 
'Status'. Let's take a look at the script:
<br />
<i>latest.cgi</i><br />

<textarea style="height: 80px" class="bashcode">
#!/bin/bash
DocummentRoot="/var/www/linuxevolution.org/htdocs"
Latest=`cat $DocummentRoot/rss.xml | grep link | grep archives | head -n1 | sed -e :a -e 's/<[^>]*>//g;/</N;//ba'`
echo "Status: 302 Moved"
echo -e "Location: $Latest\n"</textarea>
</p>
<p>
Here we are sending the Status header to prevent search engines from associating more than one url to the 
same content (this will give us a lower score in some search engines' systems) and then we send the 
Location header to do the actual redirect.
</p>
<p>
<br /><b>Lighttp and CGIs.</b><br />

In other to execute this CGI we need to make some minor modifications to our VirtualHostost configuration. 
Lets add these two lines to it:
<br />

<textarea style="height: 26px" class="bashcode">
cgi.assign = ( ".cgi" => "/bin/bash" )
url.redirect =( "^/latest/(.*)" => "http://www.linuxevolution.org/latest.cgi")</textarea>


</p>
<p>
In the first line we are telling lighttpd to use /bin/bash to execute any *.cgi file (you can change this 
to anything like *.sh, *.bash). In the second line we redirect all requests to /latest/ to the url 
/latest.cgi. You can either use /latest.cgi or /latest/ for these urls in your signature at the forums; 
personally I like to use /latest/<name of the forum here> to keep track of where is my traffic coming from 
even if I don't get the HTTP referrer.
</p>
<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/howto/un-cgi-en-bash-para-mantener-tu-firma-al-dia-en-todos-los-foros-en-que-participas/" rel="friend" hreflang="es">Un CGI en BASH para mantener tu firma al dia en todos los foros en que participas.</a>
</i></p>
</div>
</content>

</entry>
<entry>
<title type="html">The end of public access to my NSLU2? </title>
<author>
<name>orvtech</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2010/03/14/the_end_of_public_access_to_my_nslu2/index.html"/>

<id>http://linuxevolution.org/archives/2010/03/14/the_end_of_public_access_to_my_nslu2/index.html</id>
<published>2010-03-14T20:01:57-05:00</published>
<updated>2010-03-14T20:01:57-05:00</updated>
<category term="NSLU2" />
<category term="Twitter" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
I just found out that the 'datacenter' where I have my NSLU2 will be shooting down soon. When I say datacenter I mean the house of a friend that have a public IP, this will happen within the next 2 months so I need to start thinking on what to do to keep this site alive and maintained by a NSLU2. 
<br />
<br />
<img src="http://www.linuxevolution.org/images/jailed_nslu2.png" align=left> Right now I thing the best option is just to bring it to my house and use it as a backend or publisher and use the VPS as my frontend. I am still contemplating other ideas but I think the easiest option is to just publish trough my NSLU2 and  rsync the content to my VPS. My home ISP is u-verse and I dont know how friendly are they about hosting services. 
</p>
<p>
If you have any suggestion please dont hesitate to let me know via twitter ( <a href="http://twitter.com/m1n1m3">@m1n1m1</a> ) or just leave  a comment... also if you are hosting any kind of service via u-verse please let me know how has been your experience. 
</p>
<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/nslu2/ha-llegado-el-fin-del-acceso-publico-a-mi-nslu2/" rel="friend" hreflang="es">Ha llegado el fin del acceso publico a mi NSLU2.</a>
</i></p>
</div>
</content>

</entry>
<entry>
<title type="html">The NSLU2 as a last.fm to twitter bridge.</title>
<author>
<name>orvtech</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2009/11/30/the_nslu2_as_a_last_fm_to_twitter_bridge/index.html"/>

<id>http://linuxevolution.org/archives/2009/11/30/the_nslu2_as_a_last_fm_to_twitter_bridge/index.html</id>
<published>2009-11-30T16:57:10-05:00</published>
<updated>2009-11-30T16:57:10-05:00</updated>
<category term="Scripts" />
<category term="Last_FM" />
<category term="NSLU2" />
<category term="Linux" />
<category term="Twitter" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>This simple script came from the need of updating <a href="http://twitter.com/m1n1m3">my twitter</a> 
status with the songs that I am playing, the trick is that it will only update my profile 
if the song has been tagged as 'loved' on last.fm. It will also detect if it is Monday 
and will add the <a href="http://twitter.com/#search?q=%23mm"><i>#mm</i> hash</a>.</p>

<textarea class="bashcode" readonly wrap="off">twitter_user="<your_twitter_user_here>"
twitter_passwd="your_twitter_password_here"
URL="http://twitter.com/statuses/update.xml"
tags="#lastfm"
lastfm_api="<your_api_from_lastfm_here>"
lastfm_user="<your_lastfm_user_here>"
bit_ly_user="<your_bit.ly_user_here>"
bit_ly_apikey="<your_bit.ly_api_key_here>"

fmtwitted=`cat /tmp/lastfm2twitter.tmp | \
sed -e 's/status=Just played: //g' -e 's/#.*//g' | \
grep '[a-z]'|sed -e 's/\ //g' -e 's/\-/./g'`

fmcurrent=`curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&limit=1&user=$lastfm_user&api_key=$lastfm_api" | \
grep -E '<name>|</name>|<artist\ |</artist>' |\
head -n2| sed -e 's/<[^>]*>//g' | tr '\n' '.' |\
sed -e 's/\ //g' -e 's/.$//g'`


lastfm_song_url=`curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&limit=1&user=$lastfm_user&api_key=$lastfm_api" |\
grep -E '<url>|</url>' | sed -e 's/<[^>]*>//g' |\
head -n1| tr '\n' '.' | sed -e 's/\ //g' -e 's/.$//g'`
bit_ly_url=`curl -s "http://api.bit.ly/shorten?version=2.0.1&longUrl=$lastfm_song_url&login=$bit_ly_user&apiKey=$bit_ly_apikey" | \
grep shortUrl | sed -e 's/\"/\ /g' | awk '{print $3}'`

today_mm=`date +%A`
if [[ $today_mm == "Monday"  ]] 
  then tags="$tags #mm"
fi


if grep $fmcurrent /tmp/lastfm_loved.tmp  > /dev/null
  then if [[ "$fmtwitted" == "$fmcurrent" ]]
      then exit 0
        else curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&limit=1&user=$lastfm_user&api_key=$lastfm_api" | \
	grep -E '<name>|</name>|<artist\ |</artist>' |\
	head -n2| sed -e 's/<[^>]*>//g' | tr '\n' '-' | \
	sed -e 's/^[ \t]*//' -e 's/-/\ -\ /g' -e 's/- $//g' -e 's/\ $//g' |\
	awk '{print "status=Just played: "$0}' > /tmp/lastfm2twitter.tmp
	lastfm2twitter=`cat /tmp/lastfm2twitter.tmp; 
	echo $bit_ly_url 
	echo $tags | tr '\n' ' '`
	echo $lastfm2twitter > /tmp/lastfm2twitter.tmp
	curl -s -u $twitter_user:$twitter_passwd -d @/tmp/lastfm2twitter.tmp $URL > /dev/null
	  fi
	  else exit 0
fi</textarea>
<br />
<p>As you can see I am using bit.ly to shorten the urls of the song, you will need a bit.ly API for this to work. 
I think what is left is to optimize the script storing the curl requests in a file sort of like a cache 
and add a routine to detect if it is longer than the 140 charaters allowed by twitte and shorten the text 
to be posted as the status.r</p> 
<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/howto/el-nslu2-como-un-puente-de-last-fm-a-twitter/" rel="friend" hreflang="es">El NSLU2 como un puente de last.fm a twitter.</a>
</i></p>
</div>
</content>

</entry>
<entry>
<title type="html">Monitoring Script for resources </title>
<author>
<name>orvtech</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2009/11/03/monitoring_script_for_resources/index.html"/>

<id>http://linuxevolution.org/archives/2009/11/03/monitoring_script_for_resources/index.html</id>
<published>2009-11-03T11:37:17-05:00</published>
<updated>2009-11-03T11:37:17-05:00</updated>
<category term="Scripts" />
<category term="NSLU2" />
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>This is a small script to display the resources utilization of a NSLU2 running linux on a web page
in plain HTML, It is coded in BASH and some JavaScript in orther to display the information. Here is what the 
output looks like:
<br />
<script src="http://orvtech.com/resources.js" type="text/javascript"></script>
</p>

<br /><p>Source Code of resources.sh:</p>
<textarea class="bashcode" readonly wrap="off">#!/bin/bash

#GETTING THE DAYS OF UPTIME
let UP_TIME=`uptime | awk '{print $3" "$5}' | sed 's/:/ /g' |\
awk '{print "("$1"*24)+"$2}'`

#CALCULATING FREE RAM PERCENTAGE
mem_total=`grep MemTotal /proc/meminfo|awk '{print $2}'`
mem_free=`grep MemFree /proc/meminfo|awk '{print $2}'`
percent=$(echo "scale=2; $mem_free/$mem_total*100" | bc -l)

#GETTING THE AVERAGE LOAD OF THE SERVER 
load_10=`uptime | awk '{print $11}'|sed 's/,//g'`

#BUILDING THE *.js FILE
echo "var resources=\"<b>Last Updated: </b> `date`<br /><b>UP Days: 
</b>$UP_TIME<br /><b>Free RAM:</b> $percent% ($mem_free kB)<br />
<b>Load: </b>$load_10<br />\";"
echo "document.write(resources);"</textarea>

<p>You then direct the output of that script to a file in your RootDirectory, in my case I am using  /resources.js and I execute resources.sh every 5 minutes from a cronjob.</p>
<br /><p>Source Code of resources.js:</p>

<textarea style="height: 55px" class="bashcode" readonly wrap="off">var resources="<b>Last Updated: </b> Tue Nov  3 12:00:02 EST 2009<br />
<b>UP Days: </b>2549<br /><b>Free RAM:</b> 5.00% (1552 kB)<br /><b>Load: 
</b>0.21<br />";
document.write(resources);</textarea>

<p>I use the following code to display the information:</p>
<textarea style="height: 35px" class="bashcode" readonly wrap="off">
<script src="http://orvtech.com/resources.js" type="text/javascript"></script></textarea>
<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/howto/script-para-monitorear-recursos-del-sistema-en-el-nslu2/" rel="friend" hreflang="es">Script para monitorear recursos del sistema en el NSLU2.</a>
</i></p>
</div>
</content>

</entry>
<entry>
<title type="html">Linux on the NSLU2</title>
<author>
<name>iDontknow</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2009/11/01/linux_on_the_nslu2/index.html"/>

<id>http://linuxevolution.org/archives/2009/11/01/linux_on_the_nslu2/index.html</id>
<published>2009-11-01T13:16:16-05:00</published>
<updated>2009-11-01T13:16:16-05:00</updated>
<category term="NSLU2" />
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>The Linksys NSLU2 (aka "slug") is sold as a NAS device but in reality it is much more useful than that. It is a complete, cheap, embedded Linux system. Best of all is the fact that the official Linksys firmware uses the Linux kernel, and so Linksys released the <a href="http://localhost">source code</a>. This led to some excellent custom firmware projects like Unslung and OpenSlug. </p>
<p><i>
<b>Spanish version:</b><a href="http://orvtech.com/general/linux-en-el-nslu2/" hreflang="es" rel="friend">Linux en el NSLU2.</a>
</i></p>
</div>
</content>

</entry>

</feed>

