The Slug

IndexReturn to index

Introduction to the Slug (NSLU2).

Tux smoking joint The Slug is a pet name for a nice piece of embedded hardware called NSLU2 and is made by Linksys. The Slug runs on Linux and most Linux programs can be compiled to run on the Slug. The Slug is inexpensive (less then 100 US dollars) and does not consume a lot of power. Which makes it perfect to run as a personel webserver.

Before you can start running your own Linux programs on the Slug you have to Unslung it first. If you are Dutch you should check out HCC Unix Unslung Demo


To get you started using Linux fast here are some useful Linux commands

/share/hdd/data/
Is the path to your USB harddrive.
mkdir 'dir'
Makes directory 'dir'
cd 'dir'
Change directory
cd ..
Go back one directory
rm -R 'dir'
Remove directory and files
cp 'file' 'file'
Copy file or directory to file or directory
mv 'dir' 'dir'
Move file or directory etc.
vi 'filename'
VI is one of the linux editors. Not very userfriendly but is build in.
pwd
Shows current path.
chown 'filename'
Change the owner of the file.
chgrp 'filename'
Change the group that can access this file.
chmod 775 'filename'
Change the read and write access for this file.
chmod ugoa=rwx 'filename'
Change mode file for User, Group, Owners, All to Read, Write or Execute.
ls -l
Displays the content of the current directory in long form.
alias ls='ls -l'
Gives your favourite command a shorter name.
export
Shows enviroment including path.
Ok, this should get you started. I will be adding more later.

Tux size matters

Count 2.5

How to use Count 2.5 on your slug

Would you like to have a visitors counter on your website like mine? Here is what you have to do

Tux reading paperLog into your slug and go to your home directory.(The directory were you store your files)
Download the program with:

Untar and unzip the file with: Before you can continue compiling the counter program you need the GCC compiler and the C-libraries installed. This is done by (total 130 mb, so be patient): Next we can start configuring the counter: Fill in the path to your cgi-bin directory i.e.: Fill in the path where you want the counter to reside in i.e.: Answer the rest of the directory and file questions with the Enter key. And answer Yes to "Everything looks OK [y/n]?" Now we can compile the program with: Next we will make the config file: Enter your full domain name i.e.: Enter your ip address i.e.: Next we can install the program

Finally add some HTML code to your page, look at the examples.

I hope this information was helpful, if you still have a question involving getting the counter to work on the slug send me an email

Adding webalizer 2.01

How to add web statistics Webalizer 2.01 to your website

Webalizer 2.01 is a nice visual program that keeps track of your web statistics. I wrote this article to show how you can compile the Webalizer program on the NSLU2. The program is not so easy to compile, because webalizer seems to have troubles finding the right libraries. The other problem is that the standard DBase library on the slug is not V1.85 compatible. So that we have to compile BerkeyDB too, which will be explained later.

Webalizer uses the log files of your http daemon, this can be both Apache or Httpd and probably others. If you are using Apache then you can just use "ipkg install webalizer" to install the program on your NLSU2. If you want to use al the features of webalizer in combination with Thttpd then you need to compile webalizer with DNS support. This is because Thttpd does not have build in reverse DNS lookup. Also if you want to modify the source to your own wishes you need to compile the program.

If you do not want to compiler webalizer yourself, you can also download the program from my download directory

Setting up development enviroment

First we need the developement enviroment again, if you have not installed it yet then now it is the time:

Be patient this will install at least 130 mb in programs and this will take a while.

Make sure that libgd is installed. If not install with:

Next we have to install the BerkeleyDB, Webalizer uses this program to look up where you visitors are coming from. This step can be skipped is you do not want to keep track of where you visitors are visiting from. Compiling the BerkeleyDB will take at least 45 minutes. Go to your home directory and download the BerkeleyDB:

Unzip the file and change the directory with:

Now we need to run the configure program with the following parameters:

Build the library and be very patient with:

Now we can download the Webalizer program:

The program has trouble finding the libraries, so run configure with the following options

Before we can run make, we have to modify the Makefile else the linker has problems to finding the libraries.

These lines should be modified and look like this:

Next we compile and install the program:

Your program is now ready for use.

Next time i will explain how to set up webalizer, but there is enough information on the web, compiling the program is the hard part.

Geolizer patch for Webalizer

How to get the geolizer patch working on the Slug

Still working on this one. Work is in progress but I still have some problems to solve.

download GeoIP.dat from http://www.maxmind.com/app/ip-location

download GeoIP clib from same site http://geolite.maxmind.com/download/geoip/api/c/

More soon


CGI

Creating your own Common Gateway Interface

Common Gateway Interface is a way of creating dynamic html. Depending on the information available it will create and output an modified html to the browser. CGI can also output other formats like images, my visitors counter works with CGI

Ok, so how does CGI work. When you type in an URL in your browser, your browser will try to download the file from the server and display it on your computer. Some times the requested URL is not a file but a program, this is the case with CGI, but also with PHP and some other formats. When the requested file is a program, the complete URL that your browser is requestion for is send to the program, the program then assembles a file which get returned to the browser and is displayed, which gives you the freedom to create whatever you want to other to see on his/her browser

Before we begin you have to create a directory cgi-bin in your web root, for example /www/cgi-bin. Next you have to tell your server that you want to use CGI programs. In the case of Thttpd, the server I am using for the NLSU2, edit etc/thttpd.conf (etc/thttpd.conf is the standard configuration file, you might have created a different one if you have more then one thttpd program running, for example I am using /etc/thttpd-website.conf) and change the line cgipat to cgipat=/cgi-bin/* (if you are using virtual hosts like me use cgipat=/*/cgi-bin/* instead)

Now we are ready to create our first CGI program. Make sure you have the development setup again (see the other 2 articles). Make a directory called c in your home directory. And start editing a file called gateway.c (with vi or any other editor you want to use)

#include <stdio.h>
#include <time.h>

int main (int argc, char *argv[])
{
printf("Content-type: text/html\n\n");
printf("Hello everyone!<br><br>\n");
time_t rawtime;
time (&rawtime);
printf ( "Current date and time here are: %s", asctime(localtime(&rawtime)));
return 0;
}

Compile the file with:

gcc gateway.c -o gateway.cgi

Copy the file gateway.cgi to your cgi-bin directory. Make the file world readable with chmod 755 gateway.cgi. And run the file from your browser with <your-domain>/cgi-bin/gateway.cgi

If it doens't work on yours, here is how it should look

Compiling C++

Compiling C++ on the NLSU2

While compiling C is not problem for the gcc compiler, if you try to compile a C++ program it will give you a million of errors. This is because gcc cannot find the right libraries. Try compiling your C++ program with gcc filename.cpp -lstdc++ -Xlinker -rpath -Xlinker /opt/lib -o filename And run the program with ./filename

IndexReturn to index


80x51
80x51
[ Join Now | Ring Hub | Random | << Prev | Next >> ]
Embedded Technology
Embedded Technology
[ Join Now | Ring Hub | Random | << Prev | Next >> ]

This site is brought to you by the "slug".