Tuesday, February 28, 2006

Scripting Addiction

Since I can do some bash scripting, I fell like I can't stop.
I even try to automate anything I usually do by scripting it.
Hmm... should I dive into python and made my own NMS?
I'm quite dissappointed with JFFNMS performance, btw.
Probably, I should take a look at ifstat source code and learn from it, and then make my own lightweight network monitoring system....
Hmm... scripting is really really really addictive....

Friday, February 17, 2006

A week with Fedora Core 4

FYI, my laptop is now running Debian Sarge. It's just plain stable, albeit old system :-)
My PC, however, is running Kubuntu Dapper Drake, and with spare hdc (after cleaning up the pre-existing Ubuntu Breezy Badger) I decided to try another distro that is not debian-based.

Going into RPM world, Fedora is my first choice.

My first experience with GNU/Linux is with Red Hat 5 several years ago. Being a newbie, that was an unpleasant experience. I knew nothing about UNIX-like environment, getting annoyed with RH5 hardware detection, especially in Multimedia & Printing support, I finally mess with X and cannot log into GDM until one day my cousin did some fiddling with configuration files and fixed my X issue.
With those unpleasant memory, I begin installing FC-4.

Installation is graphical and intuitive. During the installation, I chose to manually partition my hard disk and customizing packages selection. I didn't found synaptic nor adept there, but hey, this was the time to use yum, right?

The installation ended with grub installation. Here, I made a mistake. I overwrote my Ubuntu's grub in MBR with Fedora's one. As Fedora did not recognize my Ubuntu installation, after reboot, I presented with no option to log into Ubuntu unless I manually edited the Grub.

The bootsplash is nice although not as informative as (K)Ubuntu's, and after passing my username & password into GDM, I was presented with GNOME 2.10. I had to say I much prefer the brown one than that bluecurve+clearlooks combo though :-)

After playing around for a while (and tasting Fedora's KDE 3.4) I started using yum.
I was thinking yum update is the equivalent of apt-get update when I noticed that it actually updated the system. I found that command is similar with apt-get update followed with apt-get upgrade.

As with apt, a proxy-server in the middle of the way messed up with yum. In the case of my Debian-based system, I changed the sources.list to make apt use ftp instead of http connection. In yum, I found it a bit tricky as it use mirrorlist. By default Fedora's yum using a mirror list to reach its mirror, defined in /etc/yum.repos.d/fedora*.repo (This is a good method, I wonder if Debianistas would adopt this). Since I couldn't find a way to tell yum to use ftp instead http, I created a directory named yum.custom.repo, copied the original .repo files there, made a script to grab those mirrorlist, and created the list locally.

#!/bin/sh
cat fedora.repo|grep mirrorlist|sed -e 's/mirrorlist=//' -e 's/$releasever/4/'|wget -i - -O -|grep ftp|sed 's/http:/ftp:/' >fedora.mirrorlist
cat fedora-extras.repo|grep mirrorlist|sed -e 's/mirrorlist=//' -e 's/$releasever/4/'|wget -i - -O -|grep ftp|sed 's/http:/ftp:/' >fedora-extras.mirrorlist
cat fedora-updates.repo|grep mirrorlist|sed -e 's/mirrorlist=//' -e 's/$releasever/4/'|wget -i - -O -|grep ftp|sed 's/http:/ftp:/' >fedora-updates.mirrorlist
cat fedora-updates-testing.repo|grep mirrorlist|sed -e 's/mirrorlist=//' -e 's/$releasever/4/'|wget -i - -O -|grep ftp|sed 's/http:/ftp:/' >fedora-updates-testing.mirrorlist
cat fedora-devel.repo|grep mirrorlist|sed -e 's/mirrorlist=//' -e 's/$releasever/4/'|wget -i - -O -|grep ftp|sed 's/http:/ftp:/' >fedora-devel.mirrorlist
cat fedora-extras-devel.repo|grep mirrorlist|sed -e 's/mirrorlist=//' -e 's/$releasever/4/'|wget -i - -O -|grep ftp|sed 's/http:/ftp:/' >fedora-extras-devel.mirrorlist



Then I just edited the mirrorlist option in .repo files at /etc/yum.repos.d to point into those mirror list, e.g:

[base]
name=Fedora Core $releasever - $basearch - Base
#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/$releasever/$basearch/os/
mirrorlist=file:///etc/yum.custom.repo/fedora.mirrorlist
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora


After yum update completed, I was left with a very up-to-date Fedora system, with surprisingly: a well-working KDE 3.5.

So far, I enjoyed my Fedora experience, and kept it in my system.

I still have space in my hard disk.
So... what will it be : Open SUSE, Mandriva, Gentoo or Slackware?

Tuesday, February 14, 2006

Merge PDF files with pdftk

Having some of my manuals/documentations downloaded in several separated pdf files, I wanted to merge them into a single file.

First, I installed pdftk

# apt-get install pdftk

Then, I merged the files into a single file

$ pdftk file1.pdf file2.pdf file3.pdf cat output file123.pdf

When the files to be merged is a lot, I edited the file list in a text editor (or, when I am in a good mood, using ls & awk & sed) then combine it with the script found here

$ cat stdin_pdf.sh
#!/bin/sh
# combine PDFs; pass filenames in on stdin;
# pass output to stdout
read input_filenames
pdftk $input_filenames cat output -

$ cat filelist|./stdin_pdf.sh>mergedfile.pdf


So far, I am satisfied with the result.
However, I am still looking for the method to modify the hyperlink to suit the new file, since the previously scattered files actually hyperlinked to each other. RTFM is in progress :-)

