Wednesday 18 June 2014

secrets of debconf-finally revealed

This is a simple walkthrough of Debconf, go through each and every step carefully, soon you will be using it without any trouble. Best of Luck.
--What is Debconf ? Debconf is a backend database, with a frontend that talks to it and presents an interface to the user. There can be many different types of frontends, from plain text to a web frontend. The frontend also talks to a special config script in the control section of a debian package, and it can talk to postinst scripts and other scripts as well, all using a special protocol. These scripts tell the frontend what values they need from the database, and the frontend asks the user questions to get those values if they aren't set.
Confusing ? Let's go through the three files-config,template and script.
--Template
It contains all the notes, different questions you want to ask the user, be it boolean(true/false), multiple answer, string inputs, displaying notes, everything you want to display or ask the user. P.S. :make sure you leave a space in the begining of the Long Description, check the file in case you have any doubt.
--Config
Next, decide what order the questions should be asked and the messages to the user should be displayed from the template file we talked about earlier. Config script does all this, it has no other job than to display notes and questions from template file and take input from the user in the form of answers to the question it asked.
--Script
The job of this script is to use the input stored in debconf database. It all depends how you want to use the inputs, I jave just printed the inputs stored.
--Where to find the Debconf database ?
/var/cache/debconf/config.dat config.dat stores all the template questions, notes everything you stored in the template file once you have run the config script.
--How to run the scripts ?
  1. Change the permssion of the scripts to executable.
  2. run the first script "sudo ./config" .You need to use sudo inorder to make changes to the debconf database.
  3. run the second script "sudo ./script".
P.S. : The first script would run for only one time as after running if on the first time the flag in the debconf database gets set or "seen", but you can run the second script(script) any number of time. If you want to run the first script(config) again, do the following:
$ sudo gedit /var/cache/debconf/config.dat
and search the template you created and remove "seen" from all the flags of your templates, once you have deleted seen, you can run the config script again.
--That's all for the debconf, best of luck again and enjoy your experience.

MongoDB- Address already in use for socket

Open Terminal and run the following command:
sudo mongod


The following error in the port being used is thrown
[websvr] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:28017
[initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
[websvr] ERROR:   addr already in use
[initandlisten] ERROR:   addr already in use
[initandlisten] now exiting
dbexit:
[initandlisten] shutdown: going to close listening sockets...
[initandlisten] shutdown: going to flush diaglog...
[initandlisten] shutdown: going to close sockets...
[initandlisten] shutdown: waiting for fs preallocator...
[initandlisten] shutdown: closing all files...
[initandlisten] closeAllFiles() finished
[initandlisten] shutdown: removing fs lock...
dbexit: really exiting now
Run the following command to check the mongo processes/
ps -eF | grep 'mongo\|PID'

UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
mongodb    1024     1  0 24077 13052   1 19:09 ?        00:00:05 /usr/bin/mongod --config /etc/mongodb.conf
 
1000      2814  2752  0   832   884   0 19:33 pts/1    00:00:00 grep --color=auto mongo\|PID
 
 
the problem is with the process with id 1024 , use the following command
___________________________________________________
sudo kill 1024
 ___________________________________________________
Try running mongodb again with the following commabd.

sudo mongod
[initandlisten] MongoDB starting...
[websvr] admin web console waiting for connections on port 28017
[initandlisten] waiting for connections on port 27017