Sunday, July 24, 2011

Reactivating

It's been years since my last post. It seems that I can't blog when I don't put my heart in it.
Let's see if I can reignite the sparks.

Tuesday, November 24, 2009

How to Make an Offline Repository of Your Own Ubuntu System

Introduction

Sometimes when you need to replicate an Ubuntu system to another computer, the usual step will be:
  1. Install Ubuntu using Installer CD/ Live CD
  2. Reboot
  3. Connect to the Internet
  4. Update
  5. Installing additional packages that you need
However, if it occurs that you need to install to another computer at another place with uncertainty of the availability and/or reliability of the Internet connection over there, one would wonder if you could prepare those updates and additional packages yourself in an offline repository.
Assuming the additional packages is the same with your Ubuntu System, this howto will explain how to make such offline repository.

Creating Offline Repository

There are 4 steps to setting up a simple repository for yourself
  1. Import the packages in a directory
  2. Scan the packages and create a file apt-get update can read
  3. Replicate the repository to portable media
  4. Add a line to your sources.list pointing at your repository

Import Packages

In your Ubuntu System, the .deb files you have installed are stored in /var/cache/apt/archives/
To replicate these files, first create the directory you want to paste into. For this example, we'll use ~/mydebs.

mkdir ~/mydebs

Then, replicate the files using rsync

rsync -upt --progress /var/cache/apt/archives/*.deb ~/mydebs

Sometimes some files you have installed is not cached. If so, you need to retrieve them from the internet. First we need to generate the list of files to be downloaded.

sudo apt-get install $(dpkg -l|grep ^ii|awk '{print $2}') --reinstall --print-uris \
-y |awk '{print $1}'|sed "s/'//g"|grep tp:// > downlist

Then download it using wget

wget -ci downlist -P ~/mydebs

Scan Packages

To be included in apt-get process, we net to generate packages list of those .deb files.
First go into mydebs directory.

cd ~/mydebs

then generate Packages.gz using dpkg-scanpackages

dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

Replicate mydebs Directory to Portable Media

The repository can now be replicated to portable media, such as DVD-ROM or External Hard Drive. Assuming you are using external harddrive with volume name REPO:

rsync -a ~/mydebs /media/REPO/mydebs

Then, after finishing installing the new system, restore the directory to your new home folder

rsync -a /media/REPO/mydebs ~/mydebs

Adding mydebs Directory as Repository Source

To use these repository, these mydebs directory then must be included in the Repository Source file on your new system.

sudo su -pc 'echo deb file:$HOME/mydebs ./ >> /etc/apt/sources.list'

sudo apt-get update

Your repository is now ready to use

Tuesday, October 28, 2008

Counting Down on Intrepid Ibex


I just can't wait :-D

Monday, October 27, 2008

Extracting Similarity Between Two (Text) Files

When you need to compare difference between two files, you have diff.
When you need to find similarity between such files, as far as I know, you need to devise your own script.
This is my oneliner script for such need (assuming files to be compared named file-01 & file-02):

for ((i=1;i<=$(wc -l file-01|awk '{print $1}');i+=1)); do grep $(awk -v a=$i 'NR==a' file-01) file-02 ; done

Ugly, but working...

Monday, October 13, 2008

The Reason

If I know the answer of "Why",
I believe I'll better understand the question of "How"

I need to know why I want to be rich, before seeking the way to be richer
I need to know why I want to be free, before breaking anything that hold me back
I need to know why I want to be happy, before pursuing the happiness itself

But, is it wise to seek the reason of being right, while I am still pursuing the very question of what is truth?

Tuesday, February 05, 2008

Reverse Proxy with Apache

Sometimes, when we need to configure network devices within LAN (via http), we need to do it on site due to private addressing. While making the devices directly accessible from the Internet is a big no-no, there is another way to connect remotely and securely: Reverse HTTP Proxy (with Apache).

Apache has proxy-related modules to enable this operation. To get it working, you need to enable this modules:
- proxy
- proxy_http

Using Ubuntu 7.10, this modules can be loaded simply by typing:

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo /etc/init.d/apache2 restart

To forward any http request to your internal address, you need to add the destination url into your virtual host configuration, i.e:

sudo nano /etc/apache2/sites-available/yourvirtualhostconfig

then add this line:

ProxyPass /your-public-url/ http://your-private-address

enable your site by typing:

sudo a2ensite yourvirtualhostconfig
sudo /etc/init.d/apache2/restart

By default, in Ubuntu 7.10 all proxy access are denied. Therefore, you
need to white list your address into the proxy.conf file

sudo nano /etc/apache2/mods-available/proxy.conf

change the config to allow your source address i.e:

<Proxy *>
AddDefaultCharset off
Order deny,allow
Deny from all
Allow from 203.153.240.197
</Proxy>

Then reload the configurations

sudo a2enmod proxy
sudo /etc/init.d/apache2 restart

That's it folks. Enjoy working on your devices remotely, securely.
(It is not so secure as the traffic is not encrypted. What I mean by
secure, is that I can hide the private address from any port scan.
Therefore, what is deemed secure by me, is not necessarily secure by
your definition. This is MY blog, so no complain!!!)

Monday, November 12, 2007

Connecting to XL 3G via Sony Ericsson W850i

While it is not so newbie friendly, I never thought that configuring Internet connectivity using my cellular phone will be a straightforward process. All I did just edit the /wtc/wvdial.conf into this:

Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0

Modem Type = USB Modem
Baud = 460800
Modem = /dev/ttyACM1
ISDN = 0
Phone = *99***1#
Phone1 = *99***2#
Password = proxl
Username = xlgprs

then, I connect by calling wvdial (with root privillege)

sudo wvdial

Just be very cautious with the cost as it is charged per KB!
Enjoy...