Skip to content


DHCP on Ubuntu

Goal: Install DHCP server for 192.168.10.0 VLAN. IP Pool would be 192.168.10.101-250

Prerequisite Details:

IP address range: 192.168.10.101 to 192.168.0.250
Subnet Mask: 255.255.255.0
DNS Servers: 202.188.0.133, 202.188.1.5
Domains: transcomus.com
Gateway Address: 192.168.10.1

1.Install the DHCP server using the below commands and make some required changes as below:

$ sudo apt-get install dhcp3-server
$ sudo cp /etc/default/dhcp3-server /etc/default/dhcp3-server_backup
$ sudo gedit /etc/default/dhcp3-server

2. Find this line
… INTERFACES=”"
3. Replace with the following line
INTERFACES=”eth0″
4. Save the edited file

$ sudo cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf_backup
$ sudo gedit /etc/dhcp3/dhcpd.conf

5. Find this section

# option definitions common to all supported networks…
option domain-name “example.org”;
option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;
max-lease-time 7200;

6. Replace with the following lines
# option definitions common to all supported networks…
#option domain-name “example.org”;
#option domain-name-servers ns1.example.org, ns2.example.org;

#default-lease-time 600;
#max-lease-time 7200;
7. Find this section

# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
# range 10.5.5.26 10.5.5.30;
# option domain-name-servers ns1.internal.example.org;
# option domain-name “internal.example.org”;
# option routers 10.5.5.1;
# option broadcast-address 10.5.5.31;
# default-lease-time 600;
# max-lease-time 7200;
#}

8. Replace with the following lines

# A slightly different configuration for an internal subnet.
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.0.101 192.168.0.250;
option domain-name-servers 202.54.10.2;
option domain-name "transcomus.com";
option routers 192.168.10.1;
option broadcast-address 192.168.10.255;
default-lease-time 600;
max-lease-time 691200;
}

9. Save the edited file (sample/dhcpd.conf_installdhcpserver)
10. $ sudo /etc/init.d/dhcp3-server restart

Now change the client settings to pickup the IP automatically, if your client machines picking up the IP’s means your DHCP is working fine. If not then please check the log files for errors.

Posted in Linux.


Tips & Tricks

Grep in colour
Grep can use colours to highlight the matching text using the –color parameter

grep –color=auto

I found this tip at:

http://unstableme.blogspot.com/2009/03/highlight-match-with-color-in-grep.html

Posted in Linux.


FreeLance Projects

I have hands on experience on so many opensource projects. I have done these projects as my hobby as well as a professional.

Mail Severs

* Postfix
* Sendmail
* Qmail

Proxy

* Squid

WebServers

* Apache
* Lighthttpd
* Tomcat

Telephony

* Asterisk
* Vicidial
* FreeSwitch

DNS

BIND

Webservices

* Amazon
* EC2(Elastic Computer Cloud)
* S3(Simple Storage solution)

Blog

* Roller
* WordPress

Bug-Tracking

* Buggzilla
* Mantis
* Trac

CMS

* Alfresco
* Drupal
* Joomla
* KnowledgeTree

CRM

* SugarCRM

ECM

* Alfresco
* KnowledgeTree

Forum

* phpBB

Portal Server

* Liferay

Version Control

* Subversion

Wiki

* DokuWiki
* MediaWiki
* DokuWiki

eLearning

* Dokeos
* Moodle

If anybody interested or having any problem in above mentioned projects please feel free to contact me at +91 9899184890 or mail me out at ramesh.mimit@gmail.com

Posted in Soldier of Fortune.


Open Source Projects

In today’s world everybody intersted in implementing the opensource solutions. If anybody want to survive he has to think upon the free solution where he can fulfill his requirements by doing some tweaks to the opensource applications. I have worked on lots of opensource projects, some of them are listed below:

Blog

* Roller
* WordPress

Bug-Tracking

* Mantis
* Redmine
* Buggzilla
* Trac

Business Intelligence

* JasperServer

CMS

* Alfresco
* Drupal
* Enano CMS
* eZ Publish
* Joomla
* KnowledgeTree

CRM

* SugarCRM

ECM

* Alfresco
* KnowledgeTree

Forum

* phpBB

Photo Sharing

* Coppermine Photo Gallery
* Gallery

Planning

* Tracks

Poll Management

* Opina

Portal Server

* JasperServer
* Liferay

Version Control

* Subversion

Wiki

