Archive forTechnology

Bluetooth headphone with Ubuntu Jaunty

Well, I recently got a pair of Dell Bluetooth headphone and was trying to use with Ubuntu 9.04 on my laptop. I went through the forums which suggested a lot of things, but this are the steps that really worked for me. I am summarizing the steps that were involved in pairing the headphone with the laptop. Before using the below, please install `pulseaudio` server.

prasanta@ophiophagus:~$ sudo apt-get install pulseaudio

1. Turn on the headset in pairing mode.
2. Open the terminal and use the following commands,

prasanta@ophiophagus:~$ hcitool scan
Scanning …
00:16:44:21:D5:4F Dell

4. Create a .asoundrc file in your home directory,

prasanta@ophiophagus:~$ emacs -nw .asoundrc
pcm.btheadset {
type bluetooth
device 00:16:44:21:D5:4F
profile “auto”
}

5. Enable bluetooth headphone to get the audio,

prasanta@ophiophagus:~$ sudo hciconfig hci0 voice 0×0060

6. Now we need to tell PulseAudio for the existence of the bluetooth headphone for sinking output.

prasanta@ophiophagus:~$ pactl load-module module-alsa-sink device=btheadset

7. Once pairing has completed, we can now test to see if we can send audio to the headset. In your terminal, type in the following:

prasanta@ophiophagus:~$ aplay -D btheadset -f s16_le /usr/share/sounds/ubuntu/stereo/dialog-question.wav

Note: it will play only .wav files. It does not play .ogg files.
8. Install PulseAudio Preferences, the PulseAudio Manager and the PulseAudio Device Chooser application.

prasanta@ophiophagus:~$ sudo apt-get install paprefs paman padevchooser

9. Once everything is installed, go to
`Applications->Sound & Video->PulseAudio Device Chooser. `
This will add a black microphone jack icon to your system tray.
10. Do a left-click on the jack icon and a menu appears. In this menu, choose “Manager”. A new window appears. If it’s not already connected, click on the “Connect” button to connect to your local PulseAudio server. When connected, you will see details about it listed.
11. Click on the Devices tab. Under “Sinks” you should see an entry for “alsa_output.btheadset”. This is picked up directly from your .asoundrc file.
12. Now go to the Sample Cache tab. You are shown a list of sounds. Choose a WAV file from this list (it won’t play any other format). At the bottom is a “Playback on” drop-down. Choose “alsa_output.btheadset” from this list and click on the Play button. You should hear the Ubuntu “login ready” sound through your speakers. This proves to us that PulseAudio can play through your Bluetooth headpone (but this is NOT the redirection – this is just a test).
13. Close the PulseAudio Manager.
14. Do another left-click on the mic jack icon in your system tray.
15. Go to “Default Sink” and then choose “Other” from the sub-menu. A window appears. In this window, type in “alsa_output.btheadset” and click OK.

Woh! you are ready to rock.

To switch back to your speakers, simply click on the mic jack icon again, choose “Default Sink” and choose “Default” from the sub-menu. The next audio stream played will go back through your speakers.

Note: When you try to reload the module, it gives out an error, Module Authorization Failed. After unloading the modules it works, but most of the times it does not.

I am not able to go around this problem even after restarting bluetooth. Hope to find a solution.

Tutorials:
http://bluetooth-alsa.sourceforge.net/build.html
http://forums.overclockers.com.au/showthread.php?t=780054

Comments

Server Uptime

A nice screen shot to be uploaded in the blog, as a sysadmin. Will keep it updated as days pass by.

screenshot

Comments

Hardware Information under Linux

For most of the time I have been using `lshw` (list hardware) happily under Ubuntu. But yesterday, I had a situation wherein I need to find out the hardware of the machine in Rocks Linux. I did not think of installing `lshw` on the machine, but wanted to find out whether there are other commands from where I can get the hardware information including BIOS. So after doing some  google search, came up with `dmidecode`.

`dmidecode` is a tool for dumping a computer’s DMI (Desktop Management Interface) table contents in a human-readable format. This table contains a description  of  the  system’s  hardware  components,  as well as other useful pieces of information such as serial numbers and BIOS revision.

Usage:

root@ophiophagus:~$ dmidecode -t
dmidecode: option requires an argument — t
Type number or keyword expected
Valid type keywords are:
bios
system
baseboard
chassis
processor
memory
cache
connector
slot

root@ophiophagus:~$ dmidecode -t bios < List BIOS information>

Use the above types for getting the hardware information for the machine.

Comments

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)

Next entries » · « Previous entries