Thursday, February 09, 2006

Size of Ubuntu Repository

When I tried to create local repository of Ubuntu, I was haunted by an unanswered question: How big will it be?
Googling and diving into ubuntuforums.org gave me no solution.
Then, a friend in Ubuntu-id mailing list gave me the answer: calculate the size from every packages listed in Package.gz.

This is a sample (ugly) script I used to get main repository size calculated.

$ wget http://id.archive.ubuntu.com/ubuntu/dists/breezy/main/binary-i386/Packages.gz -O - |zcat|sed 's/Installed-Size://'|grep Size|awk '/Size:/ {pkgsize+=$2} END {print "package size = "pkgsize" Bytes"}'

The size of other repositories can be calculated by simply changing the path of Packages.gz

Tuesday, February 07, 2006

Building Ubuntu Local Repository (CD)

I've just read from this site about creating Ubuntu DVD Repositories. I thought I need to create such local repo, but in CDs, as I don't have DVD burner.

First, I created local copy from main repository using debmirror.
In this case, I am using mirror from CBN.

$ debmirror --nosource -m --passive --host=ubuntu.cbn.net.id --root=Ubuntu/ --method=http--progress --dist=breezy --section=main --arch=i386 ubuntu/ --ignore-release-gpg


Creating destination folders for partitioning

$ mkdir ubuntu-cd


Then I partitioned those files using debpartial

$ debpartial --nosource --dirprefix=ubuntu --section=main --dist=breezy --size=CD74 ubuntu/ ubuntu-cd/


After the packages lists had been generated, I created the symlink to the corresponding packages using debcopy script. It can be downloaded from here.

$ ruby debcopy -l ubuntu/ ubuntu-cd/ubuntu0
$ ruby debcopy -l ubuntu/ ubuntu-cd/ubuntu1
$ ruby debcopy -l ubuntu/ ubuntu-cd/ubuntu2
$ ruby debcopy -l ubuntu/ ubuntu-cd/ubuntu3
$ ruby debcopy -l ubuntu/ ubuntu-cd/ubuntu4


The partitioned folders then converted into iso image files, and burnt.

$ mkisofs -f -J -r -o ubuntu-cd-main-0.iso ubuntu-cd/ubuntu0
$ mkisofs -f -J -r -o ubuntu-cd-main-1.iso ubuntu-cd/ubuntu1
$ mkisofs -f -J -r -o ubuntu-cd-main-2.iso ubuntu-cd/ubuntu2
$ mkisofs -f -J -r -o ubuntu-cd-main-3.iso ubuntu-cd/ubuntu3
$ mkisofs -f -J -r -o ubuntu-cd-main-4.iso ubuntu-cd/ubuntu4

$ sudo cdrecord -v dev=/dev/cdrw speed=32 driveropts=burnfree -dao -eject ubuntu-cd-main-0.iso
$ sudo cdrecord -v dev=/dev/cdrw speed=32 driveropts=burnfree -dao -eject ubuntu-cd-main-1.iso
$ sudo cdrecord -v dev=/dev/cdrw speed=32 driveropts=burnfree -dao -eject ubuntu-cd-main-2.iso
$ sudo cdrecord -v dev=/dev/cdrw speed=32 driveropts=burnfree -dao -eject ubuntu-cd-main-3.iso
$ sudo cdrecord -v dev=/dev/cdrw speed=32 driveropts=burnfree -dao -eject ubuntu-cd-main-4.iso

The method to create repo-cd for universe & multiverse repository is similar.
I Just changed the apropriate parameter in debmirror & debpartial.
Now I have access to ubuntu repository even when I am not connected to the net. Right now, I am currently trying to create repo from breezy-updates & security. Hopefully, I will have it mirrored before it changes (again) :-)