Saturday, August 22, 2009

Using APT Offline

Overview

APT being available on both machines gives the simplest configuration. The basic idea is to place a copy of the status file on the disc and use the remote machine to fetch the latest package files and decide which packages to download. The disk directory structure should look like:

/disc/
archives/
partial/
lists/
partial/
status
sources.list
apt.conf

The configuration file

The configuration file should tell APT to store its files on the disc and to use the configuration files on the disc as well. The sources.list should contain the proper sites that you wish to use from the remote machine, and the status file should be a copy of /var/lib/dpkg/status. Please note, if you are using a local archive you must use copy URIs, the syntax is identical to file URIs.

apt.conf must contain the necessary information to make APT use the disc:

APT
{
/* This is not necessary if the two machines are the same arch, it tells
the remote APT what architecture the Debian machine is */
Architecture "i386";

Get::Download-Only "true";
};

Dir
{
/* Use the disc for state information and redirect the status file from
the /var/lib/dpkg default */
State "/disc/";
State::status "status";

// Binary caches will be stored locally
Cache::archives "/disc/archives/";
Cache "/tmp/";

// Location of the source list.
Etc "/disc/";
};


More details can be seen by examining the apt.conf man page and the sample configuration file in /usr/doc/apt/examples/apt.conf.

On the remote Debian machine the first thing to do is mount the disc and copy /var/lib/dpkg/status to it. You will also need to create the directories outlined in the Overview, archives/partial/ and lists/partial/ Then take the disc to the remote machine and configure the sources.list. On the remote machine execute the following:

# export APT_CONFIG="/disc/apt.conf"
# apt-get update
[ APT fetches the package files ]
# apt-get dist-upgrade
[ APT fetches all the packages needed to upgrade your machine ]



The dist-upgrade command can be replaced with any-other standard APT commands, particularly dselect-upgrad. You can even use an APT front end such as dselect However this presents a problem in communicating your selections back to the local computer.

Now the disc contains all of the index files and archives needed to upgrade the Debian machine. Take the disc back and run:


# export APT_CONFIG="/disc/apt.conf"
# apt-get check
[ APT generates a local copy of the cache files ]
# apt-get --no-d -o dir::etc::status=/var/lib/dpkg/status dist-upgrade
[ Or any other APT command ]


It is necessary for proper function to re-specify the status file to be the local one. This is very important!

If you are using dselect you can do the very risky operation of copying disc/status to /var/lib/dpkg/status so that any selections you made on the remote machine are updated. I highly recommend that people only make selections on the local machine - but this may not always be possible. DO NOT copy the status file if dpkg or APT have been run in the mean time!!


Source www.fifi.org

Wednesday, August 19, 2009

setting up moin moin wiki

Install Required Packages
Required packages are as follows:
python-moinmoin (Which should point to the proper python version)
apache2 webserver
sudo apt-get install python-moinmoin
sudo apt-get install apache2

Create a Wiki With "wikiname"
Create a wiki called "wikiname" and set the permissions.


cd /usr/share/moin
sudo mkdir wikiname
sudo cp -R data wikiname
sudo cp -R underlay wikiname
sudo cp server/moin.cgi wikiname
sudo chown -R www-data.www-data wikiname
sudo chmod -R ug+rwx wikiname
sudo chmod -R o-rwx wikiname


Configure MoinMoin to Locate "wikiname"
Relevant MoinMoin config files are located in /etc/moin/
Edit /etc/moin/farmconfig.py, and after the line "wikis = [" add your "wikiname". For a single instance wiki, this would entail renaming the following line from:
("mywiki", r".*"),

to
("wikiname", r".*"),

Copy the /etc/moin/mywiki.py file to /etc/moin/wikiname.py:
sudo cp /etc/moin/mywiki.py /etc/moin/wikiname.py

Edit the /etc/moin/wikiname.py and change all instances of mywiki to wikiname. In addition to this, change the data dir to point to your local installation of MoinMoin:
data_dir = '/usr/share/moin/wikiname/data'

Note :- You can simply copy the data directoy of old wiki to the above set folder to get the pages from the old pages to the newly installed wiki
Make apache ready for your wiki
Insert into /etc/apache2/sites-available/default (inside of the "" tag)
### moin
ScriptAlias /wikiname "/usr/share/moin/wikiname/moin.cgi"
alias /wiki "/usr/share/moin/htdocs"
alias /moin_static171 "/usr/share/moin/htdocs"

Order allow,deny
allow from all

### end moin

Restart apache to apply your changes:
sudo /etc/init.d/apache2 restart