* DokuWiki
* MediaWiki

eLearning

* Dokeos
* Moodle

Infrastructure

* DjangoStack
* JRubyStack
* LAMPStack
* LAPPStack
* MAMPStack
* MAPPStack
* RubyStack
* SAMPStack
* WAMPStack
* WAPPStack

Posted in Open Source.


iSCSI and LVM

iSCSI – Brainstorm

iSCSI is a protocol that allows you to use SCSI commands over an IP network. You can use the storage over the network using iSCSI.

SCSI uses a client-server architecture. A “client” (ie: your system) is an initiator, it initiates requests. A “server” (ie: your storage device) is a target, it has something you want and answers requests from the initiator(s).

iSCSI Basics

All devices in an iSCSI enviroment will have addresses. Initiators will have addresses, and targets will have addresses. When you define a target you can specify the address yourself.

iSCSI uses the following form for addresses

iqn.2009-05.com.linuxtrove.avstorage:storage03

iqn (iSCSI Qualified Name)

The date field is the date of the first full month

The Naming Auth is the naming authority (domain name) for this target, reversed.

Following the naming authority is a colon, after which you can put anything you want to help you better remember.

I have used this one: iqn.2009-05.com.linuxtrove.avstorage:storage03

Now we will setup the target first then configure the initiator

<!– @page { margin: 2cm } P { margin-bottom: 0.21cm } H2 { margin-bottom: 0.21cm } H2.cjk { font-family: “DejaVu Sans” } H2.ctl { font-family: “DejaVu Sans” } –>

Setting up a Target

I have follow the following steps:

  1. Install the new machine with Ubuntu-8.4 OS, i have 1TB storage capacity on this machine.

We made the LVM partion because we are gonna to add it up in existing LVM storage.

IP Address for the machine is 192.168.200.23

Install the iscsitarget package using the following command.

apt-get install iscsitarget

3. Edit /etc/ietd.conf file

ietd.conf file contains the information which partition of the system is gonna to export using iSCSI

I have made the entry like this:

Target iqn.2009-05.com.linuxtrove.avstorage:storage03

Lun 1 Path=/dev/sda3,Type=blockio
Alias storage03

Second line Contains the path of the partiton you are going to use for storage
and the type of the device, it may be a file, but in our case it is a block device.

Third line contains the Alias, that is optiona
Save the file then restart the iscsi service using the following command.

#/etc/init.d/iscsitarget restart

NOTE: For more information please read the man pages or do googling.

Setting up an Initiator

  1. Install the open-iscsi package using the following command.

#apt-get install open-iscsi

In my case i have initiator already setup so i skipped the step 1.

  1. To list the targets, do the following

iscsiadm --mode discovery --type sendtargets --portal 192.168.200.23

Once the targets are listed above, they are automatically added into 
	 /etc/iscsi/nodes
  1. You can change the settings in the nodes directory and make it always automatic login on boot. The directories and files to be considered are

  • /etc/iscsi/iscsid.conf <- Make Node as automatic rather than manual
  • /etc/iscsi/nodes/yournodename <- Change the configuration and make it automatic e.g. node.startup=automatic
  1. Start into a node using the following and then monitor /var/log/messages for the block device name

iscsiadm –mode node –targetname iqn. 2009-05.com.vccorp.avstorage:storage03 –portal 192.168.200.23 –login

After that just check the output of fdisk command. New disk will be there as i got.

# fdisk -l

Disk /dev/sdd: 80.0 GB, 80026361856 bytes

255 heads, 63 sectors/track, 9729 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdd1 1 2550 20482843+ 8e Linux LVM

/dev/sdd2 * 2551 9430 55263600 83 Linux

/dev/sdd3 9431 9729 2401717+ 5 Extended

/dev/sdd5 9431 9729 2401686 82 Linux swap / Solaris

Disk /dev/sde: 500.1 GB, 500105217024 byte

255 heads, 63 sectors/track, 60800 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sde1 1 60800 488375968+ 8e Linux LVM

Disk /dev/sdf: 485.5 GB, 485595855360 bytes

255 heads, 63 sectors/track, 59037 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdf1 1 59037 474214671 8e Linux LVM

Disk /dev/sdg: 986.0 GB, 986005440000 bytes

255 heads, 63 sectors/track, 119875 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdg1 1 119875 962895906 8e Linux LVM

Above is just the sample output.

/dev/sdg1 is the newely added partiton by iSCSI.

