Register now and start sharing your code snippets.
-->

3G connection with Linux and Option Globetrotter GT Max "7.2 ready"

Shell Script (Bash) posted about 1 year ago by marko

The installation instructions for the software are Debian specific. The configuration files are specific to Saunalahti Mobiililaajakaista (Saunalahti mobile broadband) in Finland.

Installation

Install wvdial and pppd

   1  apt-get install wvdial pppd

Create and edit /etc/ppp/peers/wvdial

   1  usepeerdns
   2  plugin passwordfd.so
   3  noauth
   4  name wvdial
   5  defaultroute
   6  replacedefaultroute
   7  noipdefault
   8  novj
   9  nobsdcomp

Edit /etc/wvdial.conf

   1  [Dialer Defaults]
   2  Modem = /dev/ttyUSB0
   3  Baud = 115200
   4  Init1 = ATZ
   5  Init2 = ATQ0 V1 E1 S0=0 &C1 &D2
   6  Init3 = AT+CFUN=1;+CGDCONT=1,"IP","internet.saunalahti"
   7  Area Code =
   8  Phone = *99#
   9  Username = saunalahti
  10  Password = saunalahti
  11  Ask Password = 0
  12  Dial Command = ATD
  13  FlowControl=NOFLOW
  14  Stupid Mode = 1
  15  Compuserve = 0
  16  Force Address =
  17  Idle Seconds = 3000
  18  DialMessage1 =
  19  DialMessage2 =
  20  ISDN = 0
  21  Auto DNS = 1

Run wvdial

   1  sudo wvdial

You should now be connected. If you aren’t then check for potential solutions below.

Troubleshooting

Kernel modules

Check that modules USB _SERIAL_OPTION and USB _SERIAL are built as modules or into the kernel.

Conflicting drivers

This is identified by a rapidly flashing purple light in your modem. You must disable and blacklist the usb_storage module, because it interferes with the built in modem.

Disable usb_storage module

   1  rmmod usb_storage
   2  cat /etc/modprobe.d/blacklist | grep "blacklist usb_storage" || echo "blacklist usb_storage" >> /etc/modprobe.d/blacklist
   3  pccardctl eject
   4  pccardctl insert

Device in wrong state

If you completely fail to get a response from the modem then you probably need to run the usb_modeswitch utility. You can check if this is the problem using lsusb. Below are the correct and incorrect values.

Correct value of lsusb (no need to run usb_modeswitch). Notice the row containing “0af0:6701 Option”.

   1  marko@x61s:~$ lsusb
   2  Bus 008 Device 003: ID 0af0:6701 Option 
   3  Bus 008 Device 001: ID 0000:0000  
   4  Bus 007 Device 001: ID 0000:0000  
   5  Bus 006 Device 001: ID 0000:0000  
   6  Bus 001 Device 001: ID 0000:0000  
   7  Bus 005 Device 001: ID 0000:0000  
   8  Bus 002 Device 003: ID 0483:2016 SGS Thomson Microelectronics Fingerprint Reader
   9  Bus 002 Device 002: ID 0a5c:2110 Broadcom Corp. 
  10  Bus 002 Device 001: ID 0000:0000  
  11  Bus 004 Device 001: ID 0000:0000  
  12  Bus 003 Device 001: ID 0000:0000  

Incorrect value of lsusb (you should run usb_modeswitch). Notice the row containing “05c6:1000 Qualcomm, Inc.”.

   1  marko@x61s:~$ lsusb
   2  Bus 008 Device 002: ID 05c6:1000 Qualcomm, Inc. 
   3  Bus 008 Device 001: ID 0000:0000  
   4  Bus 007 Device 001: ID 0000:0000  
   5  Bus 006 Device 001: ID 0000:0000  
   6  Bus 001 Device 001: ID 0000:0000  
   7  Bus 005 Device 001: ID 0000:0000  
   8  Bus 002 Device 003: ID 0483:2016 SGS Thomson Microelectronics Fingerprint Reader
   9  Bus 002 Device 002: ID 0a5c:2110 Broadcom Corp. 
  10  Bus 002 Device 001: ID 0000:0000  
  11  Bus 004 Device 001: ID 0000:0000  
  12  Bus 003 Device 001: ID 0000:0000  