See if it works
Go to your wiki's homepage:
http://127.0.0.1/wikiname Or try the test command:
http://127.0.0.1/wikiname?action=test
Security
You should probably set up PasswordProtectedEditing and investigate other security stuff: SecurityPolicy.
Troubleshootings
Server Name warning
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
http://wiki.apache.org/httpd/CouldNotDetermineServerNamehighlight=(ServerName)

Solution:
Add in /etc/apache2/apache.conf the following: ServerName
Where is your actual host name, like www.google.com or IP like 89.234.12.45

Tuesday, August 18, 2009

Use Mutt with Gmail

================
Introduction
================

This page is a guide to using the email client Mutt to send, receive and read email under Ubuntu using a Gmail account as a relay. It has been tested and extensively used under Ubuntu Intrepid Ibex. There are a few steps involved but if followed carefully and in sequence you will soon be using Mutt successfully with your Gmail account.

In sequence we will:

1. Introduce John!
2. Introduce vim
3. Set up SSL
4. Set up msmtp
5. Set up Fetchmail
6. Set up Procmail
7. Set up Mutt


=====================
1. Introducing John ...
=====================

To avoid confusion in editing the many configuration files involved in this setup I will describe the setup of mutt and gmail for my new friend John, who has been borrowed from this guide's big brother. John's details are as follows:

Code:

Gmail Address: john.example@gmail.com
Gmail Password: rover
Computer Username: john

John's details will always be in italics, bold and in red to remind you, Gentle Reader, to substitute your details for his. Hopefully this will lessen the confusion that I have unintentionally created with older versions of this page!

Now to introduce one of my best friends: vim...

=====================
2. Introducing vim ...
=====================

I have been somewhat taken to task for throwing vim into this guide without too much warning, for which my apologies to all. vim is the text editor that I feel suits mutt the best but a little preparation is a good idea before launching straight into it. Download vim from the repository as follows:

Code:

sudo apt-get install vim


and once vim is installed run through the builtin tutorial by simply running:

Code:

vimtutor


It may take a little time to come to grips with this great editor but trust me it is time well spent. For those who find it all a little hard there is always nano or pico!

Now lets get started with SSL:

============
3. SSL Tools
============

Gmail uses the POP3-over-SSL protocol to protect the transmission of username and password over the Internet. You will need to install both open SSL and a certificate pack from the repository as follows:

Code:

$ sudo apt-get install openssl ca-certificates


Later you will need to add the necessary SSL instructions to Fetchmail, but the next step is to install the software to send mail from your computer to the server: ssmtp.

=========
4. msmtp
=========

msmtp is a great and wonderfully reliable way to move mail from your computer. Download it from the repository as follows:

Code:

$ sudo apt-get install msmtp


There is a single configuration file to be altered: $HOME/.msmtprc. It can be created and permissions set as follows:

Code:

$ touch $HOME/.msmtprc
$ touch $HOME/.msmtp.log
$ chmod 0600 $HOME/.msmtprc


Below is the required configuration for a Gmail server:

Code:

account default
host smtp.gmail.com
port 587
from john.example@gmail.com
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
auth on
user john.example
password rover
logfile ~/.msmtp.log


Now to setup Fetchmail:

============
5. Fetchmail
============

Fetchmail is great tool to download mail from Gmail. Download it from the repository as follows:

Code:

$ sudo apt-get install fetchmail

Once again a single configuration file is required and so you will need to create ~/.fetchmailrc as follows:

Code:

$ vim ~/.fetchmailrc


The following configuration allow Fetchmail to access and fetch email from Gmail, leave a copy of the mail on the Gmail server and pass the mail to Procmail on your local machine. The SSL configuration is included here as well:

Code:

poll pop.gmail.com
with proto POP3
user 'john.example@gmail.com'
there with password 'rover'
is 'john' here
mda "/usr/bin/procmail -d %T"
options
no keep
ssl
sslcertck
sslcertpath /etc/ssl/certs


All done except as a final touch, since the username and password are openly in this file,you will need to make the file readable only by the file owner. If this is not done Fetchmail will not even run:

Code:

$ chmod 600 ~/.fetchmailrc


Now would be a good to time to make sure you have POP forwarding enabled in your Gmail account. You will find this in: Settings - Forwarding and POP. Note also that Gmail has a little oddity in regard to the "keep" and "nokeep" command of Fetchmail. You cannot remove mail from Gmail servers via POP3 but you can choose to have your messages archived, kept or deleted once they have been downloaded via POP3. This is a Gmail setting hidden in Settings - Forwarding and POP: "When messages are accessed with POP...".