Now we will add this new storage to our existing LVM.

# pvcreate /dev/sdg1

#pvscan

root@Orion:~# pvscan

PV /dev/sda1 VG recordings lvm2 [74.52 GB / 0 free]

PV /dev/sdb1 VG recordings lvm2 [74.52 GB / 0 free]

PV /dev/sdd1 VG recordings lvm2 [19.53 GB / 0 free]

PV /dev/sdc1 VG recordings lvm2 [335.34 GB / 0 free]

PV /dev/sde1 VG recordings lvm2 [465.75 GB / 0 free]

PV /dev/sdf1 VG recordings lvm2 [452.23 GB / 0 free]

Total: 6 [1.29 TB] / in use: 6 [1.29 TB] / in no VG: 0 [0 ]

Its not showing newely created physical volume.

Physical Volume will not be recognised untill you add it up in any volume group.

#vgextend recordings /dev/sdg1

# pvscan

root@Orion:~# pvscan

PV /dev/sda1 VG recordings lvm2 [74.52 GB / 0 free]

PV /dev/sdb1 VG recordings lvm2 [74.52 GB / 0 free]

PV /dev/sdd1 VG recordings lvm2 [19.53 GB / 0 free]

PV /dev/sdc1 VG recordings lvm2 [335.34 GB / 0 free]

PV /dev/sde1 VG recordings lvm2 [465.75 GB / 0 free]

PV /dev/sdf1 VG recordings lvm2 [452.23 GB / 0 free]

PV /dev/sdg1 VG recordings lvm2 [918.28 GB / 0 free]

Total: 7 [2.29 TB] / in use: 7 [2.29 TB] / in no VG: 0 [0 ]

Now its showing the new PV also.

root@Orion:~# vgdisplay

— Volume group —

VG Name recordings

System ID

Format lvm2

Metadata Areas 7

Metadata Sequence No 22

VG Access read/write

VG Status resizable

MAX LV                          0

Cur LV                              1

Open LV                            1

Max PV                              0

Cur PV                               7

Act PV                              7

VG Size                            2.29 TB

PE Size                            16.00 MB

Total PE                         91001

Alloc PE / Size              91001 / 2.29 TB

Free PE / Size                58770 / 986GB

VG UUID                       wz8pMV-RE63-Flwo-jpUI-G3t7-GCCz-uEAQDT

Now check the Logical volume space using the follwing command.

root@Orion:~# lvdisplay

— Logical volume —

LV Name /dev/recordings/disk1

VG Name recordings

LV UUID                             qy4ywC-oRqH-ccc5-PY47-NkCL-9Fcw-SfLpD1

LV Write Access                read/write

LV Status                              available

# open 1

LV Size                                 1.29 TB

CurrentLE                            149771

Segments                                7

Allocation                          inherit

Read ahead sectors                  0

Block device                          254:0

Now we will extend the size of Logical Volume by using the following command.

# lvextend -l +58770 /dev/recordings/disk1 /dev/sdg1

In the output of vgdisplay you can can the free extents and just add them like the above command.

Now please check the output of “df -h”.

root@Orion:~# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sdd2 52G 16G 35G 31% /

varrun 502M 144K 502M 1% /var/run

varlock 502M 0 502M 0% /var/lock

procbususb 502M 444K 502M 1% /proc/bus/usb

udev 502M 444K 502M 1% /dev

devshm 502M 0 502M 0% /dev/shm

lrm 502M 33M 469M 7% /lib/modules/2.6.20-16-generic/volatile

/dev/mapper/recordings-disk1   1.4T 1.3T 222G 99% /recordings

Size of the logical volume still not increased. To make it visible here and usable, we have two ways.

  1. Reboot the system
  2. Online resizing

In second option we dont require reboot. So i prefer the second one. Use the following command to do that.

# resize2fs /dev/recordings/disk1

It will take some time to resize. Please have patience and wait for atleast 1 hour. If you want to check it that size is increasing or not you can check it by executing the df command without any flag.

Posted in Linux.


Wine Configuration For Multiple Users

Open a terminal and Create a user using the following commands

useradd test
passwd test

Now Login to system by test user now.
Open up the terminal and run the following commands

#Download the latest IE from tatanka.com

wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
tar -zxvf  ies4linux-latest.tar.gz
cd ies4linux-*
./ies4linux

Now you should be able to launch ie6 with “/home/test/bin/ie6″ in a terminal.

Log off from the wine session and log in on your main user account.

Open a terminal and type:

sudo visudo 

It should give you an editor where you can insert sudo rules.
At the end of the file you can insert this line:

ALL     ALL = (test) NOPASSWD:ALL

It means that all users can ran commands as if they are the wine user without giving a password, save and go back to the terminal.

run this command to allow the wine program to access the display:

xhost + 

you can now type this command to run ie6 from your main account (and all others too):

sudo -u test /home/test/bin/ie6 

to facilitate you can automate this in a script.
Enter this command in a terminal:

sudo gedit /usr/local/bin/ie6

It should give you a text editor.
Enter these 3 lines in the text editor and save the file:

#!/bin/bash
xhost +
sudo -u test /home/test/bin/ie6

Close the text editor, go back to the terminal and type this command to make this file executable:

sudo chmod 755 /usr/local/bin/ie6

Now you can launch Internet explorer by typing ie6 in a terminal from all the accounts.

If you want a shortcut like Firefox in your Internet section you need to follow the following steps:

Open a terminal and type this command:

sudo vim /usr/share/applications/ie6.desktop

Enter the following lines in the text editor:

[Desktop Entry]
Encoding=UTF-8
Name=Internet Explorer
Comment=Microsoft Internet Browser
Exec=ie6
Type=Application
Icon=/home/test/ies4linux/ies4linux.svg
Categories=Application;Network;

Save the file and exit the text editor.

Now You should have access to Internet Explorer via Applications -> Internet -> Internet Explorer

I have also made a script for the above mentioned task. You can download the script and just execute the script it will do all the tasks automataically. You can download the script from here or just copy below mentioned text in a file save the file and give the execute pemissions and execute the script.

#!/bin/bash
HOMEDIR=/home/test
apt-get -y install wine cabextract
cd $HOMEDIR
wget http://linuxtrove.com/IE.tar.gz
tar -xzf IE.tar.gz
chown -R test.test .ies4linux
echo "ALL ALL = (test) NOPASSWD:ALL" >> /etc/sudoers
touch /bin/ie6
echo "#!/bin/bash" > /bin/ie6
echo "xhost +" >> /bin/ie6
echo "sudo -u test /home/test/.ies4linux/bin/ie6" >> /bin/ie6
chmod 755 /bin/ie6
cd /usr/share/applications
wget http://linuxtrove.com/ie6.desktop

Posted in Linux.


Ubuntu Network Installation Using PenDrive

About

With the new version of Ubuntu Hardy Heron 8.04, the ms-sys package no longer exists (due to copyright violations). For that download the ms-sys package here ms-sys-2.1.3.tar.gz and also install gettext using apt-get.

Value Addition:

We can setup a linux machine in a matter of minutes without requiring some special infrastructure. Also, if we have customized an operating system (in case of say, a streaming server, or VMS slave servers), we can make an image of it and make it installable. That installation can be started via the network, so the end user would just need to plugin the USB Pen Drive, and automatically the server would be setup, configured and available for use.

The softwares that you may need to download are syslinux, mtools, ms-sys, gettext

Following are the steps:

Step 1: Make a Bootable USB Pen Drive

  • Partition the USB Drive and make the partition bootable using fdisk. Make sure the partition that you’d make bootable is a Win95Fat16 one (Mode e in fdisk)
  • Now put Win95 MBR in the drive by using ms-sys -9 /dev/sda (ms-sys is not available 8.04/Hardy Heron onwards. Use the Gutsy Deb for the same. ms-sys_2.1.0-1_i386.deb )
  • Format that partition using mkdosfs /dev/sda1
  • Make it bootable using syslinux by typing syslinux /dev/sda1
  • Mount the USB Drive’s Parition through mount /dev/sda1 /media/usbdisk. Copy the initrd.gz and linux onto the partition
  • Create a file called syslinux.cfg inside the parition and add the following values into it
DEFAULT insall

LABEL install
 menu label ^Start Ubuntu via Netboot
 kernel linux
 append initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

Make the chages to append line as below if you want to perform a kicksrtart installation.

DEFAULT insall

LABEL install
 menu label ^Start Ubuntu via Netboot
 kernel linux
 append ks=http://ipadd/ofserver/ks.cfg initrd=initrd.gz rw quiet splash --

So essentially there’d be only 4 files inside the USB Drive, viz. initrd.gz , ldlinux.sys , linux , syslinux.cfg

STEP 2: On your Web Server, mount the ISO and make it available

