Membuat SMS Gateway dengan Gammu dan Wavecom Fastrack M1306B

Merasa terusik dengan kedatangan Modem Wavecom Fastrack M1306B yang barusan dibeli, hari ini menjelang malam 1 Suro pengen utak utik piranti tersebut. Awalnya ada beberapa kendala ketika saya jalankan di Windows dan Linux. Setelah dipelajari dengan melihat error yang ada ketemulah satu persatu jawaban tersebut. Berikut rangkuman yang saya peroleh dari internet juga, saya sederhanakan sesuai dengan kasus yang saya kerjakan. Tutorial ini sudah saya coba dibeberapa Sistem Operasi untuk melihat kesetabilan dari aplikasi yang dibangun dan untuk menguji device yang digunakan. Daftar sistem Operasi teruji antara lain : Windows XP, Windows 7 dan Linux Distro Ubuntu 10.04.

Sebelumnya saya membuat tutorial sms gateway menggunakan Gammu - Modem GPRS GSM. Sekarang saya menggunakan Modem Wavecom Fastrack. Meskipun harganya jauh lebih murah ( sekitar 650 rb) Modem Wavecom Fastrack sangat handal digunakan kalau hanya untuk SMS Server.

MODEM
Untuk membeli modem, pastikan bahwa dia menggunakan konektor USB. Bukan apa-apa, karena konektor USB lebih mudah kita gunakan.

















LANGKAH-LANGKAH KONEKSI

1. Download Gammu (saya menggunakan versi 1.30)
2. Ekstrak di direktory C:\Program Files\Gammu 1.30.0-Windows\
3. Colokkan GSM Modem ke USB Komputer.
  • Install Drivernya (untuk pemakaian diLinux.Device langsung bisa dikenali, sudah ditest di Ubuntu 10.04)
  • Cek Portnya

4. Konfigurasi


Cari file gammurc dan smsdrc yang ada di C:\Program Files\Gammu-1.30.0-Windows\share\doc\gammu\examples\config dan taruh di folder bin. Buka gammurc ubah arah portnya.
[gammu]
port = com16:;connection = irdaphonet
connection = at115200; Kecepatan koneksi default untuk device M1306B adalah at115200,saya coba pakai at19200 tidak bisa. Pastikan settingan dikecepatan at115200
;model = 6110
;synchronizetime = yes
;logfile = gammulog
;logformat = textall
;use_locking = yes
;gammuloc = locfile
;startinfo = yes
;gammucoding = utf8
;usephonedb = yes

5. Pasang Kartu GSM (jangan lupa sudah di registrasi dulu) 

pastikan anda didirektori bin gammu
Kalau IMEI nya muncul berarti sudah OK

6. Menyambungkan ke MYSQL

Jika ingin mengkoneksikan ke mysql, cari sql nya di dalam paket C:\Gammu-1.30.0-Windows\share\doc\gammu\examples\sql\

Install mysql.sql pada database mysql

Kemudian konfigurasikan smsdrc sbb (ganti bagian yang di cetak tebal):

# This is a sample Gammu SMSD configuration file. It's required for gammu-smsd,
# see gammu-smsdrc(5) for documentation.
# Gammu configuration, this section is like section "gammu" in "gammurc" file,
# see gammurc(5) for documentation.
[gammu]
port = com16:
connection = at115200

#model = 6110
#connection = dlr3
#synchronizetime = yes
#logfile = gammulog # this is not used at all in SMSD mode
#logformat = textall
#use_locking = yes
#gammuloc = gammu.us
#startinfo = yes
# When uncomment this section and insert numbers here, smsd will process
# incoming sms only from numbers written here (incoming sms from all other
# numbers will be deleted)
#[include_numbers]
#number1 = 1234
# When uncomment this section and insert numbers here, smsd will process
# incoming sms from all numbers not written here (incoming sms from numbers
# written here will be deleted). This is "black" list.
# Note: after using "include_numbers" section this one will be ignored
#[exclude_numbers]
#number1 = 1234
# General SMSD settings, see gammu-smsdrc(5) for detailed description.
[smsd]
# SMSD service to use, one of FILES, MYSQL, PGSQL, DBI
service = sql # pada versi 1.30.0 perbedaan dibanding penggunaan setting yang dulu tidak terletak disini yang semula MYSQL dirubah jadi sql
# PIN for SIM card
PIN = 1234
# File (or stderr, syslog, eventlog) where information will be logged
logfile = smsdlog
# Amount of information being logged, each bit mean one level
debuglevel = 0
# Configuration for using more phones on same database
#phoneid = MyPhone1
# Script to be executed when new message has been received
#runonreceive = /some/script
# Commication frequency settings
commtimeout = 30
sendtimeout = 30
#receivefrequency = 0
# Phone communication settings
#checksecurity = 1
#resetfrequency = 0
# Delivery report configuration
#deliveryreport = no
#deliveryreportdelay = 10
# Ignoring broken SMSC
#skipsmscnumber = +48602123456
# Database backends congfiguration
user = root
password = rahasia
pc = localhost

# pc can also contain port or socket path after colon (eg. localhost:/path/to/socket)
database = smsd
# DBI configuration
driver = native_mysql # pada versi 1.30.0 perbedaan dibanding penggunaan setting yang dulu tidak terletak disini yang semula sqlite dirubah jadi native_mysql
# driverspath = /usr/lib/dbd/
# Database directory for sqlite
# dbdir = /var/lib/smsd
# Files backend configuration
#inboxpath = /var/spool/sms/inbox/
#outboxpath = /var/spool/sms/outbox/
#sentsmspath = /var/spool/sms/sent/
#errorsmspath = /var/spool/sms/error/
#inboxformat = unicode
#transmitformat = auto