Compile usb_modeswitch

   1  wget "http://frederick-reid.com/usb_modeswitch/usb_modeswitch-0.9.1beta.tar.bz2"
   2  tar xjvf usb_modeswitch-0.9.1beta.tar.bz2 -C /usr/src
   3  cd /usr/src/usb_modeswitch-0.9.1beta
   4  gcc -l usb -o usb_modeswitch usb_modeswitch.c
   5  mv -i usb_modeswitch /usr/bin

Create /etc/usb_modeswitch.conf with the following contents (NOTE: if you need to revert back then swap the values of “Default” and “Target”).

   1  DefaultVendor=  0x05c6
   2  DefaultProduct= 0x1000
   3  
   4  TargetVendor=   0x0af0
   5  TargetProduct=  0x6600
   6  
   7  MessageEndpoint=0x05
   8  MessageContent="55534243706ede860000000000000601000000000000000000000000000000"

Finally run usb_modeswitch

   1  usb_modeswitch

PPPD dying

If you start connecting, but lose it with pppd dying (like below), then re-check your /etc/wvdial.conf file. Your card may need a pin before it can be used. Or, as in my case, I had a typo where I had written “internet.saunalahti” instead of “saunalahti.internet” :)

   1  marko@x61s:~$ sudo wvdial
   2  --> WvDial: Internet dialer version 1.56
   3  --> Cannot get information for serial port.
   4  --> Initializing modem.
   5  --> Sending: ATZ
   6  ATZ
   7  OK
   8  --> Sending: ATQ0 V1 E1 S0=0 &C1 &D2
   9  ATQ0 V1 E1 S0=0 &C1 &D2
  10  OK
  11  --> Sending: AT+CFUN=1;+CGDCONT=1,"IP","saunalahti.internet"
  12  AT+CFUN=1;+CGDCONT=1,"IP","saunalahti.internet"
  13  OK
  14  --> Modem initialized.
  15  --> Idle Seconds = 3000, disabling automatic reconnect.
  16  --> Sending: ATD*99#
  17  --> Waiting for carrier.
  18  ATD*99#
  19  CONNECT 3600000
  20  --> Carrier detected.  Starting PPP immediately.
  21  --> Starting pppd at Sat Oct 20 21:49:26 2007
  22  --> Pid of pppd: 6010
  23  --> Using interface ppp0
  24  --> pppd: �+
  25  --> pppd: �+
  26  --> pppd: �+
  27  --> pppd: �+
  28  --> pppd: �+
  29  --> pppd: �+
  30  --> Disconnecting at Sat Oct 20 21:49:28 2007
  31  --> The PPP daemon has died: A modem hung up the phone (exit code = 16)
  32  --> man pppd explains pppd error codes in more detail.
  33  --> Try again and look into /var/log/messages and the wvdial and pppd man pages for 

No device found

If your /dev/ttyUSBn devices don’t exist you might need to create them.

Create ttyUSBn devices

   1  mknod /dev/ttyUSB0 c 188 0
   2  mknod /dev/ttyUSB1 c 188 1
   3  mknod /dev/ttyUSB2 c 188 2
   4  chmod g+w /dev/ttyUSB?
   5  chown root.dialout /dev/ttyUSB?

Permission errors

If you get permission errors then you aren’t running wvdial with leveraged privileges. Adding yourself to groups dialout and dip will get you a bit further, but the initial connection still needs to be run as root as files /etc/ppp/chap-secrets and /etc/ppp/pap-secrets are only writable to root. There is a guide for gentoo for setting up ppp access as non-root, but I have yet to try it myself.

Add yourself to groups dialup and dip

   1  usermod -a -G dialout,dip marko

A successful connection

This is what a successful connection will look like.

   1  x61s:# sudo wvdial
   2  --> WvDial: Internet dialer version 1.56
   3  --> Cannot get information for serial port.
   4  --> Initializing modem.
   5  --> Sending: ATZ
   6  ATZ
   7  OK
   8  --> Sending: ATQ0 V1 E1 S0=0 &C1 &D2
   9  ATQ0 V1 E1 S0=0 &C1 &D2
  10  OK
  11  --> Sending: AT+CFUN=1;+CGDCONT=1,"IP","internet.saunalahti"
  12  AT+CFUN=1;+CGDCONT=1,"IP","internet.saunalahti"
  13  OK
  14  --> Modem initialized.
  15  --> Idle Seconds = 3000, disabling automatic reconnect.
  16  --> Sending: ATD*99#
  17  --> Waiting for carrier.
  18  ATD*99#
  19  CONNECT 3600000
  20  --> Carrier detected.  Starting PPP immediately.
  21  --> Starting pppd at Sat Oct 20 22:13:05 2007
  22  --> Pid of pppd: 9174
  23  --> Using interface ppp0
  24  --> pppd: �+
  25  --> pppd: �+
  26  --> pppd: �+
  27  --> pppd: �+
  28  --> pppd: �+
  29  --> pppd: �+
  30  --> pppd: �+
  31  --> pppd: �+
  32  --> pppd: �+
  33  --> local  IP address 8x.7x.2xx.6x
  34  --> pppd: �+
  35  --> remote IP address 10.xx.xx.xx
  36  --> pppd: �+
  37  --> primary   DNS address 19x.19x.5x.10x
  38  --> pppd: �+
  39  --> secondary DNS address 19x.7x.0.4x
  40  --> pppd: �+
  41  rm --> pppd: �+
  42  --> Connect time 44.9 minutes.