Now for the mail delivery program Procmail:

===========
6. Procmail
===========

Procmail is great sorting tool for use with any mail setup. It can be easily downloaded from the repository:

Code:

$ sudo apt-get install procmail


So where will Procmail deliver to? Traditionally all mail goes to the location specified in the $MAIL environment variable, but in a default Ubuntu system this is often not set. Set the MAIL variable by opening ~/.bashrc as follows:

Code:

$ vim ~/.bashrc


and adding the following, using your own username:

Code:

# Sets the Mail Environment Variable
MAIL=/var/spool/mail/john && export MAIL


A very simple configuration file must be created for procmail as follows:

Code:

$ vim ~/.procmailrc


and below is a very simple start to what can be quite a complex file:

Code:

# Environment variable assignments
PATH=/bin:/usr/bin:/usr/local/bin
VERBOSE=off # Turn on for verbose log
MAILDIR=$HOME/Mail # Where Procmail recipes deliver
LOGFILE=$HOME/.procmaillog # Keep a log for troubleshooting.
# Recipes
:0:
* ^TOmutt-user
mutt



I include a very simple sorting recipe with the file: this one intercepts everything addressed to "mutt-user" and directs it to $HOME/Mail/mutt. This is the mutt-user mailing list which I would advise all new mutt users to join. And lets not forget to create the Mail folder:

Code:

$ mkdir $HOME/Mail


Now finally to Mutt.

=======
7. Mutt
=======

Mutt is one of the truly great pieces of software under Linux. The following command downloads Mutt from the Ubuntu repository:

Code:

$ sudo apt-get install mutt


Mutt is driven by a configuration file that can be created as follows:

Code:

$ vim ~/.muttrc


I have spent some time building this file from scratch but for you, Gentle Reader, I include here a more basic version, similar to the one I started from:

Code:

#======================================================#
# Boring details
set realname = "john"
set from = "john.example@gmail.com"
set use_from = yes
set envelope_from ="yes"
set sendmail="/usr/bin/msmtp"

# If not set in environment variables:
set spoolfile = /var/spool/mail/john

#======================================================#
# Folders
set folder="~/Mail" # Mailboxes in here
set record="+sent" # where to store sent messages
set postponed="+postponed" # where to store draft messages
set move=no # Don't move mail from the spool.

#======================================================#
# Watch these mailboxes for new mail:
mailboxes ! +Fetchmail +slrn +mutt
set sort_browser=alpha # Sort mailboxes by alpha(bet)

#======================================================#
# Order of headers and what to show
hdr_order Date: From: User-Agent: X-Mailer \
To: Cc: Reply-To: Subject:
ignore *
unignore Date: From: User-Agent: X-Mailer \
To: Cc: Reply-To: Subject:

#======================================================#
# which editor do you want to use?
# vim of course!
set editor="vim -c 'set tw=70 et' '+/^$' "
set edit_headers # See the headers when editing

#======================================================#
# Aliases

set sort_alias=alias # sort aliases in alpha order by alias name

#======================================================#
# Colours: This scheme is fairly basic and only
# really works if your Terminal background is white

color hdrdefault black default
color quoted red default
color signature brightblack default
color indicator brightwhite red
color attachment black green
color error red default
color message blue default
color search brightwhite magenta
color status brightyellow blue
color tree red default
color normal blue default
color tilde green default
color bold brightyellow default
color markers red default

#======================================================#
# Odds and ends
set markers # mark wrapped lines of text in the pager with a +
set smart_wrap # Don't wrap mid-word
set pager_context=5 # Retain 5 lines of previous page when scrolling.
set status_on_top # Status bar on top.
push # Shows mutt version at startup


Note: Procmail will create your mailbox in the spool, and set the appropriate permissions, when it first receives mail from fetchmail so don't worry that mutt cannot initially find this mailbox. If you wish to create the mailbox yourself the following permissions and ownership are required (taken from my own system):

Code:

-rw-rw---- 1 andrew mail 0 2008-10-23 10:12 /var/spool/mail/andrew


And finally it is reward time as you open Mutt, type ! to open a shell prompt, type fetchmail -v and start reading your mail! My parting gift is a little macro that was written for me by a generous person on the mutt-user mailing list that will actually do this for you when you simply press the key "I". Place the following in your ~/.muttrc file:

Code:

macro index,pager I ' fetchmail -v'


And welcome to the world of mutt!

source : ubuntu-forums

Friday, August 14, 2009

Creating Custom Ubuntu Live-CD With Remastersys