MENJALANKAN SEBAGAI SERVICE

Untuk menjalankan sebagai service, silahkan buka membuka  command prom dan ketikkan :
(gammuSMSD adalah nama service bisa anda ganti sendiri. tapi anda harus konsisten mengunakannya)
gammu-smsd -i -c smsdrc -n gammuSMSD
Untuk uninstall service
gammu-smsd -u -c smsdrc -n gammuSMSD
Untuk menjalankan service
gammu-smsd -s -c smsdrc -n gammuSMSD
Hasilnya silahkan lihat di service


MASALAH DI SERVICE

Secara native service berjalan otomatis, namun kenyataannya tidak demikian, service harus selalu dijalankan secara manual begitu komputer restart.

Untuk mengatasinya silahkan membuat file gammu.bat dan taruh di C:\Documents and Settings\All Users\Start Menu\Programs\Startup

Adapun isi file gammu.bat adalah sbb :
START /LOW C:\Program Files\Gammu 1.30.0-Windows\bin\gammu-smsd.exe -s -c C:\Program Files\Gammu 1.30.0-Windows\bin\smsdrc -n gammuSMSD
nb : penulisan port device pada OS Windows menggunakan huruf kecil : misal = com22: untuk penggunaan huruf besar OS Windows 7 tidak bisa baca device.

Menggunakan NuSOAP dalam PHP5-SOAP Enable dan Disable

Untuk NuSOAP dengan PHP5 yang SOAPnya masih On bisa juga digunakan NuSOAP tanpa harus medisable SOAP bawaan PHP5. yang harus dilakukan adalah 
  1. Rename class.soapclient.php menjadi class.soap_client.php
  2. Edit file nusoap.php dengan merubah isi file, rename soapclient menjadi soap_client

Untuk menggunakan NuSOAP dengan PHP5 (soap sudah disable). bisa menggunkan sample dan tutorial dari bang kurniawan dibawah ini :

Cara mudah untuk menggunakan fasilitas web service yang ada pada PHP5.
Pada dasarnya PHP5 sudah mendukung SOAP yang sudah ditambahkan dalam packege instalasinya pada saat kita install, entah itu di LAMPP, XAMPP atau aplikasi sejenis yang memudahkan kita memadukan WebServer dan Database Serta aplikasi PHP5.


Berhubung kemarin sempet dapat tugas Mata kuliah SIT (Sistem Informasi Terdistribusi) dan dapet jatah membahas Web service.. So, pada kesempatan ini saya mau share sedikit tentang apa itu Web Service dan bagaimana implementasi Web Service itu sendiri… :D . Oke, sebelum masuk ke Tutorial, let’s see.. apa itu “Web Service”.
Ok, jadi Web Service merupakan suatu sistem yang dirancang untuk mendukung interoperabilitas dan interaksi komunikasi antar sistem (aplikasi) dalam suatu jaringan. Web Service memungkinkan kita dapat mengakses informasi atau mendapatkan potongan informasi dari suatu aplikasi melalui aplikasi yang lain. Contoh mudahnya misal pada layanan yang terdapat di Facebook atau Twitter. Kita (user) dapat mengakses dan berinteraksi dengan Facebook atau Twitter baik melalui website (facebook.com / twitter.com) atau melalui aplikasi-aplikasi daripihak ketiga seperti Aplikasi Facebook yang ada di Ponsel, Aplikasi seperti TwitDeck, Yoono dsb. Aplikasi-aplikasi tersebut memanfaatkan “Web Service” yang disediakan oleh Facebook maupun Twitter sehingga dapat memperoleh konten informasi dari aplikasi tersebut.
Web service sendiri dibentuk dari :
  1. Service provider, merupakan pemilik Web Service yang berfungsi menyediakan kumpulan operasi dari Web Service.
  2. Service requestor, merupakan aplikasi yang bertindak sebagai klien dari Web Service yang mencari dan memulai interaksi terhadap layanan yang disediakan.
  3. Service registry, merupakan tempat dimana Service provider mempublikasikan layanannya. Pada arsitektur Web Service, Service registry bersifat optional. Teknologi web service memungkinkan kita dapat menghubungkan berbagai jenis software yang memiliki platform dan sistem operasi yang berbeda.
Web Service menggunakan SOAP  (Simple Object Access Protocol) yang berbasis pada XML. XML (Extensible Markup Language) merupakan standar bahasa yang digunakan dalam pertukaran data dalam Web Service. Web Service yang akan kita buat ini akan menggunakan library Open Source bernama “NuSOAP” . NuSOAP adalah sebuah kumpulan class-class PHP yang memungkinkan  user untuk mengirim dan menerima pesan SOAP melalui protokol HTTP. NuSoap sendiri dapat diunduh secara gratis di sini. Ok. mari kita mulai tutorialnya.. ;)
Pada contoh kasus ini kita akan membuat aplikasi Web Service untuk mengakses Data mahasiswa. yang perlu kita siapkan untuk membuat aplikasi Web service “Data Mahasiswa” antara lain :
  1. Library Web Service : NuSOAP
  2. Rancangan Database Mahasiswa (mhs_webserv.sql)
  3. Rancangan Script untuk Server (server.php)
  4. Rancangan Script untuk Client. (client.php)