# cd /var/www
# mkdir ubuntu
# mount -o loop /path/to/ubuntu-8.10-alternate.iso /var/www/ubuntu

STEP3: Boot using the USB and start the installation Now there are two problems.
(a) If you start the Edgy Installation using the netboot kernel, it’ll search for archive.ubuntu.com and get the Release files from there. If the Release file that is available at archive.ubuntu.com is later than what’s available on the CD, then you’ll face problems while downloading packages. So, the network installation will fail if you use the CD as the repository.
(b) The linux-image-kernel which is available in the CD, probably does not have correct GPG key/md5sum. Due to which later in the installation it gives an error that it could not be authenticated and the installation fails. The solution to both the problems above is covered below

  • Boot using the USB. You should be able to see the installation screen where it asks for the Language. If not, try the Ubuntu Wiki where booting using the USB is explained alongwith the Netboot Kernel Image.
  • Proceed through the normal installation steps. Once the Network Configuration step comes, if you’ve a DHCP server, it’ll automatically pickup the IP Address. Don’t let that happen (Press Cancel). If the DHCP Config is done and it asks for the system’s name, click Go Back and configure the network manually.
  • If you have the details about the IP Address, well and good, else on the VT2, type ifconfig and route -n to know about the IP Address, Subnet Mask and the Gateway
  • Don’t Provide the DNS Entry as it will allow the system to go through internet and get connected to archive.ubuntu.com which we do not want.
  • While asked for mirror from which to do the installation, go to the Top and add the information manually.
  • Once the Base Installation is in progress, switch to Virtual Terminal 2, by pressing ALT+F2. Press ENTER and add the following
  • echo 'APT::Get::AllowUnauthenticated "true";' >>/target/etc/apt/apt.conf (All Credit goes to dixonp who suggested the same here -> http://ubuntuforums.org/showthread.php?t=332343)
    This will ensure that no GPG Related issues pop-up and installation happens smoothly.

That’s it. This will help you in a scenario where

  • Bandwidth is limited and you don’t want to connect to Internet everytime you need to do the installation
  • You were able to get an Alternate Install ISO (or a CD), but there are no CD Drives on the machines you wish to install Ubuntu
  • You wish to do fast Ubuntu Installations but they should be interactive (Otherwise you can look into Kickstart Installs)
  • The DHCP network is not in your control to setup a PXE Install

Note: All the credit goes to Marquivon who posts the same here http://ubuntuforums.org/showthread.php?p=2086827

Posted in Linux.


Build Own deb Package

About Deb package

Normal Debian packages get a proper source package, including a debian/rules file which automates the steps involved in creating the binary package. Here we just show how to package a simple shell script or binary executable into a small binary package.

From the dpkg-deb man page: “dpkg-deb packs, unpacks and provides information about Debian archives. .deb files can also be manipulated with ar and tar alone if necessary. Use dpkg to install and remove packages from your system.”

.deb package are just the tar archives but with a proper structural format of  files. You can see and extract any deb package with any archive manager tool.

You might find lots of example .deb files in directory ‘/var/cache/apt/archives/‘. With ‘dpkg-deb -I somepackage.deb‘ you might get a general overview of what this package offers in particular. ‘dpkg-deb -c somepackage.deb‘ lists all files which will be installed.

List content of the .deb file with ‘ar tv somepackage.deb‘. Use the ‘x’ option to extract the files.

Package Structure:

$ ar tv parted_1.4.24-4_i386.deb
rw-r--r-- 0/0      4 Mar 28 13:46 2002 debian-binary
rw-r--r-- 0/0   1386 Mar 28 13:46 2002 control.tar.gz
rw-r--r-- 0/0  39772 Mar 28 13:46 2002 data.tar.gz

Now we can start to extract all files including the content of the tar files.

Debian Binary:

The content of this file is “2.0\n”. This states the version of the deb file format. For 2.0 all other lines get ignored.

data.tar.gz

The ‘data.tar.gz’ file contains all the files that will be installed with their destination paths:

drwxr-xr-x root/root      0 2002-03-28 13:44:57 ./
drwxr-xr-x root/root      0 2002-03-28 13:44:49 ./sbin/
-rwxr-xr-x root/root  31656 2002-03-28 13:44:49 ./sbin/parted
drwxr-xr-x root/root      0 2002-03-28 13:44:38 ./usr/
drwxr-xr-x root/root      0 2002-03-28 13:44:41 ./usr/share/
drwxr-xr-x root/root      0 2002-03-28 13:44:38 ./usr/share/man/
drwxr-xr-x root/root      0 2002-03-28 13:44:52 ./usr/share/man/man8/
-rw-r--r-- root/root   1608 2002-03-28 13:44:37 ./usr/share/man/man8/parted.8.gz
drwxr-xr-x root/root      0 2002-03-28 13:44:41 ./usr/share/doc/
drwxr-xr-x root/root      0 2002-03-28 13:44:52 ./usr/share/doc/parted/
-rw-r--r-- root/root   1880 2002-03-07 14:20:08 ./usr/share/doc/parted/README
-rw-r--r-- root/root   1347 2002-02-27 01:40:50 ./usr/share/doc/parted/copyright
-rw-r--r-- root/root   6444 2002-03-28 13:37:33 ./usr/share/doc/parted/changelog
-rw-r--r-- root/root  15523 2002-03-28 02:36:43 ./usr/share/doc/parted/changelog.gz

It must be the last file in the deb archive.

control.tar.gz

This file has the contents like listed below.

-rw-r--r--    1 root     root         1336 Mar 28  2002 control
-rw-r--r--    1 root     root          388 Mar 28  2002 md5sums
-rwxr-xr-x    1 root     root          253 Mar 28  2002 postinst
-rwxr-xr-x    1 root     root          194 Mar 28  2002 prerm

‘md5sums’ contains for each file in data.tar.gz the md5sum. In our example the content looks like this:

1d15dcfb6bb23751f76a2b7b844d3c57  sbin/parted
4eb9cc2e192f1b997cf13ff0b921af74  usr/share/man/man8/parted.8.gz
2f356768104a09092e26a6abb012c95e  usr/share/doc/parted/README.Debian
a6259bd193f8f150c171c88df2158e3e  usr/share/doc/parted/copyright
7f8078127a689d647586420184fc3953  usr/share/doc/parted/changelog.Debian.gz
98f217a3bf8a7407d66fd6ac8c5589b7  usr/share/doc/parted/changelog.gz

‘prerm’ and ‘postinst’ seem to take care of removing old documentation files and adding a link from doc to share/doc.

$ cat postinst
#!/bin/sh
set -e
# Automatically added by dh_installdocs
if [ "$1" = "configure" ]; then
  if [ -d /usr/doc -a ! -e /usr/doc/parted -a -d /usr/share/doc/parted ]; then
    ln -sf ../share/doc/parted /usr/doc/parted
  fi
fi
# End automatically added section
$ cat prerm
#!/bin/sh
set -e
# Automatically added by dh_installdocs
if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/parted ]; then
  rm -f /usr/doc/parted