Remastersys is a tool that can be used to do 2 things with an existing Klikit or Ubuntu or derivative installation.It can make a full system backup including personal data to a live cd or dvd that you can use anywhere and install. It can make a distributable copy you can share with friends. This will not have any of your personal user data in it.

Install Remastersys in Ubuntu

The Remastersys repository needs to be added to your /etc/apt/sources.list

sudo vi /etc/apt/sources.list


Paste the following into the sources.list:

# Remastersys
deb http://www.remastersys.klikit-linux.com/repository remastersys/


Save and exit the file.

Update the source list using the following command

sudo apt-get update


Install remastersys using the following command

sudo apt-get install remastersys


This will complete the installation

Using Remastersys

In order to learn how you can use remastersys, run

sudo remastersys


remastersys Syntax

sudo remastersys backup|clean|dist [cdfs|iso] [filename.iso]


remastersys Examples

1) to make a livecd/dvd backup of your system

sudo remastersys backup


2) to make a livecd/dvd backup and call the iso custom.iso

sudo remastersys backup custom.iso


3) to clean up temporary files of remastersys

sudo remastersys clean


4) to make a distributable livecd/dvd of your system

sudo remastersys dist


5) to make a distributable livecd/dvd filesystem only

sudo remastersys dist cdfs


6) to make a distributable iso named custom.iso but only if the cdfs is already present

sudo remastersys dist iso custom.iso


cdfs and iso options should only be used if you wish to modify something on the cd before the iso is created. An example of this would be to modify the isolinux portion of the livecd/dvd

Creating An ISO Image

To create an iso image of your installation, simply run

sudo remastersys dist


This will create an iso image called customdist.iso in the /home/remastersys directory. The dist option makes that your personal folder (e.g. /home/ruchi) will not be included in the iso image. You might have to insert your Ubuntu installation CD during the process.

This is how the end of the process looks:

[...]
92.16% done, estimate finish Wed DEC 28 15:31:25 2007
93.39% done, estimate finish Wed DEC 28 15:31:25 2007
94.62% done, estimate finish Wed DEC 28 15:31:24 2007
95.85% done, estimate finish Wed DEC 28 15:31:24 2007
97.08% done, estimate finish Wed DEC 28 15:31:25 2007
98.31% done, estimate finish Wed DEC 28 15:31:25 2007
99.54% done, estimate finish Wed DEC 28 15:31:25 2007
Total translation table size: 2048
Total rockridge attributes bytes: 3950
Total directory bytes: 9094
Path table size(bytes): 54
Max brk space used 0
406890 extents written (794 MB)


/home/remastersys/customdist.iso is ready to be burned or tested in a virtual machine.

Check the size and if it is larger than 700MB you will need to burn it to a dvd

796M /home/remastersys/customdist.iso

Clean Up

After you’ve burnt the iso image onto a CD/DVD, you can run

sudo remastersys clean


to remove all temporary file created during the iso generation as well as the /home/remastersys directory.


also read: Click here

Wednesday, August 12, 2009

Did you know... ?

Did you know...

A video about how quickly the technological development is happening. Interesting, but also kind of scary.

Thursday, August 6, 2009

HOWTO Restore GRUB

You have windows 98 and linux on the same hard disk and you choose GRUB as boot loader.At boot time you see a menu to choose windows or linux.
But one day you reinstall windows 98 and it rewrites your MBR and the menu has gone, now you only can boot windows.

What to do:
Put the redhat boot disk you created on the installation on the floppy drive, boot the system and run grub command

Remember that for grub (hd0,1) means hda (primary controller master), second partition.

Now we need to tell grub where are the grub files:

If you know where they are, type something like:
root (hd0,1)


else if you have no idea, type:
find /boot/grub/stage1

and then the root command with the correct parameters:

setup (hd0)

to install it on hd0, that is MBR of the first HD.

type quit and reboot.
The menu will appear again.
If you want to make some changes to the boot menu, you must edit the file: /boot/grub/menu.lst

A sample menu.lst file is this:

default=0
timeout=5
splashimage=(hd0,1)/boot/grub/splash.xpm.gz

title Red Hat Linux (2.4.18-14)
root (hd0,1)
kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/ hdc=ide-scsi
initrd /boot/initrd-2.4.18-14.img
title Red Hat Linux (2.4.18-openmosix3)
root (hd0,1)
kernel /boot/vmlinuz-2.4.18-openmosix3 ro root=/dev/hda2 hdc=ide-scsi
initrd /boot/initrd-2.4.18-openmosix3.img
title WindowsME
rootnoverify (hd0,0)
chainloader +1