1. Library Web Service NuSOAP
NuSOAP yang sudah kita download kita extrak dan kita letakkan satu folder dengan aplikasi web service yang akan kita buat. Jangan lupa untuk menon-aktifkan  fitur SOAP bawaan PHP yang bisa disetting di file php.ini. (extension=php_soap.dll) dan mengaktifkan fitur CURL (extension=php_curl.dll).
2. Rancangan Database Mahasiswa :
Database Engine yang kita pakai adalah MySQL. Struktur Database/Table : Database Name = mhs_webserv, Table Name = mahasiswa;
a. Buat Database “mhs_webserv”
create database mhs_webserv;
b. Buat Tabel “mahasiswa” :
CREATE TABLE IF NOT EXISTS `mahasiswa` (
`nim` varchar(10) NOT NULL,
`nama` varchar(50) NOT NULL,
`alamat` text NOT NULL,
PRIMARY KEY (`nim`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
c. Isi data mahasiswa.
INSERT INTO `mahasiswa` (`nim`, `nama`, `alamat`) VALUES
('001', 'Kabul', 'Pekalongan'),
('002', 'Ridwan', 'Semarang');
3. Rancangan Script untuk Server (server.php)
register(ambilData);

function tes($param){
$nama= $param['nama'];
$alamat = $param['alamat'];
$return_value[] =array('nama'=>$nama,'alamat'=>$alamat);
return ($return_value);}

function ambilData(){
mysql_connect('127.0.0.1','root','');
mysql_select_db('coba_wservice');
$sql = mysql_query('SELECT * FROM mahasiswa WHERE 1');
$return_data_count=mysql_num_rows($sql);
//$return_data[]=array();
while ($row=mysql_fetch_array($sql)){
$return_data[]=array('nim'=>$row['nim'],'nama'=>$row['nama'],
'alamat'=>$row['alamat']);
}
$return['count']=$return_data_count;
$return['data']=$return_data;
return $return;

}

$HTTP_RAW_POST_DATA = isset ($HTTP_RAW_POST_DATA) ?
$HTTP_RAW_POST_DATA:"";
$ws_srv->service($HTTP_RAW_POST_DATA);

?>
4. Rancangan Script untuk Client. (client.php)
'Kabul Kurniawan','alamat'=>'Pekalongan');
$result = $client->call('ambilData');
$n=$result['count'];
$data=$result['data'];
echo '';
echo "";
for($i=0;$i<$n;$i++){
echo  "";

}
echo "
NimNamaAlamat
".$data[$i]['nim']."".$data[$i]['nama']. "".$data[$i]['alamat']."
"; print_r ($result['count']); echo' '; print_r ($result['data']); ?>
Setelah rancangan-rancangan tersebut dibuat, kita dapat langsung mengakses data mahasiswa melalui client.php, berikut hasilnya..  :)

NB : Contoh Source Code, database beserta Library NuSOAP dapat anda download di sini., semoga bermanfaat :)

Ref : http://kabulkurniawan.com/2011/05/02/implementasi-web-service-sederhana-dengan-nusoap/







Powerful Web Services with PHP and SOAP