fi
# End automatically added section

And finally the most interesting file:

$ cat control
Package: parted
Version: 1.4.24-4
Section: admin
Priority: optional
Architecture: i386
Depends: e2fsprogs (>= 1.27-2), libc6 (>= 2.2.4-4), libncurses5 (>= \
5.2.20020112a-1), libparted1.4 (>= 1.4.13+14pre1), libreadline4 (>= \
4.2a-4), libuuid1
Suggests: parted-doc
Conflicts: fsresize
Replaces: fsresize
Installed-Size: 76
Maintainer: Timshel Knoll <timshel@debian.org>
Description: The GNU Parted disk partition resizing program
 GNU Parted is a program that allows you to create, destroy,
 resize, move and copy hard disk partitions. This is useful
 for creating space for new operating systems, reorganizing
 disk usage, and copying data to new hard disks.
 .
 This package contains the Parted binary and manual page.
 .
 Parted currently supports DOS, Mac, Sun, BSD, GPT and PC98
 disklabels/partition tables, as well as a 'loop' (raw disk)
 type which allows use on RAID/LVM. Filesystems supported are
 ext2, ext3, FAT (FAT16 and FAT32) and linux-swap. Parted can
 also detect HFS (Mac OS), JFS, NTFS, ReiserFS, UFS and XFS
 filesystems, but cannot create/remove/resize/check these
 filesystems yet.
 .
 The nature of this software means that any bugs could cause
 massive data loss. While there are no known bugs at the moment,
 they could exist, so please back up all important files before
 running it, and do so at your own risk.

Further information about the control file can be obtained via ‘man 5 deb-control’.

Below is the example script with intergrate all the above steps together. You can change the script as per your needs.

