Archive forTechnology

Setup WebDAV with Apache

This is a small tutorial in setting up WebDAV with Apache2. I have implemented it on Centos 5.0.

WebDAV – Web-based Distributed Authoring and Versioning, allows one user to edit the files directly on the server rather than downloading and then uploading the files to the server. Install `apache` web server. Just need to make some changes in the `httpd.conf` file.

Enable the following modules in the `httpd.conf` file.


LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so

Noe, you need to create the directory where you want users to upload the files. Suppose I assume that you have a partition `/data` on the server.

root@ophiophagus:~#mkdir backup <- inside the /data partition.

Ensure that the ownership for the /data parition is `apache`.

Now you need to create a virtual host entry for the `WebDAV`. Before that, create the WebDAV username/password file.

root@ophiophagus:~#htpasswd -c /data/backup/passwd.dav testuser

Change the ownership as well as the permission of the file. Now create a virtual host entry for the directory.

<VirtualHost *:80>
ServerName ophiophagus.blog.co.in
ServerAdmin prasanta@ophiophagus
DocumentRoot /data/

<Directory /data/>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

Alias /backup /data/backup
<Location /backup>
DAV On
AuthType Basic
AuthName “Admin Server”
AuthUserFile /data/backup/passwd.dav
Require valid-user
</Location>
</VirtualHost>

Just reload `httpd`.

There is a utility tool for testing WebDAV from command line. Download and install and application called `cadaver`.

