
My SLUG is dead……. kind of half powers up before dying. I’m going to give CPR later with a hard reset just to see if I can shock it back to this world, but I fear it has gone forever

My SLUG is dead……. kind of half powers up before dying. I’m going to give CPR later with a hard reset just to see if I can shock it back to this world, but I fear it has gone forever
I’ve finally got my NSLU2 back up and running properly again!
I’ve ultimately reverted back to unslung after a dabble with Debian and OpenSlug but whilst these were much better and much more complete of an OS than uNSLUng, unlsung is much easier to use and repair when anything goes wrong!
Expect more NSLU2 posts as I start to do things again with it!
Following the second failure of my slug debian installation, I couldn’t bear to go through the lengthy 10 or so hour setup process, so I’ve decided to give SlugOS a try and see how I get on with this one. It’s taken around an hour to flash/format/setup the disk, and install the core packages.
I’ve now got opkg and ipkg working….
Off to play now
As promised, what follows are my installation notes for debian on the NSLU2.
These are pretty much just a dump of everything I did to get things working. Hopefully these may be of use to someone as a good reference guide!
Apologies that this isn’t structure too well, I just wanted to get it all down for posterity
Having said that…. here comes the mega post – try not to fall asleep
——————————
This is enough to install Debian, so then it’s onto all the optional and more useful parts!
——————————
sudo
su apt-get install sudo vi /etc/sudoers
Add to file below root entry:
user ALL=(ALL) ALL
Save and Close.
exit from root user
——————————
Time Server
sudo apt-get install ntp
——————————
Additional Users
Create group
groupadd groupname
Add user
adduser username
Add user to group
usermod -g groupname useruser
——————————
VIM
Colour code
apt-get install vim cp /usr/share/vim/vimrc ~user/.vimrc vi ~user/.vimrc
Remove “ from
"syntax on
Test working by
vi /etc/init.d/zleds
——————————
Remove non required packages
Install RCC Conf
apt-get install rcconf
Remove Netatalk & NFS
rcconf
Uncheck netatalk and 2 nfs services
——————————
Change SSH boot priority
Move SSH starter from rc2.d(?) to rcS.d just after networking
——————————
Change power button shutdown
Replace the line the /etc/inittab
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
with
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -h now
run
telinit q
to reload the file
——————————
Melody Beep on startup/shutdown
apt-get install beep
vi /etc/init.d/beep
Enter/paste following in vi editor
#! /bin/sh ### BEGIN INIT INFO # Provides: beep # Required-Start: # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: S 0 1 6 # Short-Description: Beeps that indicate startup and shutdown ### END INIT INFO
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
NAME=beep
BEEP=/usr/bin/$NAME
MELODY_START="-f 65.4064 -l 100 -n -f 130.813 -l 100 -n -f 261.626 -l 100 -n -f 523.251 ←
-l 100 -n -f 1046.50 -l 100 -n -f 2093.00 -l 100 -n -f 4186.01 -l 100"
MELODY_STOP="-f 523.251 -l 100 -D 100 -n -f 391.995 -l 100 -D 100 -n -f 329.628 ←
-l 100 -D 100 -n -f 261.626 -l 200"
SCRIPTNAME=/etc/init.d/$NAME
ARGS="-e /dev/input/event0"
# Exit if the package is not installed
[ -x "$BEEP" ] || exit 0
case "$1" in
start)
$BEEP $ARGS $MELODY_START
;;
stop)
$BEEP $ARGS $MELODY_STOP
;;
restart|force-reload)
# Do nothing
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
Save and close file
chmod 755 beep
cd /etc/rcS.d
ln -s /etc/init.d/beep S99beep
cd /etc/rc0.d
ln -s /etc/init.d/beep S89beep
——————————
Htop
apt-get install htop
——————————
Disable getty (unless you have a serial port)
In /etc/inittab
Comment out:
T0:23:respawn:/sbin/getty -L ttyS0 115200 linux
Then run
telinit q
——————————
Disable IP6
if not using IPv6, you can prevent the module from being automatically loaded by adding the line
blacklist ipv6
to
/etc/modprobe.d/blacklist.
——————————
Native Development
apt-get install build-essential
——————————
Drive sleep/spindown
apt-get install sg3-utils
mkdir ~user/tmp cd ~user/tmp wget http://spindown.googlecode.com/files/spindown-0.2.2.tar.gz tar xvzf spindown-0.2.2.tar.gz cd spindown-0.2.2 make make install
Find ID of disk
ls -l /dev/disk/by-id/
Note ID of disk
lrwxrwxrwx 1 root root 9 May 5 21:07 usb-Seagate_External_Drive_SW063423123-0:0 -> ../../sda
lrwxrwxrwx 1 root root 10 May 5 21:07 usb-Seagate_External_Drive_SW063423123-0:0-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 May 5 21:07 usb-Seagate_External_Drive_SW063423123-0:0-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 May 5 21:07 usb-Seagate_External_Drive_SW063423123-0:0-part3 -> ../../sda3
lrwxrwxrwx 1 root root 10 May 5 21:07 usb-Seagate_External_Drive_SW063423123-0:0-part5 -> ../../sda5
e.g. id is = usb-Seagate_External_Drive_SW063423123-0:0
Add noted disk id into the config file
nano /etc/spindown.conf
[General] # Number of seconds between cycles.
cycle-time = 60
# The time in seconds a disk has to be idle before it is spundown. # Do not use a value that is to small (less than 3600) unless you # know what you are doing. idle-time = 3600
# Turn this on if you want spindown to log messages using syslog. # You will not want to turn this on if you are trying to spindown # the disk with the root filesystem on. syslog = 0
[Disk 0] id = usb-Seagate_External_Drive_SW063423123-0:0 spindown = 1 command = sg_start --stop
——————————
Disable Cron Hourly Parts (Prevent disk writes!)
Edit /etc/crontab
Comment out the hourly run-parts
——————————
Samba
sudo vi /usr/share/samba/smb.conf
edit following:
[global] workgroup = NETWORK
[homes] Read only = no
Save and close
sudo smbpasswd -a user
sudo /etc/init.d/samba restart
Open browser on PC and connect to:
http://<ip address>:901/
——————————
SSH
Install telnet as temporary Backup just in case SSH goes awry!
sudo apt-get install telnetd
Create SSH Banner (optional)
sudo vi /etc/ssh/ssh_banner sudo vi /etc/sshd/sshd_config
Add
Banner /etc/ssh/ssh_banner
Restart SSH
/etc/init.d/sshd restart
Add in SSH Certificates
mkdir ~user/.ssh
add authorized_keys file
vi /etc/ssh/sshd_config
uncomment and change to no…
PasswordAuthentication no
Restart SSH
/etc/init.d/sshd restart
Test, then remove telnet if succesful!
sudo apt-get remove telnetd
——————————
TownkyMedia
Twonky requires old LIBC version – easiest way to get this running is to install an etch environment, as follows.
apt-get install unzip
sudo apt-get install debootstrap
sudo debootstrap --arch=arm etch /etch-root http://ftp.de.debian.org/debian/
sudo debootstrap –arch=arm etch /etch-root http://archive.debian.org/debian/
mkdir /etch-root/usr/local/twonkymedia cd /etch-root/usr/local/twonkymedia unzip /root/twonkymedia-armel-glibc-2.2.5-4.4.11-20090108.zip chmod 700 twonky* cgi-bin/* plugins/* cd /root
vi /etc/init.d/twonkyStartEtch
#!/bin/sh set -e action="$1" case "$action" in *start) mount | grep -q " on /etch-root/proc " || mount --bind /proc /etch-root/proc # mount | grep -q " on /etch-root/home " || mount --bind /home /etch-root/home ;; esac chroot /etch-root /usr/local/twonkymedia/twonkymedia.sh $action || true case "$action" in stop) mount | grep -q " on /etch-root/proc " && umount /etch-root/proc # mount | grep -q " on /etch-root/home " && umount /etch-root/home ;;
Esac
Save and Close
chmod +x twonkyStartEtch
cd /etc/rcS.d/
ln -s /etc/init.d/twonkyStartEtch S97twonky
cd /etc/rc0.d/
ln -s /etc/init.d/twonkyStartEtch S19twonky
cd /etc/rc6.d/
ln -s /etc/init.d/twonkyStartEtch S19twonky
——————————
Webserver
Apache 2 already installed – use aptitude to remove all apache packages
apt-get install lighttpd sudo apt-get install php5 php5-cli php5-common php5-cgi
modify
/etc/lighttpd/lighttpd.conf
add:
server.modules = (
"mod_fastcgi",
)
and
fastcgi.server = ( ".php" => (( "bin-path" => "/usr/bin/php5-cgi", "socket" => "/tmp/php.socket", )))
modify
/etc/php5/cgi/php.ini
Change
# cgi.fix_pathinfo = 0
to
cgi.fix_pathinfo = 1
Restart lighttpd
/etc/init.d/lighttpd restart
Check PHP is working by creating a php info page in /var/www with content like:
<?php phpinfo(); ?>
Install SQL Lite database
sudo apt-get install sqlite
sudo apt-get install php5-sqlite
——————————
Deny Hosts
sudo apt-get install denyhosts
Add in local network so you don’t get locked out!
vi /var/lib/denyhosts/allowed-hosts # Allowed hosts # #local network # 192.168.1.[1-199]
——————————
NTFS Drive Access
http://technowizah.com/2006/11/debian-how-to-writing-to-ntfs.html
sudo apt-get install ntfs-3g
test mount
sudo mount -t ntfs-3g /dev/sda1 /mnt/windows -o umask=0,nls=utf8
if successful edit etc/fstab
/dev/sda1 /mnt/windows ntfs-3g umask=0,nls=utf8 0 0
So for the second time, something has happened to my NSLU2s primary disk – it scans ok, and there doesn’t appear to be any errors, though debian is refusing to boot right now and it’s a real pain to try and work out what is going on when there is no console and I’m getting next to nothing in the logs!
I’ve decided I’m going back to uNSLUng as it did everything I need, and caused me less pain….. that’s my task for this weekend!
I’ve got a document which describes everything I did to get debian up and running. I’ll edit and post this later in the week so it’s available to all who want to try debian on the NSLU2.
The installer completed successfully after around 5 hours.
I’m now going through the painful process of getting everything back up and running, but I’m making notes as I go and I’ll post these here when I get the chance. There’s loads of good debian NSLU2 information out there – some has been invaluable!
My main 500GB hard drive that was plugged into the slug decided to stop working last week causing my slug to freeze and crash on every reboot.
I’ve purchased a new hard disk and have begun installing Debian onto the NSLU2 – I’ll keep you posted

I’m toying with the idea of installing dnsmasq on my NSLU2… I don’t want the DHCP part as I’d rather leave my router doing that but I like the idea of having the DNS stuff running now there are a few machines on my LAN.
It’s a pain managing multiple host files..
If I take the plunge – I’ll report back
I was hunting around the internet for a way to get my slug to text me via SMS when things happen and stumbled across the orange developer APIs and was pleasantly surprised! I was hoping for a simple gateway to send SMS messages from so that I could get a text alerts if/when things go wrong and I found a whole lot more
“The orange SMS API allows you to send and receive text messages within your web application.” is the description from the orange website
The API not only allows you to send texts, but also to receive them. This sounds a little wierd but it’s really simply, so I’ll explain with the example I built!
First you need to be an orange customer and you have to register for the developer website. Once you’ve done that, you need to get your access code – a unique number much like the google api codes. Once you’ve got it, the next thing to do is add a prefix. This is what your message should start with. The prefix you choose might have gone, so you may have to try a few.
To send a text, basically, you issue a call to the following, passing your access key, the destination mobile, the text, and which number its coming from.
http://sms.alpha.orange-api.net/sms/sendSMS.xml?id=[access key]&to=>[mobile number]&content=[your text message]&from=[mobile number]To receive a text, when you register your prefix, you get the option to select either an email address or a URL. If you pick an email address, then that email address will receive a copy of the text. If it’s a URL, then the message will be delivered to the specified URL with information added as URL parameters. The parameters are:
| Name | Description |
| api | This is the name of the API function – receivesms. |
| content | This is the content of the text message, limited to 160 characters. |
| from | This is the origin of the text message in international format. This is either a phone number or an alias. |
| to | This is the destination number of the SMS |
So an example URL would be something like:
http://www.mydomain.com/mypage.php?api=receivesms&content=hi+how+are+you&from=33123456789&to=20345This is all documented in great depth on the orange developer website so I won’t go into this too much.
The next step was making this work on my NSLU2
I have the lighttp webserver with FCGI installed via IPKG running on my NSLU. This runs on port 8081 by default. In my router, I’ve port forwarded port 80 to 8081 on my NSLU2 to open lighttp up to the internet.
The next thing to do was to create a PHP page to recieve a text and do something with it. My first idea to test this was to use a shell script I have on the NSLU2. This shell script simply scans the var/log/messages file to find when the last successful login was today and how many unsuccessful logins there have been today.
The shell script looks like this:
lastLogin=`cat /var/log/messages | grep "sshd" | grep "Accepted publickey for" | tail -2 | head -1`<br />
numberInvalids=`cat /var/log/messages | grep "sshd" | grep "Invalid user" | wc -l`dateStr=${lastLogin:0:16}echo 'Last successful login occurred on:' $dateStr' - Number of invalid user attempts: '$numberInvalids''So my aim – to send a text to the NSLU2, and get back this message from my shell script. I created a PHP file like the following:
$content = $_GET['content'];$from = $_GET['from'];$fid = fopen('~xxxxxxxxxxxxxxxxxxxx/SMSdatabase.txt','a');fwrite($fid,"$from $contentn");fclose($fid);$toexec="~xxxxxxxxxxxxxxxxxxxx/commands/lastloginsms.sh" . $program;$exec=exec($toexec);
$returnmessage = $exec;
$phone_number = urlencode($from);
$text_message = urlencode($returnmessage);
$url = "http://sms.alpha.orange-api.net/sms/sendSMS.xml?id=XXXXXXXXXXX&to=$phone_number&content=$text_message";
$response = file_get_contents($url);
$xml = simplexml_load_string($response);
echo "Status: ",$xml->status->status_msg;
This does a few things – firstly it gets the URL parameters, then writes out the message to a text file so I can keep a track of what messages were received.
Next, it calls the shell script lasloginsms.sh.
Finally, it takes the output of the shell script, and sends that as an SMS back to the sender!
So, to make it all work now, I simply text (from my orange phone)
prefix test
to: 967482
And a few seconds later I get a text back with a response similar to:
Last successful login occurred on: Sep 5 09:46:01 - Number of invalid user attempts: 7
Pretty cool.
You can have 5 prefixs on the devloper website, so the next step is to create a few different PHP scripts that work with the prefixs to stop/start services on the NSLU2 via SMS and provide status reports. A good example of use would be, should I ever lock myself out of the SSH server (by denyhosts), then I could SMS my slug to enable telnet, log in, and remove the entry from the hosts.deny file!
I’ll post when I get this working!
Being a java developer I was intrigued with the idea of getting a JVM running on my NSLU2, so I looked into how to do this.
Surprisingly it was pretty easy.
To start with you need to install the following packages with ipkg:
ipkg install classpath ipkg install jamvm ipkg install jikes ipkg install zlib ipkg install file
Once these have installed then you are almost ready to go. Being a java developer, I was used to using javac and java to compile and execute programs, so jikes and jamvm didn’t sit well with me! To get around this I created a symbolic link and a shell script in /opt/bin
These are as follows:
/opt/bin/java
ln -s /opt/bin/jamvm /opt/bin/java
/opt/bin/javac
/opt/bin/jikes -classpath /opt/share/jamvm/classes.zip:/opt/share/classpath/glibj.zip $*
Remember to change the permissions on the shells scripts to add the execute flag!
Having done all that, I can now create a java file:
HelloWorld.java
class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Pembo's Hello World!");
System.out.println("Args Length: " + args.length);
for(int i=0;i
compile this using the command
javac HelloWorld.java
and then run this using the command
java HelloWord test1 test2 test3
And I see the following output:
Pembo's Hello World!
Args Length: 4
[0] - test1
[1] - test2
[2] - test3
JamVM is excellent from what I've seen so far and is perfect for Java NSLU2 development.
I've yet to run anything overly complex on the Slug so I can't comment on the memory utilisation.
It takes around a second to compile the above HelloWorld program on the NSLU2 and under a second to run it.