#!/bin/bash
# This script should be run from within the directory with the .jpg files.
# First, create the empty tree under a new "build" directory
# (the name "build" is completely arbitrary here)
mkdir -p build/usr/share/newwallpapers/
# Put the jpg images in the newwallpapers directory
cp -v *.jpg build/usr/share/newwallpapers/
# move into the build directory, make a docs directory
cd build
mkdir -p usr/share/doc/your-package-name
# write the README file
cat > usr/share/doc/your-package-name/README <<END
This package provides latest desktop wallpapers for Ubuntu desktop.
It moves the original wallpapers aside using dpkg-divert, and
restores them upon uninstallation.
END
# write the control file
cat > control <<END
Package: your-package-name
Version: 0.1
Section: user/themes
Priority: optional
Architecture: all
Installed-Size: `du -ks usr|cut -f 1`
Maintainer: Your-Name-Here <someone@example.com>
Description: New desktop wallpapers, with auto-backup of the originals
 This package contains a set of jpg files. This
 version will preserve your current wallpapers using dpkg-divert and
 restore them upon uninstallation.
 END
# write the pre-installation script
cat > preinst <<END
#!/bin/sh
if [ "$1" = install ]; then
    for f in newhill.jpg get_started.jpg new_era.jpg this_world.jpg heaven.jpg weather.jpg new_lesson.jpg old_building.jpg wemm.jpg coinage.jpg genesis.jpg aslan.jpg googleworld.jpg vcustomer.jpg hacktheworld.jpg manhack.jpg warlock.jpg sicker.jpg; do
        dpkg-divert --package your-package-name --rename --add /usr/share/newwallpaperss/$f
    done
fi
END
# write the post-removal script
cat > postrm <<END
#!/bin/sh
if [ "$1" = remove ]; then
    for f in newhill.jpg get_started.jpg new_era.jpg this_world.jpg heaven.jpg weather.jpg new_lesson.jpg old_building.jpg wemm.jpg coinage.jpg genesis.jpg aslan.jpg googleworld.jpg vcustomer.jpg hacktheworld.jpg manhack.jpg warlock.jpg sicker.jpg; do
        dpkg-divert --package your-package-name --rename --remove /usr/share/newwallpapers/$f
    done
fi
END
# Setting this environment variable fixes Apple's modified GNU tar so that
# it won't make dot-underscore AppleDouble files. Google it for details...
export COPY_EXTENDED_ATTRIBUTES_DISABLE=1
# create the data tarball
# (the tar options "czvf" mean create, zip, verbose, and filename.)
tar czvf data.tar.gz usr/share/newwallpapers/ usr/share/doc/
# create the control tarball
tar czvf control.tar.gz control preinst postrm
# create the debian-binary file
echo 2.0 > debian-binary
# create the ar (deb) archive
ar -r your-package-name.deb debian-binary control.tar.gz data.tar.gz
# move the new deb up a directory
mv your-package-name.deb ..
# remove the tarballs, and cd back up to where we started
rm data.tar.gz control.tar.gz
cd ..

After running this, should have a your-package-name.deb next to your jpg files in the current directory. You can delete the build sub-directory, and try installing your new package.

All the credit goes to http://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/ and http://synthesize.us/HOWTO_make_a_deb_archive_without_dpkg.

Posted in Linux.


LVM (Logical Volume Manager)

What is LVM

LVM is a Logical Volume Manager for the Linux operating system. There are now two version of LVM for Linux:

  • LVM 2 – The latest and greatest version of LVM for Linux.LVM 2 is almost completely backward compatible with volumes created with LVM 1. The exception to this is snapshots (You must remove snapshot volumes before upgrading to LVM 2)LVM 2 uses the device mapper kernel driver. Device mapper support is in the 2.6 kernel tree and there are patches available for current 2.4 kernels.
  • LVM 1 – The version that is in the 2.4 series kernel,LVM 1 is a mature product that has been considered stable for a couple of years. The kernel driver for LVM 1 is included in the 2.4 series kernels

Features

The LVM can:

  • Resize volume groups online by absorbing new physical volumes (PV) or ejecting exiting  ones.
  • Resize logical volumes (LV) online by concatenating extents onto them or truncatiing    extents from them.
  • Create read-only snapshots of logical volumes (LVM1).
  • Create read-write snapshots of logical volumes (LVM2).
  • Stripe whole or parts of logical volumes across multiple PVs, in a fashion similar to R AID0.
  • Mirror whole or parts of logical volumes, in a fashion similar to RAID1.
  • Move online logical volumes between PVs.
  • Split or merge volume groups in situ (as long as no logical volumes span the split).  The    can be useful when migrating whole logical volumes to or from offline storage.

 The LVM will also work in a shared-storage cluster (where disks holding the PVs are shared between multiple host computers), but requires an additional daemon to propagate state changes between cluster nodes.

