Byzanz and PDFEdit on Ubuntu 8.04.1

Byzanz can record your desktop session to a GIF image file. It is ideal for creating a Linux visual tutorial on Gnome Window Manager. The GIF image can be viewed on the Firefox.

To use it, right click on the top bar and select “Add to the panel” and choose “Desktop Recorder”. It can record the desktop, area or windows. It also can capture the mouse cursor too.

To install it on Ubuntu 8.04.1 :
sudo apt-get update
sudo apt-get install byzanz

PDFEdit can edit a PDF file and it can also combine 2 or more PDF files together with a simple click. You can install it on Ubuntu 8.04.1 with a single command.
sudo apt-get install pdfedit

Make your tutorials with the powerful tools!

HOWTO : Home made wired and wireless router with ZeroShell

My wired and wireless routers are connected together and served me for years. However, they produced a lot of heat on the devices and the electricity adapters. It is not ideal for running 24/7/365 at no air-conditioning environment with my new built home NAS server.

I searched the internet for days and later find ZeroShell. ZeroShell is very powerful and easy to install. It only supports Atheros chipset wireless PCI card. So, I can build a all-in-one (wired and wireless) router in one machine.

The minimum requirement of ZeroShell is Pentium 233MHz CPU, 96MB RAM and a ATA CD-ROM or Compact Flash card. The current version is 1.0 beta 10 at this writing. It is a Linux based router system. I am now going to build a simple and just work powerful home wired and wireless router. Enterprise features are not needed in this HOWTO.

Hardware

Motherboard – VIA PC-1 PC2500E with VIA C7-D 1.5GHz CPU
RAM – 2 X 1GB DDR2 667MHz (maximum)
Hard drive – SATA SSD Enclosure with 8GB Compact Flash card (Transcend)
Wireless PCI card – TP-Link TL-WN551G (detachable antenna) 54M IEEE 802.11b/g
PCI Ethernet card – Planet Gigabit Ethernet PCI card
Switch – 100M or Gigabit switch (optional)

The on board 100M ethernet card is for connecting to internet (the interface name at ZeroShell is ETH01), the PCI ethernet card is for connecting to wired intranet (the interface name at ZeroShell is ETH00) and the TP-Link wireless card is connected to wireless computers (the interface name at ZeroShell is ETH02).

Install ZeroShell on hard drive

Download ZeroShell-1.0.beta10-CompactFlash-IDE-USB-SATA=1GB.img.gz and copy it to a USB stick. Download the CD iso (ZeroShell-1.0.beta10.iso and burn to CD-R. Follow the instruction at this PDF at http://digilander.libero.it/smasherdevourer/schede/linux/Zeroshell%20su%20HD-EN.pdf

Configure the Wired ZeroShell

Set your IP address at your Ubuntu Desktop as static IP (192.168.0.2), netmask is 255.255.255.0 and the gateway is 192.168.0.75. Connect to the Zeroshell with browser. The default username is admin and the password is zeroshell. You can change the password later during the configuration.

Follow the instruction at this http://digilander.libero.it/smasherdevourer/schede/linux/zeroshellEN.pdf up to “Surfing Internet”. The default gateway at “Storing our configuration” is 192.168.0.75.

Use the default profile and change the administrator password. If the default gateway is not set for you at “Router” — “Network”, you just key in “192.168.0.75”. Make sure to set IP range at the DHCP server for the ETH00, such as 192.168.0.1 to 192.168.0.70 or something like this.

After that, reconfigure your Ubuntu Desktop IP to roaming. Now, you can surf the internet via the wired intranet.

Configure the Wireless ZeroShell

Since this beta 10 version does not support web based setup via browser, you should go to the console or use ssh to set the wireless interface.

At the console, press “w”- Wifi Manager. Then press “n” to set the SSID. Press “c” to set the channel and WPA-PSK. Finally, press “r” to restart the device.

Make sure to add IP range at DHCP server. The ETH01 should be set to Dynamic IP enabled.

At the browser, go to “Setup”- “Network”. Add a IP (192.168.10.75) and netmask (255.255.255.0) to the interface ETH02, i.e. wireless interface. Then go to “Router”- “Manage” to add two static routes for connecting wired and wireless interfaces.

Route 1 :
Destination – 192.168.10.0
Netmask – 255.255.255.0
Type – net
Metric – 1
Gateway – 192.168.0.75
Interface – N/A

Route 2 :
Destination – 192.168.10.0
Netmask – 255.255.255.0
Type – net
Metric – 2
Gateway – N/A
Interface – eth00

Now, you can surf the internet by wireless and you can also login to the ZeroShell web interface by wireless too.

Let’s build your home all-in-one router now!!!

HOWTO : Home made NAS server with Ubuntu 8.04.1 – Part IV (a)

Since someone complained that Torrentflux with BitTornado eats a lot of CPU resources. I then switch to Torrentflux-b4rt with BitTornado. Torrentflux-b4rt is a fork of Torrentflux but it is completely rewritten by the developers for the current version. The current version is still in beta 2 at this writing.

I have tested the torrent download at 1134.80 KB/s (one torrent) and it eats not more than 25% of CPU resources (according to the TOP). The overall CPU usage of the system is not more than 35% for the speed of download. Quiet good indeed. It is better than Torrentflux.

Torrentflux-b4rt supports wget, torrent and nzb metafile type download method. The downloaded video clips can be used for streaming via VLC. B4rt also supports Transmission, Azureus, BitTorrent Mainline and BitTornado. However, I had tested the latest version of Transmission (1.32) unsuccessful – it is too slow to start the download and unable to stop the transfer. I think it is bugs. Azureus requires Java to run and I will not test it at all. BitTorrent Mainline is also not tested. Therefore, I selected BitTornado.

Torrentflux-b4rt

Install required libraries and softwares :
sudo apt-get install php5-cli unrar unzip vlc uudeview build-essential bittornado

Download and compile the cksfv that required by b4rt :
wget http://zakalwe.fi/~shd/foss/cksfv/files/cksfv-1.3.12.tar.bz2
tar -xjvf cksfv-1.3.12.tar.bz2

cd cksfv-1.3.12
./configure
make
sudo make install

Get and install the Torrentflux-b4rt (the current version at this writing) from the official site :
wget http://download.berlios.de/tf-b4rt/torrentflux-b4rt_1.0-beta2.tar.bz2
tar -xjvf torrentflux-b4rt_1.0-beta2.tar.bz2

cd torrentflux-b4rt_1.0-beta2
sudo cp -R html /var/www/torrentflux

sudo chmod -R 0777 /var/www/torrentflux/inc/config

Create a directory for the download :
sudo mkdir /home/torrent
sudo chmod -R 0777 /home/torrent

Install the Torrentflux-b4rt with the browser. Type in “http://your_server_ip/torrentflux/setup.php”

Follow the instructions on the screen. The username and password of MySQL is the administrator’s username and password of the MySQL (i.e. “root” and the password that you install the MySQL). Make sure to delete the “setup.php”at /var/www/torrentflux after the installation.

The Torrentflux-b4rt is already installed. You can login by the browser at “http://your_server_ip/torrentflux”. Beware, the username and password that you have key in is the administrator username and password. The program will create for you once you keyed in.

I nearly forgot to tell you to open or forward the (default) port 49160 to 49300 at router or firewall. You can change it as desire.

Samba configuration

If you want to share the downloaded files with the intranet, you just added the following lines at the end of the /etc/samba/smb.conf :
[torrent]
comment = Share to all
path = /home/torrent
browseable = yes
read only = no
create mask = 0664
directory mask = 0664
valid users = samiux,john,mary
admin users = samiux

Access to the torrent directory at Windows system :
\\your_server_ip\torrent

Bonus

Transmission installation procedure :
sudo apt-get install libcurl4-openssl-dev gettedxt libc6-dev libssl-dev pkg-config

Download and install the Transmission :
wget http://download.m0k.org/transmission/files/transmission-1.32.tar.bz2
tar -xjvf transmission-1.32.tar.bz2

cd transmission-1.32
./configure --without-gtk
make
sudo make install

HOWTO : Home made NAS server with Ubuntu 8.04.1 – Part VI

This part is also optional. The Samba is shared with Windows desktops that files stored in the Samba will be infected by virus. To prevent this, you should install the ClamAV, the open source anti-virus program for Linux that kills Windows virus.

ClamAV

Edit /etc/apt/sources.list and append the following lines at the end of the file :
sudo nano /etc/apt/sources.list

# ClamAV PPA
deb http://ppa.launchpad.net/ubuntu-clamav/ubuntu hardy main
deb-src http://ppa.launchpad.net/ubuntu-clamav/ubuntu hardy main

sudo apt-get update
sudo apt-get install clamav clamav-daemon arj unzoo lha unrar

Make sure clamav-daemon is running :
ps ax | grep clamd

If not :
sudo /etc/init.d/clamav-daemon start
sudo /etc/init.d/clamav-freshclam start

Scan and kill virus if found at 03:00am on every day :
sudo crontab -e

0 3 * * * clamscan -r -i –remove /home > /home/samiux/scan.txt

Remember to configure the ClamAV’s 15 threads to 3 or less in order to reduce the consumption of CPU resources but the con is that it take a longer time to complete the virus scan of the whole system :
sudo dpkg-reconfigure clamav-base

Remarks : The current version of ClamAV at the time of this writing cannot scan RAR files. It is a bug and it will be fixed later.

HOWTO : Home made NAS server with Ubuntu 8.04.1 – Part V

This part is optional. The web server with PHP and MySQL is already running. Now, we are going to fine tune the Apache and PHP to make it running as faster as possible. The kernel can also be optimized too.

Apache

sudo apt-get install libapache2-mod-bw libapache2-mod-fastcgi

sudo a2enmod deflate
sudo /etc/init.d/apache2 force-reload

Edit the file /etc/apache2/conf.d/deflate.conf :
sudo nano /etc/apache2/conf.d/deflate.conf

<IfModule mod_deflate.c>
DeflateCompressionLevel 6
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/x-httpd-eruby
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/postscript
<IfModule mod_headers.c>
Header append Vary User-Agent
</IfModule>
</IfModule>

Edit /etc/apache2/apache2.conf :
sudo nano /etc/apache2/apache2.conf

Then change the value as the following :
ServerSignature Off
ServerTokens Prod

Updated for Ubuntu 9.04 :
sudo nano /etc/apache2/conf.d/security

Then change the value as the following :
ServerSignature Off
ServerTokens Prod

Edit /etc/apache2/sites-available/default :
sudo nano /etc/apache2/sites-available/default

Then change the value as the following at /var/www section :
Options -Indexes FollowSymLinks

Restart your Apache server :
sudo /etc/init.d/apache2 restart

PHP
To accelerate PHP, you need Zend but I will show you how to use eAccelerator.

Download the eAccelerator :
wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
tar xvf eaccelerator-0.9.5.3.tar.bz2

sudo apt-get install build-essential php5-dev

cd eaccelerator-0.9.5.3
phpize
./configure
make
sudo make install

sudo mkdir /tmp/eaccelerator
sudo chmod 0777 /tmp/eaccelerator

Add the following lines at the end of /etc/php5/apache2/php.ini :

extension="eaccelerator.so"
; shm_size default is 16, you may change to 64 or 128 depends on your RAM
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

Still at the php.ini file or enter the following command to go there.
sudo nano /etc/php5/apache2/php.ini

Locate Display_errors = On and change it to “Off”.
Display_errors = Off

Restart the Apache :
sudo /etc/init.d/apache2 restart

Kernel

Please refer to my blog “Performance-tunning” at https://samiux.wordpress.com/2008/06/12/performance-tunning/ for details.

HOWTO : Home made NAS server with Ubuntu 8.04.1 – Part IV

Your Samba server and vsFTPd server are running smoothly. Now, we are discussing the installation of remote BitTorrent feature.

You can access your remote BitTorrent server anywhere at anytime. The server requires Apache, PHP and MySQL. They have been installed when you install your Ubuntu Server that selecting the LAMP option.

BitTorrent

sudo apt-get install torrentflux bittornado

You will asked for MySQL root password, it is the same as the one when you install the Ubuntu Server. TorrentFlux Administration password to be entered in the same as the MySQL and Ubuntu user password in my case. (for easy remembering).

Run the TorrentFlux server at your desktop computer with Firefox :
http://your_server_ip/torrentflux

Enter the Log in name as “root” and the password as what you had entered during the installation (TorrentFlux Administration password).

You can replace the “your_server_ip” with your domain name or the IP that provided by your ISP (or say, the real IP).

Updated on 2008-AUG-13 :
Someone complained that the Torrentflux with Bittornado eats a lot of CPU resources. I confirmed that it is. I am looking for an alternative solution – BitTornado (backend) and Torrentflux-b4rt (front end). The title for the tutorial is at HOWTO : Home made NAS server with Ubuntu 8.04.1 – Part IV (a).

HOWTO : Home made NAS server with Ubuntu 8.04.1 – Part III

Now, your Samba file server is up and working. It is high time to configure the vsFTP server. Anonymous users can download your file from your FTP server but they cannot upload and change anything in it. Local users can access their local home directories (read and write) by using FTP client, e.g. Filezilla or gFTP.

vsFTP

Edit the file at /etc/vsftpd.conf :
sudo nano /etc/vsftpd.conf

Uncomment and change the following lines (removes the “#”in front of the entry) :
anonymous_enable=YES
local_enable=YES
write_enable=YES
data_connection_timeout=120
chroot_local_user=YES

If you are behind a router or firewall, you need to add the following lines at the end of the file :
pasv_enable=YES
pasv_promiscuous=YES
pasv_min_port=50000
pasv_max_port=50100
pasv_address=192.168.0.15

Change the ports 50000-50100 at your desire and add this port range to the router’s port forwarding section or virtual server section. The pasv_address should be the IP address of your server (yours may different from me).

Remember to forward port 20 and 21 out at your router.

Anonymous users can download files from /home/ftp and you can put some files there for them to download.

To restart your vsFTPd :
sudo /etc/init.d/vsftpd restart