Tagged 3g, saunalahti mobiililaajakaista, saunalahti mobilbredband, hsdpa, umts, grps, modem, modeemi, pcmcia, linux, gsm, laptop, kannettava tietokone, bärbar dator, saunalahti mobile broadband

How to reset the MySQL root password

Shell Script (Bash) posted about 1 year ago by christian

I just happened to lock myself out of MySQL, but luckily I have root access to the server so I can reset it easily by first shutting down MySQL:

   1  /etc/init.d/mysql stop

And then creating a MySQL init file with the desired password:

   1  $ echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('1234');" >> /tmp/mysql_init.txt

Starting MySQL with the —init-file parameter like this resets the password:

   1  $ mysqld_safe --init-file=/tmp/mysql_init.txt

Remember to delete the file:

   1  rm /tmp/mysql_init.txt

Tagged mysql, password, reset

Change nginx configuration on the fly

Shell Script (Bash) posted about 1 year ago by christian

First make your changes to nginx.conf.

Then run the following command to test the new configuration:

   1  # nginx -t -c /etc/nginx/nginx.conf 
   2  2007/10/18 20:55:07 [info] 3125#0: the configuration file /etc/nginx/nginx.conf syntax is ok
   3  2007/10/18 20:55:07 [info] 3125#0: the configuration file /etc/nginx/nginx.conf was tested successfully

Next, look for the process id of the master nginx process:

   1  # ps -ef|grep nginx
   2  root      1911     1  0 18:00 ?        00:00:00 nginx: master process /usr/sbin/nginx
   3  www-data  1912  1911  0 18:00 ?        00:00:00 nginx: worker process

Lastly, tell nginx to reload the configuration and restart the worker processes:

   1  # kill -HUP 1911

Tagged nginx, reload, configuration

Entering copy / scrollback mode in screen

Shell Script (Bash) posted about 1 year ago by marko

How to enter copy mode (also called scrollback mode) in the terminal program called screen.

   1  Ctrl-a esc

Tagged shell, screen, copy mode, kopiointitila, kopieringsläge

Custom kernel for Debian Etch

Shell Script (Bash) posted about 1 year ago by marko

Sometimes you just need a kernel that is newer than the package manager has to offer. For me it was the bug fixes for the driver of the sound card in x61s. Here’s how to do it “the debian way”.

   1  wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.23.1.tar.bz2
   2  tar xjvf linux-2.6.23.1.tar.bz2 -C /usr/src
   3  rm /usr/src/linux && ln -s /usr/src/linux-2.6.23.1 /usr/src/linux
   4  cd /usr/src/linux
   5  zcat /proc/config.gz > .config
   6  make xconfig

Now turn on and configure the new features you are looking for in the new kernel, save the configuration and finally quit.

   1  make-kpkg clean
   2  fakeroot make-kpkg --initrd --append-to-version=-custom-13.10.2007 kernel_image kernel_headers
   3  cd ..
   4  sudo dpkg -i linux-image-2.6.23.1-custom-13.10.2007_2.6.23.1-custom-13.10.2007-10.00.Custom_amd64.deb
   5  sudo dpkg -i linux-headers-2.6.23.1-custom-13.10.2007_2.6.23.1-custom-13.10.2007-10.00.Custom_amd64.deb
The—append-to-version parameter appends the given value into the kernel signature, so that it is easily recognized. If you compile a kernel with the exactly same name as a previous kernel you have then you must move away the directory /lib/modules/your-kernel-name-here.

Tagged linux, debian, custom kernel, kustomoitu kerneli, kustomiserad kernel, deb