LVM does not:

  • Provide parity-based redundancy across LVs, as with RAID4, RAID5 or RAID6. This functionality is instead provided by Linux metadisks, which can be used as LVM physical volumes.

LVM Terminology

Physical Volume (PV) :- A PV is nothing more than a physical medium with some administrative data added to it – once you have added this, LVM will recognise it .

A Physical Volume, containing Physical Extents:

+-----[ Physical Volume ]------+
| PE | PE | PE | PE | PE | PE  |
+------------------------------+

b. Physical Extents (PE) :- Physical Extents are like really big blocks, often with a size of megabytes.

c. Volume Group (VG) :- A VG is made up of a number of Physical Extents (which may have come from multiple Physical Volumes or hard drives). While it may be tempting to think of a VG as being made up of several hard drives (/dev/hda and /dev/sda for example), it’s more accurate to say that it contains PEs which are provided by these hard drives.

A Volume Group, containing 2 Physical Volumes (PVs) with 6 Physical Extents:

+------[ Volume Group ]-----------------+
|  +--[PV]--------+  +--[PV]---------+  |
|  | PE | PE | PE |  | PE | PE | PE  |  |
|  +--------------+  +---------------+  |
+---------------------------------------+
We now further expand this:

+------[ Volume Group ]-----------------+
|  +--[PV]--------+  +--[PV]---------+  |
|  | PE | PE | PE |  | PE | PE | PE  |  |
|  +--+---+---+---+  +-+----+----+---+  |
|     |   |   | +-----/     |    |      |
|     |   |   | |           |    |      |
|   +-+---+---+-+      +----+----+--+   |
|   |  Logical  |      |  Logical   |   |
|   |  Volume   |      |   Volume   |   |
|   |           |      |            |   |
|   |  /home    |      |    /var    |   |
|   +-----------+      +------------+   |
+---------------------------------------+

You can use pvdisplay,vgdisplay and lvdisplay commands to show the physical volume,
volume group and logical volume status respectively.

Posted in Linux.


Trac Setup

Trac is open-source solution for wiki and bugs tracking system.

Follow the following steps to install the Ttac  wiki and bug tracking system version 0.11.2

Prerequiste for Trac installation are

1.    Python version >= 2.3
2.    Setuptools version >= 0.6
3.    Genshi version >= 0.5
4.    SQLite version 3.3.4
5.    Webserver mostly  apache used

Step1: For installing the setup tool and Genshi template download the ez.setup.py script from http://svn.python.org/projects/sandbox/branches/setuptools-0.6/#egg=setuptools-dev06

Step2: Download the tar.gz of trac from the URL http://trac.edgewall.org/wiki/TracDownload

Step3: Uncompress the tar.gz file

tar -xzvf   Trac-0.11.2.tar.gz
cd   Trac-0.11.2

Step4: Now copy ez.setup.py file to Trac-0.11.2 folder and make that script executable

cp ez.setup.py /Trac-0.11.2
cd /Trac-0.11.2
chmod 755   ez.setup.py

now execute it

python ./ez.setup.py

It will automatically  download and install the setuptools.

Now run the
setup.py script

python ./setup.py install

Step5: Now initialize your project varibales by executing the following command.

trac-admin /path/to/project initenv

First give the name to your project whatever you want and then accept all the default options.

Step6: Now initialize the tracd deamon

tracd –port 8000 /path/to/project_dir/

If you want user base authetication on your wiki then setup apache style authetication by adding up user using htpasswd command

htpasswd -c /path/to/project_dir/.htpasswd username

You can add the administrator user by the following command:

trac-admin /path/to/project_dir/ permission add administrator  TRAC_ADMIN

If you are not adding any administrator user then anyone can edit your wiki text. Administrator can give different rights to different users.

Then startd the tracd deamon

 /usr/bin/tracd -p 8000 --basic-auth=Project_name,/path/to/project_dir/.htpasswd,
/path/to/Project_dir /path/to/project_dir/ -d 

Posted in Linux.




I'm happy to use Increase Sociability.