Thursday, March 14, 2013

RubyOnRails - A few steps installing and creating first project

#Install MySql
yum grouplist | grep -i mysql
yum groupinstall "MySQL Database"

# If fail..........
vi /usr/bin/mysql_install_db  # edit hostname=127.0.0.1

# Start MySql....
usr/bin/mysql_install_db --user=mysql
service mysqld start
/usr/bin/mysqladmin version
/usr/bin/mysqlshow
mysql -u root

# Install RubyOnRails
wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
tar -zxvf yaml-0.1.4.tar.gz
cd yaml-0.1.4
./configure
./configure --prefix=/usr/local
make
make install

wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -zxvf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194
./configure
make
make install

# Check Ruby Version
ruby --version

# Install Rubygems
wget http://rubyforge.org/frs/download.php/76073/rubygems-1.8.24.tgz
tar -zxvf rubygems-1.8.24.tgz
cd rubygems-1.8.24
ruby setup.rb

# Check Gems Version
gem --version

# Install Rake
gem update --system
gem install therubyracer -v '0.9.8'
gem install rake
gem install rails

# Check Installed Gems
cd ..
gem list

# Create your first Application
rails new welcome -d mysql
cd welcome
rails generate controller welcome index
vi Gemfile # Add... gem 'therubyracer', require: "v8"
bundle install
rake db:create

# Configure route to access your first application
vi config/routes.rb # Uncomment root :to => 'welcome#index'

# Start rail server
rails server

# Check your application
http://127.0.0.1:3000/welcome/index


Wednesday, March 13, 2013

TataPhoton USB modem Configuration in RHEL5


Tata Photon Data card never get detected by RHEL-5 automatically. By default the device is available as "USB-storage (Mass Storage / SD Storage)”.  In RHEL5 even the device never initialized itself. In a dual booting system first we need to initialize the card in Windows and then restart the system (without power off) in Linux.Off course this is not the way of handling a device in RHEL, there must be some proper way, but at this moment I am unaware about that.

To get vendor ID and product ID use "lsusb" as a super user if data card is not detected by default.

#lsusb
Bus 003 Device 003: ID 12d1:140b
Bus 003 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 005 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000

For more details information use following command 
#lsusb -v | grep -B4 HUAWEI

Here the first number is vendor id (0x12d1) and the second one (0x0140b) is product id. These numbers may differ depending on the make and model of the device.

To get generic USB serial driver bind to the device, USB vendor and product IDs need to be specified as a parameter when the module “usbserial” is loaded. For example, to bind the previously described device with a vendor ID of 0x12d1 and product ID of 0x140b, execute following command as a super user

#modprobe usbserial vendor=0x12d1 product=0x140b

Now we need usb_modeswitch. If it is not installed yet, please install latest available package. usb_modeswitch can send bulk messages (most likely a mass storage command) to the device which is known to initiate the mode switching. 
#usb_modeswitch -v 0x12d1 -p 0x140b -H -W

Next we need to run WvDial command-line pppd driver. Wvdialconf generates  configuration file containing information of your modem and ISP details. To avoid changing configuration file parameters, let’s create a master copy of wvdial.conf file.

#cat wvdial.conf-master
[Modem0]
Modem = /dev/ttyUSB2
Baud = 115200
SetVolume = 0
Dial Command = ATDT
Init1 = ATZ
Init3 = ATM0
FlowControl = CRTSCTS
[Dialer tataphoton]
Username = internet
Password = internet
Phone = #777
Stupid Mode = 1
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Inherits = Modem0

[Dialer Defaults]
Modem = /dev/ttyUSB2
Baud = 460800
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Stupid Mode = 1
ISDN = 0
Modem Type = USB Modem
Phone = #777
Username = internet
Password = internet

Now execute following command to connect internet through the device.

#wvdialconf /etc/wvdial.conf
#wvdial

It’s better to bring all command together in a script and run the script to connect internet through Tata-Photon USB modem.

#!/bin/bash
modprobe usbserial vendor=0x12d1 product=0x140b
usb_modeswitch -v 0x12d1 -p 0x140b -d 1
usb_modeswitch -v 0x12d1 -p 0x140b -H 1
cp /etc/wvdial.conf-master /etc/wvdial.conf
wvdialconf /etc/wvdial.conf
wvdial