prasanta@ophiophagus:~$cadaver http://ophiophagus.blog.co.in/backup/
Authentication required for webdav on server `Admin Server’:
Username: testuser
Password:
dav:/webdav/> ls

This will list the files which are there in the particular directory.

Note: I am still looking for a option to limit the user file upload, depending upon the file type extension, but I still not able to figure this out.

Comments

A day with Openfiler

I needed some sort of shared system wherein user’s can dump there data, with access restrictions. I had two options in mind. Go for a branded NAS box or bring some NFS/SMB from scratch. So as always, did a Google search for some open source product. I bumped into FreeNAS and Openfiler. Om Google -ai Namah. I thought of giving Openfiler a shot.

Openfiler is an Open Source Network Attached Storage and Storage Area Network Solution. It is a distribution which is built on top of Red Hat and is available as an installable iso. I looked for rpm’s also, but I was unable to find it. However got it installed in one of the machine.

The installation is as simple as installing any other Red Hat distro. Screen shots were also available showing each and every step of the installation. Both version of the installation exists, text based as well as gui based. So there should not be any problem with the installation. The only difference with that to the ones shown in the docs, was that I made was installing it on top of RAID1. After all the installation was done, one just opens the browser and gives the url as listed in the document. Openfiler runs in port 446 by default.

Now comes the part of creating shared folders to be used for data dumping. I was unable to create any volume/shared space using the GUI interface. The administrator guide is not available for the public. One needs to pay to get it. So back to old strategy of using irc. Since they already have a channel, why not hook into it and get the answers. I got myself hooked into #openfiler and asked my doubts, but to my utter surprise no one responded. Logged out of it thinking that, these questions were dumbed enough not to be answered by the Openfiler community. I went through the forums which were quiet resourceful in terms of getting the doubts cleared compared to the irc.

Openfiler using LVM for data storage. So I used lvm from the CLI, for creating the partitions. (A good manual for using lvm can be found out at TLDP.)

[root@localhost etc]# pvcreate /dev/md6
Physical volume “/dev/md6″ successfully created

After the partition being created one can use the GUI for all the other stuff including creating shares, folders etc. The best part of the system is that, it can hook itself to the existing authentication system like LDAP, NIS etc. For other means of user control, one can limit the usage by binding the user to a particular machine etc.

I am still exploring the system, but frankly speaking it’s a worth, much better then the proprietary NAS/SAN solution that is available. Kudos to the Free Open Source Community.

Openfiler – http://www.openfiler.com
FreeNAS – http://www.freenas.org
TLDP – http://tldp.org/

Comments

Synchronize Google Calendar

Synchronization of Google Calendar with Mozilla Thunderbird Lightening works as a charm. Install Lightening, which is an add-on for Mozilla, for the calendar part. But this will not give a bi-directional access for Google Calendar. So, you need to install one more add-on called Provider for Google Calendar. Set up proxy server in case your network requires the same else nothing to do with the preferences.

I have set-up CalDAV as per below,

1. Open the Lightening application and Calendar > New Calendar.
2. Select On the Network and click Next.
3. In the format option select the CalDAV option.
4. In the Location field, enter [ https://www.google.com/calendar/dav/ [ your Google Calendar ID ] /events ] and click Next. eg. [https://www.google.com/calendar/dav/ophiophagus.blog@gmail.com/events]. Be sure to use https in your URL, as an http address will not work.
5. Enter a name and select a color for your calendar.

Click on the Reload icon/button. A pop up screen will be shown for entering the user name/password. User name consists of the whole email address, eg. ophiophagus.blog@gmail.com. Enter the password and you are able to see the sync between the two calendar’s.

Comments

National Knowledge Network

NKN = National Knowledge Network

I had the privilege to attend the workshop on NKN that was held today at National Informatics Centre, HQ, Delhi. It was a small gathering of about 63 people from all the top notch institutes including IIT, CSIR lab’s etc. The workshop was to brief about what is NKN and it’s overall benefits. For more information pertaining to NKN can be found here.

Comments (1)

Reset MySQL Password

Oops! forgot your MySQL root user password. No need of panicking. There are ways through which one can retrieve the password. Just try to follow the below mentioned steps. This has worked for me in a RHEL 8.

1. Login as root user to your machine.

2. Stop/Kill all the mysql daemon/processes.

[root@localhost root]# kill -9 `ps aux | grep mysql | cut -c10-14`

3. Restart MySQL server with these parameters

[root@localhost root]# mysqld –skip-grant-tables –user=root

4. Manually set root password in the table “user” of “mysql” database.

[root@localhost root]# mysql

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1 to server version: 3.23.41
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.

mysql> USE mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed

mysql> UPDATE user SET password=password(”newpassword”) WHERE user=”root”;

Query OK, 2 rows affected (0.04 sec)
Rows matched: 2 Changed: 2 Warnings: 0

mysql> exit;

[root@localhosthost root]# kill -9 `ps aux | grep mysql | cut -c10-14`

5. Restart MySQL daemon again.

Viola, you are able to login as the root user to the MySQL database.

Comments

MySQL database backup using PHP

Well, I went through a lot of articles with respect to the above mentioned topic, but I was unable to find one which I really wanted. Most of the articles informs you how to backup the data and send a mail to the user from where they can download the archived file.

My requirement was to download the archived file at the click of the button without sending a mail to the end user. The user should be able to download the file from the browser interface.

require('../config/config.php');
if($_GET["filename"]!="")
{
$filename=$_GET["filename"];
$handle = @fopen($filename, 'r');
if (!$handle) {
exit(0);
}
$time= date('Ymd');
header("Content-type: application/force-download");
header("Content-Disposition: attachment; filename=psp-".$time.".zip");
while(!feof($handle) and (connection_status()==0)) {
print(fread($handle, 1024*8));
flush();
}
fclose($handle);
}
else
{
system("mysqldump -u $dbusername --password=$dbpasswd psp > /tmp/psp.sql");
system("cd /tmp;zip -r psp psp.sql >/dev/null");
header( "Location: http://$domainname/custom/mysqlbackup.php?filename=/tmp/psp.zip"););
}

`config.php` includes all the configuration parameters for connecting to the database. Since we are using a single file for posting, we check in the `url` whether the file name has been passed or not. In case the file name has been passed, we add headers to the content-type for download. You need change the download filename. As per my requirements I have used `psp` followed by the date when the download takes place.

I have used `mysqldump` for backing up the database. This is not an efficient way of taking a backup since the `username` and the `password` are sent across the network in plain text. Any user using a network sniffing tool can get hold of the `username` and the `password`. I preferred to use in this way as my script is not exposed to the internet. The last line indicates the reloading of the same page with the archived file name.

Comments

Creating/Deleting Software RAID-1 using mdadm

`mdadm` – manage MD devices aka Linux Software Raid (directly from `man` pages)

1. Finding out the RAID arrays (md0, md1, etc..). In all the below examples I have taken `md0` as the RAID array.

[root@library-server ~]#fdisk -l

2. Querying the arrays to find the disks it holds,

[root@library-server ~]#mdadm – -detail /dev/md0

3. Shutting the desired array,

[root@library-server ~]# mdadm – -stop /dev/md0

4. Zeroing the superblock for each drive,

[root@library-server ~]# mdadm – -zero-superblock /dev/sdX (or hdX)

5. Creating the new array,

[root@library-server ~]#mdadm – -create /dev/md0 – -chunk=4 – -level=0 – -raid-devices=2 /dev/sda1 /dev/sdb1

where sda1 and sdb1 are the partitions. The above command will create a raid0 array /dev/md0 formed from /dev/sda1 and /dev/sdb1, with chunk size 4.

6. Create an ext3 filesystem on /dev/md0,

[root@library-server ~]#mkfs.ext3 /dev/md0

Mount this partition and you are ready to push in your data. This above method worked for me. Hope this helps.

Oops, forgot to include one line in /etc/mdadm/mdadm.conf,

ARRAY /dev/md0 devices=/dev/sda1,/dev/sdb1

where `md0` – array defined and `sda1`, `sdb1` are the hard disk partitions from where the array is created. Restart the `mdadm` service.

Comments (1)

Bajaj Platina 125 cc

Finally, after going over all through the specs of different bikes along with their comparisons, I gifted myself a new bike on the 2nd of Jan 2009, a Bajaj Platina 125 cc with DTSi technology.

There weren’t much reviews of this one as it was hardly 2 months old with it’s first release. I thought of taking a chance. The on road price for the bike is Rs 46000/- in Bangalore along with the tax and everything.

Bike

My experience with my bike:

Pros:
1. Pickup is up to the mark and is good.
2. Look wise also it is good.
3. Mileage is also good. In the initial week, though it gave 60 kmpl, after the first service it went to 70 kmpl.
4. Light in weight and as such it adds to the mileage.

Cons:
1. Shifting of gears is somewhat problematic, maybe being a new bike. And after the first service the problem was solved. It seems that it is a common problem as the moment I mentioned to the service person, he automatically said 2nd gear :-)
2. Tyres are less in width.
3. Somewhere in the highway I felt the need for the 5th gear.
4. Max speed of 95 kmph.

Rest are as per the Bajaj website. The base is that if you want a good 125 cc bike you can buy it. It’s worth the money.

Comments

Megapixel myth?

The very first impression that comes to the mind is, the greater the mega pixel of a device the better will be the picture quality. Is that true or is that what we have been fed with this myth? This is the fact which I also came to know about it very lately. I was also under the same impression that the higher the mega pixel the better the quality. But I had to do some research before advising one of my friends to buy a digital camera. And so it all started.

So what camed out was the fact that mega pixels have nothing to do with image quality. Cramming more mega pixels into a smaller image sensor can even lead to reduced picture quality.

Before buying, one should always check out for the optical zoom (the more the better), LCD (size, quality), optical viewfinder (useful to frame photos in bright sunlight) and video recording (should be at least VGA quality @ 30 fps). Along with the above take a note of the battery type, the accessories (lens, flash, remote) and the manual modes. Ensure that the buttons are freely accessible as smaller cameras have really tiny and hard-to-use buttons.

Cameras with touchscreen LCD’s reduce the number of buttons, but attract a lot of fingerprints. Also check if the responsiveness of the screen is good enough.

There are different terms (in layman’s language, to impress the features) that are used to sell the camera’s.

CCD/CMOS (charge coupled device/complementary metal oxide semiconductor): The type of image sensor used in a digital camera.

Digital zoom: This type of zoom digitally enlarges a portion of the image to make it appear bigger/closer.

Image stabiliser: A technology/mechanism by which camera shake is automatically countered (to a certain degree). It can be electronic or optical. Electronic is cheaper, not as effective.

ISO/ASA (Industry Standards Organization or American Standards Association): Denotes sensitivity to light, assigned to a number. Higher ISO/ASA means greater sensitivity and vice versa. It can help reduce camera shake, and can also lead to increased image noise.

Optical zoom: Refers to the use of movable lens elements to bring an object closer. Look for optical zoom figure, not the digital zoom. That is the base of it.

Comments

Debian on Compaq Armarda 1500C

Compaq Armada 1500C? What is this? A jeep with 1500 cc cylinders? Ha ha ha. Nope, it is a Pentium II series notebook with 366Mhz processor, 12.1 Inch Display, 4 GB HDD, 32MB RAM, 24X CD-ROM and 56K Modem. A bulky piece compared to today’s one. Technology has changed drastically and so has the gadgets.

This antique piece was their for re-installation of the OS. And guess what is was running, our dear own M$ 98, which sucks. The first impression that came in my mind was, why not scrap this laptop? It would do no good to itself, with installing M$ on it. But behind my mind I thought why not install Debian and check it once. So, all set to work.

Downloaded the Debian Net Installer ISO and burnt it in the CD. CD-ROM taking it’s own sweet time to read the files from the CD. But finally was able to install it. Took almost one hour for installation. Checked the hard disk space it occupied, aila only 356 MB with no GUI and the most important the modem is detected and you can use it out of the box. apt also works. So all set to install the X window. Thought of many options but finally decided to install Xfce. So after installing the disk space consumed was less then 800MB and you had 3 GB of space left for your work. Woh! good great. Had a beast tamed with Debian. :-)

Comments

Next entries »