Powerful Web Services with PHP and SOAP
You've tried your hand at building mashups, experimented with a few RESTful Web services, maybe even started your own. Sure, you've got data sharing working. But how do you make your Web applications really talk to each other?
In this tutorial, I'll show you how to take your Web applications to the next level with SOAP, the "powerhouse of Web services", building high-end Web services with pure PHP.
SOAP 101
SOAP is a protocol for applications and servers to communicate with each other. Its primary use in PHP is exposing Web services and building Web service clients. As a protocol, it can exchange messages over HTTP/HTTPS, which helps it get around firewalls that would block other protocols (eg, Remote Procedure Call). As an application layer protocol, SOAP is also entirely platform independent — your PHP Web application can talk to a Java database server, for example, as long as they both speak SOAP.
SOAP messages are simply XML with some custom namespaces, so they're fully machine-readable. Libraries are available for every major language, and working with SOAP Web services is quick, easy and fast.
SOAP for PHP
Today we're going to take a look at one of these libraries, NuSOAP. PHP has a few options for SOAP, including a PHP 5 extension, a PEAR package, and an independent (but very popular) library called NuSOAP. NuSOAP is the simplest way to get up and running with SOAP, but we could just as well have used PEAR::SOAP or the extension, and all three are interoperable — you can consume PEAR::SOAP exposed services with NuSOAP and vice versa, and scripts using either can happily run alongside each other.
Getting started with NuSOAP
To begin using NuSOAP, first head to the project page and download a copy of libraries — I'm using version 0.7.2. All examples should be forwards-compatible, but API changes happen, so check your library version if you encounter any errors. Drop the contents of the archive into a folder on your Web server — using /soap under my docroot. The latest version is compatible with the SOAP extension, but if you experience "class already declared" errors just disable the SOAP extension or rename the class in nusoap.php.
Your first SOAP request!
We'll start with the SOAP client. SOAP works with servers and clients; servers expose services and clients consume them. We'll start with a demo of a simple Web service that takes an argument and returns an array — but with the power of SOAP, we get that array data locally, almost as if the client was the server, and SOAP takes care of all the information in between.
Fire up your favourite text editor and type out the following:
call("hello_world", array("name" => "Josh"));
print_r($output);
Save it as hello_world.php in the folder you created earlier. It can be anywhere, as long as the lib/nusoap.php reference still points to your NuSOAP library. Do the same for the server:
register("hello_world");
function hello_world($name)
{
    return array("data"=>"Hello World, {$name}!");
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : "";
$srv->service($HTTP_RAW_POST_DATA);
Save this as hello_world_server.php in the same folder. If it can't be accessed at that URL in the client script (localhost/soap/...), change the reference in the client code as needed.
Then load up your Web browser, point it to the SOAP client — eg, http://localhost/soap/hello_world.php — and run the script. You should see the following:
Array
(
    [data] => Hello World, Josh!
)
That's perfectly normal print_r output — precisely what you would expect if you returned the array within the same PHP script. Except that our server script is separate, could be on a different server and could be running on a totally different platform — SOAP helps gets data from the server to the client as smoothly as possible.
The Server
Let's examine the server for a moment. Here's the code we used to build our server:
register("hello_world");
function hello_world($name)
{
    return array("data"=>"Hello World, {$name}!");
}
In this example, we first load up the NuSOAP library and register the service we want to expose, naming it "hello_world". We then define this service as a standard PHP function. At the moment, it does nothing but return a simple associative array, with the value containing an argument, $name. The client provides this argument from a totally separate PHP script and SOAP provides the glue to make sure it is passed in when the function is called.
HTTP is stateless, and our PHP script will be executed from the top down whenever a request is made, so each SOAP call (or other script execution) will be a new request. To check if we have a SOAP call (and what the SOAP client wants us to do), we have to scan each request for data. SOAP clients send POST requests, with XML data in the message body of the request, so we can fetch this raw POST data and pass it to the service() method of the soap_server class. Raw POST data is available in $HTTP_RAW_POST_DATA, but PHP won't set this unless it has a value, so we use a small hack to ensure it exists before passing it on to the SOAP server.
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$srv->service($HTTP_RAW_POST_DATA);
We quickly get together the raw POST data, pass it to the SOAP library, and away we go.
The Client
The client uses the NuSOAP library, but only because we choose to — the server could use the PHP SOAP extension or PEAR::SOAP, and could be hosted anywhere. With the power of SOAP, we're going to take the PHP function on the server and talk to it through SOAP; we're also going to receive the result just like any other variable within our script. Have a look at the code for the client:
call("hello_world", array("name" => "Josh"));
print_r($output);
The client is very basic — we first load up the library, then establish a connection to the SOAP server at the URL we've provided and call the "hello_world" service. For testing, we'll print_r the output. The second argument to the $soap->call() method is an array of parameters to be passed to the service. Notice we specify 'name' as the array key, the same as the $name argument on the server's function — this is not necessary as we aren't working with complex pre-defined services, however, it does hold importance when consuming slightly more elaborate SOAP services.
The service call returns a value which we then put into $output. If we check that print_r output earlier, it showed we had a perfectly good PHP associative array — [data] => Hello World, Josh! — just as our server's hello_world() function should have returned. In just a few lines of code, we've linked together two independent PHP scripts. Now your Web apps are really talking.
Behind the scenes: debugging SOAP
While you make high-level calls to the SOAP libraries, the NuSOAP library is actually busy generating and parsing XML request messages and passing them back and forth between server and client. You can easily examine the message body of your request and the server's response on the client side, using the request and response properties of the SOAP client class. These are invaluable in debugging, and will help you get a better understanding of SOAP internals, although you may never need it...
call("hello_world", array("name" => "Josh"));
print_r($output);
echo '
'.htmlspecialchars($soap->request).'
'; echo '
'.htmlspecialchars($soap->response).'
';
This request will output something like the following:
POST /soap/hello_world_server.php HTTP/1.0
Host: 127.0.0.1
User-Agent: NuSOAP/0.7.2 (1.94)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""
Content-Length: 511

Notice we're making a direct POST request and passing all the XML through. In a HTML form request, that XML would be replaced with key=value&key=value pairs, which are then translated into elements of $_POST — this is why we have to request the raw POST data to check for a SOAP request. The actual XML schema for SOAP messages isn't important, as the libraries take care of it for us, but read up on the SOAP specifications if you want to take a closer look.
Further SOAP
Now that you've built your first SOAP client, experiment with more complex APIs, or try consuming one of the many SOAP-based APIs available. If your applications already receive data from other sources, check if they offer SOAP — its use is very prevalent in enterprise situations, especially where SOA is encouraged. Finally, if you want to learn more about NuSOAP, one of the authors provides some handy resources.

NuSoap with PHP5

NuSoap with PHP5
For the past few days I have been working with SOAP on a number of platforms. I wanted to use NuSoap with PHP5 and here are a few steps which will allow you to do so. As PHP5 has an inbuilt support for webservices it will clash with the names in nusoap.php. To get over this rename the class soapclient to soap_client. Also rename the constructor soapclient to soap_client.

This is all that needs to be done. Once you do this you would be able to run NuSoap with PHP5.



Tinggal Renamae saja untuk menggunakan NuSoap dalam PHP5, ganti nama file class soapclient ke soap_client dan rename pendefinisian cunstruct soapclient menjadi soap_client.


Ref : http://blog.vivekjishtu.com/2006/03/nusoap-with-php5.html

Mengembalikan GRUB Ubuntu Yang Hilang Setelah Install Windows

GRUB
Ubuntu menggunakan GRUB (GRand Unified Bootloader) sebagai boot-loader/boot-manager, yaitu sebuah program kecil (dan juga bagian dari sistem operasi) yang nantinya akan memuat sistem operasi yang biasanya tertanam pada harddisk.

Ubuntu mulai menggunakan GRUB 2 mulai sejak Ubuntu 9.10 (Karmic Koala) dirilis, sedangkan Ubuntu 9.04 (Jaunty Jackalope) kebawah masih versi GRUB legacy.
Bagi para pengguna Ubuntu/Linux dualboot pasti tidak asing lagi dengan GRUB, karena setiap kali mereka menyalakan komputer pasti akan melihat bagimana grub ini bekerja. Dengan adanya grub ini kita akan diberikan pilihan untuk booting ke sistem operasi mana saja yang terinstall di komputer kita (lihat gambar diatas). Tapi bagimana kalau tidak ada sistem operasi lain selain Ubuntu? Kalau tidak ada sistem operasi lain yang terdeteksi oleh grub, maka saat komputer dinyalakan maka biasanya akan langsung masuk ke Ubuntu.

Versi GRUB

Supaya tidak bingung, berikut ini adalah penjelasan singkat tentang grub yang digunakan pada tiap versi Ubuntu yang telah dirilis.
  • Jika Anda menginstall (fresh install) Ubuntu 9.10 keatas, maka Anda menjalankan GRUB 2
  • Jika Anda menginstall Ubuntu 9.10 kebawah, maka Anda menjalankan GRUB legacy
  • Jika Anda menginstall Ubuntu 9.10 kebawah lalu mengupgradenya ke Ubuntu 9.10, maka Anda menjalankan GRUB legacy secara default, kecuali Anda mengupgradenya ke GRUB 2.
  • Setiap Ubuntu (9.10 keatas) yang baru saja diinstall akan langsung masuk ke desktop Ubuntu jika tidak ada sistem operasi lain yang diinstall
  • Anda bisa menekan dan tahan tombol Shift untuk memunculkan menu GRUB atau juga bisa dengan tombol Esc
  • File yang berisi konfigurasi GRUB legacy ada pada /boot/grub/menu.lst, sedangkan pada GRUB 2 ada pada /boot/grub/grub.cfg
Untuk mengecek versi GRUB yang Anda gunakan jalankan perintah ini di Terminal:
grub-install -v

GRUB tidak muncul/tertimpa

Banyak alasan yang menyebabkan GRUB tidak muncul pada saat booting. Salah satu alasan yang paling utama adalah bootloader Ubuntu (GRUB) tertimpa oleh bootloader sistem operasi lain misalnya Microsoft Windows. Ini sangat sering terjadi di kalangan pengguna Linux yang dualboot dengan Windows.
Jika kita menginstall ulang Windows pada komputer yang sebelumnya sudah terinstall Ubuntu maka GRUB Ubuntu akan tertimpa oleh MBR punya Windows, inilah yang mengakibatkan mengapa menu grub tidak tampil pada saat komputer booting.

Mengembalikan GRUB Ubuntu yang hilang/tertimpa

Jika kita menginstall ulang Windows setelah menginstall Ubuntu, maka GRUB akan tertimpa oleh MBR Windows. Pada kondisi ini Ubuntu Anda tidak rusak ataupun hilang, dan tidak perlu melakukan install ulang Ubuntu, karena yang dibutuhkan adalah menginstall kembali bootloader Ubuntu (GRUB) yang tertimpa oleh MBR Windows. Ingat, yang diinstall ulang hanya bootloadernya saja buka sistem operasinya.
Untuk menginstall ulang GRUB kita membutuhkan LiveCD Ubuntu, usahakan yang sama versinya dengan Ubuntu yang sedang kita gunakan/yang akan dikembalikan GRUB nya. Contohnya, gunakan Live CD Ubuntu 9.10 untuk mengembalikan GRUB dari Ubuntu 9.10, atau gunakan Live CD Ubuntu 11.04 untuk mengembalikan GRUB dari Ubuntu 11.04, dst.
Kalau sudah punya Live CD nya, saatnya mulai.
  • Masukkan Live CD Ubuntu ke CD/DVD ROM laptop/PC dan booting ke Live CD tersebut.
  • Setelah berhasil masuk ke desktop Ubuntu, jalankan Terminal dan jalankan beberapa perintah dibawah ini.
1. Anda harus menentukan dimana letak partisi Ubuntu:
sudo fdisk -l
Contoh di komputer saya Via Terminal:

List_partition
atau bisa juga mengecek lokasi partisi Via program GParted (program bawaan pada Live CD Ubuntu):

List_partition
Pada gambar diatas (via Terminal dan Gparted) menunjukkan kalau lokasi instalasi Ubuntu saya adalah pada partisi /dev/sda7. Punya Anda mungkin berbeda, bisa saja /dev/sda5, /dev/sda6, dan lainnya.
2. Mount partisi dimana instalasi Ubuntu berada:
sudo mount /dev/sdaX /mnt
/dev/sdaX adalah lokasi instalasi Ubuntu. Lokasi instalasi ini tergantung pada hasil pada langkah 1.
3. Install grub ke partisi yang sudah di-mount
sudo grub-install --root-directory=/mnt/ /dev/sda
4. Update GUBR
Setelah semua langkah diatas sukses dijalankan, yang harus Anda lakukan berikutnya adalah merefresh GRUB yang baru saja diinstall.
sudo update-grub
Terakhir, restart komputer Anda untuk memastikan apakah GRUB sudah tampil pada saat booting.

Ref : http://blog.cyber4rt.com/linux/mengembalikan-grub-ubuntu-yang-hilang-setelah-install-windows/

Set / Change / Reset the MySQL root password on Ubuntu Linux

Set / Change / Reset the MySQL root password on Ubuntu Linux
Tested on
- Ubuntu Linux 7.10 Gutsy Gibbon and MySQL 5.0.45. (2007-10-21)
- Ubuntu Linux 6.06 Dapper Drake and MySQL 4.1.15.

Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.
  1. Stop the MySQL Server.
    sudo /etc/init.d/mysql stop

  2. Start the mysqld configuration.
    sudo mysqld --skip-grant-tables &

  3. Login to MySQL as root.
    mysql -u root mysql

  4. Replace YOURNEWPASSWORD with your new password!
    UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;
Note: This method is not regarded as the securest way of resetting the password. However it works.

Detect Modem Di Server Linux [Bagian dari setting Gammu]

Detect Modem Di Server Linux [Bagian dari setting Gammu]
Langkah pendeteksian Modem USB dalam Distro Linux, yang perlu diketahui adalah, linux akan mendeteksi semua perangkat yang melalui port USB sebagai Storage. Dibutuhkan program pendeteksi (usb_modeswitch) untuk menterjemahkan kiriman
  1. Install "usb_modeswitch"
  2. jalankan perintah "lsusb" pada console anda
  3. Modem akan terdeteksi sebagai storage, catatat "product id" dan "device id" atau bisa menjalankan perintah diconsole "dmesg"
  4. Buat rule di folder "/etc/udev/rules.d/"  dengan nama mirip seperti yang ada dalam folder didalamnya. misal " 45-hot-plug.rule".
  5. Isikan dalam file tersebut dengan settingan
    SUBSYSTEM=="usb",
    SYSFS{idProduct}=="", 
    SYSFS{idVendor}=="", 
    RUN+=""
     
    contoh : 

     # / Etc/udev/rules.d/15-huawei-e1550.rules
     SUBSYSTEM == "usb",
     SYSFS {idProduct} == "19d2",
     SYSFS {idVendor} == "2000",
     RUN+="/usr/sbin/usb-modeswitch --vendor 0x19d2 --product 0x2000 --type option-zerocd"

     
  6. Jalankan perintah "lsusb" lagi
  7. Silahkan dicoba

USB_ModeSwitch – Activating Switchable USB Devices on Linux

USB_ModeSwitch – Activating Switchable USB Devices on Linux


Version fran̤aise i̤i Рmerci au Bullteam

Introduction

USB_ModeSwitch is (surprise!) a mode switching tool for controlling “flip flop” (multiple device) USB gear.
Several new USB devices (especially high-speed wireless WAN stuff, they’re expensive anyway) have their MS Windows drivers onboard; when plugged in for the first time they act like a flash storage and start installing the driver from there. After that (and on every consecutive plugging) this driver switches the mode internally, the storage device vanishes (in most cases), and a new device (like an USB modem) shows up. The WWAN gear maker Option calls that feature “ZeroCD (TM)”.
As you may have guessed, nothing of this is documented in any form and so far there are no official Linux drivers available. On the good side, most of the known devices work out of the box with the available Linux drivers like “usb-storage” or “usbserial”. That leaves the problem of the mode switching from storage to whatever the thing is supposed to do.
Fortunately there are things like human reason, USB sniffing programs and “libusb”. It is possible to eavesdrop the communication of the MS Windows driver, to isolate the command or action that does the switching, and to reproduce the same thing with Linux.
USB_ModeSwitch makes the last step considerably easier by taking the important parameters from a configuration file and doing all the initialization and communication stuff.
It does NOT check for success afterwards as of now. The right approach would be to consult /proc/bus/usb/devices (or the output of “lsusb”) before and after execution to note any changes.
For hints about doing your own sniffing see paragraph Contribute below
Breaking News: just found this humble tool in the source code of the fine Dovado UMR router, which they publish in compliance with the GPL. So if you want the power of your Wireless Broadband across your local network, but without the “fun” of setting up your own Linux router (which I did), consider investing in such a machine.

Download

The latest release version is 0.9.5. The archive contains the source and a 686 binary (32 bit, VIA C7, GCC 4.2.2). I used libusb-0.1.12.
There are changes and updates to the config file more often than new releases; most of the valuable knowledge about devices is contained in this file. So you better use the latest version linked here.
With countless machine and distribution variants around, x86 compatibility is sometimes just not there. If you experience “floating point errors” or the like and are not able to recompile yourself, try one of the following drop-in replacements for the binary (all are 32 bit). And – thanks to Tobias Stoeber – we have a Debian package (for Xandros, Etch and others); I have to admit that I never warmed to those packaging details …

How to install

If you want to compile it for yourself, just run “compile.sh” or type on the shell:
$ gcc -l usb -o usb_modeswitch usb_modeswitch.c
That’s as easy as it gets. And it should be as portable as libusb itself (some limitations on FreeBSD based systems are known).Take the fresh executable “usb_modeswitch” (or the one provided with the archive) and put it into your path (preferably “/sbin” or “/usr/sbin”).
Put “usb_modeswitch.conf” into “/etc” and edit it according to your hardware. It’s heavily commented and should tell you what to do.
Alternatively you can use the command line interface to tell USB_ModeSwitch the things it needs to know; try “usb_modeswitch -h” to list the parameters. This way you can handle multiple configurations. If any command line parameters except -W and -q are used, the default config file is NOT read.
Important: USB_ModeSwitch – like all programs with libusb routines – has to be run as root. Otherwise strange error messages come up …

Troubleshooting

If you’re next to certain that you have the right values for your device, followed all the hints (see Known working hardware), and USB_ModeSwitch seems to do something run after run but to no effect, there are most likely system issues involved. Almost all distributions today are using “udev” as a device and hotplug manager, and in some cases this daemon is not able to “release” the established connection of a switched device and to see it as a freshly plugged one (after all, this is something outside the USB specs).There are several ways to analyse and tackle these problems:
  • To see what udev is doing, run udevmonitor in one console and watch what happens if you plug the device and run USB_ModeSwitch. “lsusb” and “dmesg” can give additional information
  • If you suspect timing issues, try to run USB_ModeSwitch with a defined delay after plugging
  • Find the device’s sysfs access. It’s in the file system under /sys/bus/usb/devices. “dmesg” tells you what bus address it got after plugging; should look like “1-2″ or “2-4″ or similar. Then – after doing the switch – set it’s power level to suspend mode. For example like this:
    $ echo suspend > /sys/bus/usb/devices/1-2/power/level
    Mind that the USB powersaving option must have been configured in your kernel. Thanks to mixmaxtw for this neat trick; I’ll look into adding this as a built-in option
  • Try the ResetUSB option with your device. This is somewhat brutal and may also reset an internally switched device back to storage mode
  • Sometimes it is recommended to use the latest firmware available as there have been issues in the past with at least one device (Icon 7.2, resolved now). In other cases devices have stopped working with the usb-serial driver after a firmware update. So the advice is simple: update if not working, otherwise leave alone

Known working hardware

Very important note:
Personally, I could only test my Option Icon; the list here – as well as all the necessary data – relies on reports from third parties (people, that is). So don’t be surprised if you hit sudden obstacles even with your device listed here. You have been warned.There are hitherto three known methods for initiating the switching process:
1. sending a rarely or never used standard storage command (equivalent to those of SCSI) to the storage device
2. actively removing (rather detaching) the storage driver from the device
3. sending a special control message to the device
  • Option GlobeSurfer Icon (aka “Vodafone EasyBox“)
    The thing that started it all, because I wanted it to work on my Linux router.
    All known Option devices use the USB storage command REZERO UNIT for switching.
  • Option GlobeSurfer Icon 7.2
    If you get hardware lockups of this thing when plugging in (flashing LEDs), update the firmware.
  • Option GlobeSurfer Icon 7.2 with HSO driver interface
    A next generation firmware with vendor/device ID unchanging. Your “7.2 ready” device might change its behaviour after re-flashing with this firmware; newer Option devices most likely come loaded with it. Use the new “TargetClass” parameter to recognize already switched devices.
    If you have a newer Option device not listed here there is a good chance to get it working by using this entry and just adapting your vendor/product ID. Note: for HSO driver questions and howtos turn to the fine Pharscape site!
  • Option Icon 225 HSDPA (aka “T-Mobile web’n'walk Stick“)
    New Firmware, HSO interface
  • Option GlobeTrotter HSUPA Modem (aka “T-Mobile wnw Card Compact III“)
    New Firmware, HSO interface
  • Option GlobeTrotter GT MAX 3.6 (aka “T-Mobile wnw Card Compact II“)
  • Option GlobeTrotter EXPRESS 7.2 (aka “T-Mobile wnw Card Express II“)
  • Option GlobeTrotter GT MAX “7.2 Ready”
  • Huawei E220 (aka “Vodafone EasyBox II“, aka “T-Mobile wnw Box Micro“)
    We have two options (no pun intended!) for Huawei devices: 1. detaching of “usb-storage” 2. the special control message found by Miroslav Bobovsky. The latter is independent of “usb-storage” and even leaves the storage portion of the device functional. Both methods leave other USB storage devices alone (compared to removing the storage module completely, which works as well)
  • Huawei E160, Huawei E160G, Huawei E169, Huawei E270, Huawei E280
    Similar setup as the E220.
  • Huawei E630
    There are reportedly modem-only variants around (without the storage part); for these no switching is required.
  • Novatel Wireless Ovation MC950D HSUPA, Ovation 930D and Merlin XU950D
    They use the USB storage command START/STOP (Eject) for switching.
  • Novatel Wireless U727 USB modem
    Similar setup as the MC950D, different product ID
  • Novatel MC990D
    Uses new features of 0.9.5
  • ZTE MF620 (aka “Onda MH600HS“)
    Uses the USB storage command TEST UNIT READY for switching.
  • ZTE MF622 (aka “Onda MDC502HS“)
    Detachment of storage driver
  • ZTE MF628, ZTE MF628+
  • ZTE MF638 (aka “Onda MDC525UP“)
  • ONDA MT503HS (most likely a ZTE model)
  • ONDA MT505UP (most likely a ZTE model)
  • Alcatel OT-X020 (aka “MBD-100HU“, aka “Nuton 3.5G“, works with “Emobile D11LC“)
  • AnyDATA ADU-500A, AnyDATA ADU-510A, AnyDATA ADU-520A
  • BandLuxe C120
    Special treatment reportedly necessary. See Forum Entry
  • Solomon S3Gm-660
    Same notes apply as with the BandLuxe C120 above
  • C-Motech D-50 (aka “CDU-680“)
    Important notes at this Forum Entry
  • Toshiba G450
  • UTStarcom UM175 (distributor “Alltel”)
  • Hummer DTM5731
  • A-Link 3GU
  • Quanta MU-Q101, also referred to as “Quanta (NU) MU-Q101
    You probably need to do the “power suspend” trick (see Troubleshooting) to make it usable

How to automate

Mind that you have to run USB_ModeSwitch every time you plug your device or cold boot with it. If you have “udev” in your distribution it’s really not hard to automate this and just forget about it.
Note however that timing might be an issue with some of the more recent setups. If your automatic switching is unreliable the delayed execution of USB_ModeSwitch might help (see the special script below).
That said, since version 0.9.4 there are very few reports of timing issues.You should have a folder named “/etc/udev” or similar. Somewhere in there (I have a folder “rules.d”) you find some files with the extension “.rules”. Create a new one (or edit an existing one, but by convention not the default “50-something.rules”). I chose one named “45-hotplug.rules” since hotplugging is what USB is about after all.
In the chosen/new file add the line
SUBSYSTEM=="usb", SYSFS{idProduct}=="", SYSFS{idVendor}=="", RUN+=""
That’s basically it.From here, there are two ways to continue. If your GSM device is recognized by a recent version of the “option” driver you shouldn’t have to do anything but to load the module (most certainly handled by udev automatically). Instead or if your (serial) device is not supported by that module you can always use “usbserial”, but it needs to be told the device IDs (plus a performance-related option):
SUBSYSTEM=="usb", SYSFS{idProduct}=="", SYSFS{idVendor}=="",
  RUN+="/sbin/modprobe usbserial vendor= product= maxSize=4096"
As for the difference between “usbserial” and “option”, here is a quote from option.c:
  This driver exists because the "normal" serial driver doesn't work too well
  with GSM modems. Issues:
  - data loss -- one single Receive URB is not nearly enough
  - nonstandard flow (Option devices) control
  - controlling the baud rate doesn't make sense
Following that, I’d recommend trying the “option” driver first. In recent kernels it recognizes several Option, Huawei and Novatel devices (among others) out of the box. And following kernel developers mail traffic it looks like this driver is becoming the standard for GSM devices as more models are added. In the latest kernels the module entry reads “USB driver for GSM and CDMA modems” (Device Drivers / USB support / USB Serial Converter support).Devices supported by the “option” driver that don’t change their IDs after switching might run into problems because of the driver trying to attach before the switching happened. In this case it might help to blacklist it and to load it manually via the helper script after execution of usb_modeswitch. Again, developers are working on the “option” driver to probe for the device class before binding, so this problem might be handled in kernel 2.6.24.
Anyway, if your device works O.K. with “usbserial”, and you are not afraid to edit kernel sources, why not just add the vendor and product ID (after switching of course) to the “option” driver? I just did that with my cell phone, and now the “option” module is bound to it automatically when plugging in. Look at the other devices included in “option.c” and just add your IDs the same way – that’s it. Two or three lines in most cases. Recompile, add your device to one of the udev rules (see above) and enjoy!
For plain serial devices that keep their ID after switching a script “/sbin/mydevice_switch.sh” can be created:
#!/bin/sh
/sbin/usb_modeswitch
sleep   # probably not necessary, try out
/sbin/modprobe usbserial vendor= product= maxSize=4096
And then add this rule:
SUBSYSTEM=="usb", SYSFS{idProduct}=="", SYSFS{idVendor}=="", RUN+="/sbin/mydeviceswitch.sh"
If timing is an issue with your device or setup it might help to delay the execution of USB_ModeSwitch, to allow other drivers like “usb-storage” to finish their activation. Again, use the helper script – called “/sbin/mydevice_switch.sh” here – and fill it like this:
#!/bin/sh
sh -c "sleep 4; /usr/bin/usb_modeswitch" &
exit 0
Luigi Iotti reported problems on some systems (RHEL 5, CentOS 5) of udev always waiting for background scripts to finish. Here is his solution for a changed “/sbin/mydevice_switch.sh”:
#!/bin/sh
# close these FDs to detach from udev
exec 1<&- 2<&- 5<&- 7<&-
sh -c "sleep 4; /usr/bin/usb_modeswitch" &
exit 0

Contribute

USB_ModeSwitch comes quite handy for experimenting with your own hardware if not supported yet. You could try this approach:Note the device’s Vendor and Product ID from /proc/bus/usb/devices (or from the output of “lsusb”); the assigned driver is usually “usb-storage”. Then try spying out the USB communication to the device with the same ID inside M$ Windoze.
I recommend this tool: “SniffUSB” (http://benoit.papillault.free.fr/usbsnoop/index.php.en).
This is the extremely short version. There is a very good case example from Mark A. Ziesemer here:
Alltel UM175AL USB EVDO under Ubuntu Hardy HeronPlease post any improvements, new device information and/or bug reports to the ModeSwitchForum !
Or send me an old-fashioned e-mail (see below).

Whodunit

Copyright (C) 2007 Josua Dietze (usb_admin at this domain)Command line parsing, decent usage/config output and handling, bugfixes added by: