Friday, August 30, 2013

reviving the old Mac as an internet radio

This is going to be a long post.

It all started with the idea of using the old mac as an internet radio. As its screen had become damaged and showed up scratches, and it was underpowered for most tasks, this seemed a good idea. The final solution was to enable booting to console by installing a base install from mini cd of Ubuntu 12.04 and running a script on login. Network connectivity via the built-in ethernet port. Efforts to use a USB wifi adapter were not successful in the sense that the wifi was not reliable, would come up sometimes and not at other times. This post will chronicle the entire story.

Final working solution:

The internal CD drive was not reading. So the easiest way to upgrade to a new distro, booting from CD, could not be used. An external USB CD drive was also not recognized as a CD to boot from, by pressing C at boot time. The netboot procedure for using a Windows machine as TFTP server was used, with the files needed for the netboot being listed at the bottom of this page. For Ubuntu 12.04 Precise Pangolin, the PPC netboot files are at http://ports.ubuntu.com/dists/precise/main/installer-powerpc/current/images/powerpc/netboot/

For doing the netboot, after setting up tftpd with the required files as above, the Mac needs to be booted into open firmware by pressing Alt+Command+o+f at boot, and the command
  boot enet:0
needs to be entered at the Open Firmware prompt. The Ubuntu netboot installer works, but stops at "getting installer components" with a blank screen, and continues after 15 minutes! The whole base install takes an hour or so, downloading required files online took around 15 minutes with our 2 Mbps shared link.

The machine was made to auto-login to the user shell by editing /etc/init/tty1.conf. An interactive bash shell script was the choice for running the "radio" - a simple bash case statement with a while loop asking for input to change streams. Changing streams by killall mpg123 followed by the relevant mpg123 stream-url. This was made to start on boot by putting it in .bash_profile. Then the system boots up and starts playing in 90 seconds.

To prevent sleep when lid closed, used the tip given at http://mrob.com/pub/ibook.html and put a plastic CD case between the lid and the bottom half.

Ease of shut-down - the Ctrl-Al-Delete method given here was adapted, editing /etc/inittab and changing the shutdown -r to shutdown -h to halt the system instead of reboot on Ctrl-Alt-Del. On the Mac keyboard, the keypress for del needs Fn+Delete, since Backspace is labelled as Delete.

Mis-steps:

In hindsight, the final result above could have been accomplished in around 10 minutes' time. Instead, a week was spent in various explorations. Many things were learnt, which are listed below.

Initially, the idea was to upgrade the running Ubuntu 8.04 LTS to 12.04, so that the newer kernel would have built-in support for the USB wifi device. Upgrade from 8.04 to 10.04 went off OK, via
#apt-get update
#apt-get upgrade
#apt-get dist upgrade
#do-upgrade-release

But 10.04 to 12.04 failed.

At this point, I'd tried to get a console-only install by removing all X related stuff. The tasksel method did not work, nor did apt-get remove ubuntu-desktop. But using wildcards and aptitude, removed ~ngnome , ~nxorg and so on, till finally the system booted to a simple bash shell and no X. Getting a list of all installed packages would sometimes be useful.

Perhaps this was because of not doing the
#apt-get update ? Software sources were manually changed archive.ubuntu.com/ubuntu to ports.ubuntu.com , and then doing the above,  do-release-upgrade worked. But at the end of the install, some errors were reported, and on reboot, the system went into a loop and refused to boot. Single user recovery console was the only working option, and ifupdown etc seemed to be borked. So, a fresh install was attempted.

USB disk install as given at https://help.ubuntu.com/community/Installation/FromUSBStick did not work. But then, it was done using the mini.iso, and that page says mini older than 13 does not boot from USB. Then the netboot option mentioned at the top of this post was tried, and worked.

Several times when the Mac was booted without an ethernet connection, the date and time were off. Apparently these iBooks don't have a BIOS battery, and only use a capacitor and the main battery. The capacitor as well as the main battery seem to be dead in this case. Resetting PMU and PRAM etc did not help.

Possibly due to the power constraints of the USB 1.1 port on this iBook, sometimes booting with the DWA-131 USB wifi adapter would cause repeated errors scrolling by every second, complaining unable to enumerate usb device on port 1 - connecting via a USB hub stopped this issue. After the driver was detected, removing the hub also did not cause this problem to recur.

In this case, lsusb showed the appropriate device name, and checking the driver for it, googled 07d1:3303 D-Link System DWA-131 wireless n nano adapter linux and found the driver was
https://wiki.debian.org/rtl819x
also googled 07d1:3303 D-Link System DWA-131 wireless n nano adapter ubuntu and found via
http://ubuntuforums.org/archive/index.php/t-1392153.html
that the command to be used to connect via wifi is iwconfig and not ifconfig.

Also, found that on listing drivers, lsmod was listing the driver rtl819x as loaded, so probably it should work.

So, did
#apt-get install wireless-tools
and tried to connect, as given at this post - in that page, in the "Make it a script" section, perhaps the first line should be ifconfig wlan0 up

Anyway, tried it, did not work. Finally found via this thread that iwconfig works only for WEP, and that wpa-supplicant has to be used for WPA. Tried the methods given here, did not work, so tried to install ubuntu desktop. This was in Ubuntu 13.10 - but starting X was causing a segmentation fault. Even after googling and trying to remove other errors, and following the steps given here, X still seg-faulted when a window manager was installed.

So, went back to 12.04 to try the procedure given at this post to load X - but before doing the X install, thought of trying to connect with commandline using wicd and found this post. This method succeeded! Except in the last line, it was dhclient wlan0 and not dhcpd wlan0 in my case.
# ifconfig wlan0 up  
# iwconfig wlan0 essid "my_network"  
# wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant.conf  
# dhclient wlan0

Then used this method to make it come up at boot, editing /etc/network/interfaces. But the wifi connection was erratic. Sometimes would not connect at all on boot. Sometimes would connect if the time was set using open firmware with
decimal dev rtc 09 34 13 28 08 2013 set-time
but sometimes not. Would sometimes connect if ethernet cable was connected, sometimes not. Tried going to WEP instead of WPA, and it seemed to work as per the iwconfig method given above, and seemed to connect OK even when the time was off, even when ethernet was off. But a cold reboot the next day showed that the wifi connection was still erratic, and so wired was the way to go.

Testing the networks with wicd, needed to enter wlan0 in Preferences of wicd-curses as per this post.

mpg123 failed to open module  etc errors as non-root user. Installed alsa, rebooted, fixed.
#apt-get install alsa alsa-tools

Then, choosing amixer set Master 45 seems to be a good volume level to set.

After all this, needed to install ntpd, otherwise time is off
https://help.ubuntu.com/10.04/serverguide/NTP.html


Wednesday, August 21, 2013

blogger post editor broken on IE 8

Probably part of Google's "older browsers not supported" campaign. The post editor seems to be working only in html mode and not in compose mode when using IE 8. Tried clearing cache, still no go. So finally it's time to say goodbye, I suppose, and use Opera or Chrome instead, as a secondary browser. Or I can post like this, using email.

Saturday, August 17, 2013

youtube video to mp3

There are quite a few services offering conversion of youtube videos to mp3. vidtomp3.com did a reasonably good job, doing an hour long video in less than 10 minutes. Ad supported, of course. Some other sites have size limits, this one seems to be free of duration restrictions.

Thursday, August 15, 2013

DD links and bug in Description form

While adding links to the Descriptions for Divine Discourses found that the form for adding Descriptions which we use internally has some bugs, with erratic behaviour for filenames which have spaces and or other characters. Have alerted PB on this. Meanwhile, the links were added without quotes, since the form again needs special treatment for quotes, and various bash csv export scripts may misbehave with quotes. I was pleasantly surprised to find that even target=_blank works without quotes.

Thursday, August 01, 2013

mysql db table repair for phplist

As a follow-up to this earlier post on table repair, PB suggested the following:
He found that the following one line command checks, repairs and optimizes all the databases.

 mysqlcheck -u root -p --auto-repair -c -o --all-databases

This could be used  in situations where we are not sure of which tables have crashed or needs repair.....

easily importing Nokia contacts into other apps with vcf support

Guest post from V:

Create a back up of contacts using application on the Nokia phone. By default it will be saved as Backup000.NBF. The extension looks strange, but the file is similar to an archived file like .zip

Open Backup000.NBF using any archive manager and navigate to /predefhiddenfolder/backup/WIP/32/contacts Extract the folder containing all contacts as .vcf files to another location

Open Terminal and navigate to the folder containing the .vcf files. [Alternate method: sudo apt-get install nautilus-open-terminal adds a right-click “Open Terminal” option into the Nautilus File Manager in Ubuntu.]

Once inside the folder on Terminal, use: cat *.vcf > combined.vcf to combine all .vcf files into a single file.

This file can now be easily imported into Google Contacts or any other application that accepts .vcf files

Edit: There is one more elaborate method of VCF multiple contact import given at http://www.allaboutsymbian.com/forum/showthread.php?p=488142