Archive for March, 2010

Hi all,

today may be sound old and boring configure a directly using a command line a dialup connection. This is may be true in many cases an a little bit unuseful.. but I love command line ๐Ÿ™‚ so I’m going to show how configure pppd to make a dial up throu a UMTS phone or a HSDPA pen.

In my case, I use a HSDPA phone with bluetooh link, but it is the same with any kind of serial port. This is a short list of used devices:

  • bluetooth: /dev/rfcommX
  • phone with data cable: /dev/ttyUSBX
  • HSDPA phone: /dev/ttyUSBX

Some times, HSDPA pen are recognized like a cdrom but do not fear about it, there are utilities to change the pen interface. If you have no idea, look in dmesg when you plug the phone/pen.

What we need: ppp daemon usually called…. (suspance)…….(a little more suspance)…. ppp :).

What we are going to do: write two files, a chat script and a ppp configuration.

This is my chat script

1. ABORT BUSY
2. ABORT ‘NO CARRIER’
3. ABORT ERROR
4. REPORT CONNECT
5. “” \rAT
6. OK ‘AT+CGDCONT=1,”IP”,”tre.it”‘
7. OK ATD*99***1#
8. CONNECT “”

Lines 1, 2, 3, 4 test the physical connection, necessary but not so interesting.

Line 5 checks for AT command

Line 6 is the trick: +CGDCONT=1 is the magical command who enable the UMTS protocol or HSDPA, without this you may get only a GPRS connection. Others parameter are necessary and says respectly the kind of connection (by ip) and the APN of your phone provider. If you do not know it, easy looking for that on your phone.

Line 7 is the call command. Call *99***1# or call *99# is the same, today I do not find any difference. If someone knows that…

Line 8 is the answer we expect.

Usually (I think on Debian and Ubuntu) this file may be placed in /etc/chatscripts, where we can find others like that.

The second file is placed in peers folder of ppp. In Debian that folder is /etc/ppp/peers. We could call hsdpa-provider.

1. /dev/rfcomm0
2. 115200
3. crtscts
4. local
5. noipdefault
6. defaultroute
7. usepeerdns
8. noauth
9. passive
10. connect “/usr/sbin/chat -v -f /etc/chatscripts/tre”
11. user pippo
12. ipcp-accept-remote
13. ipcp-accept-local

Explain it line by line is not so useful, for details look at man pppd. What we want to know is about lines 1, 10 and 11. Line 1 is the device, look the introduction if you do not find it. Line 10 says “use my chat script”, the one we have written. Line 11 is the user for dialup authentication: I think no provider asks about it so I put an uninteresting name.

We have finished.

To test it the simple way is plug your device or power on bluetooth and then call

pon hsdpa-provider

Using ifconfig we could see a new pppX interface.

To shutdown the connection, you can use poff command, or kill directly the ppp daemon.

That’s all folks!

Cheers.

Advertisements

Reality or dream?

Posted: 05/03/2010 in Uncategorized

A nice story ๐Ÿ™‚

http://regebro.wordpress.com/2010/03/04/the-knights-who-say-py/

Hi All,
this release is about a small set of script that I use on our AWS server to make backup of data. Well, it is not complete cos I found every day something to add or modify, but for me is a nice point to start.

Two Words before start

Two words about my AWS server setup:usually, I use an ami on instance storage and two EBS volumes with same size.ย  Others details like Reserved IP are optional, cos any information about server is provided in the config files. I use to attach the two disk on /dev/sdo and /dev/sdq, patitioned with a single partition for each. If you don’t like, you have to check the script mkbackup.sh and fix.

The related mount point are /mnt/partition for /dev/sdo1 and /mnt/backup for /dev/sdq1, but remember this thing: only /mnt/partition is mounted when backup procedure is NOT running.

In /mnt/partition I move any folder that I want to backup: for example /srv/zope will be moved in /mnt/partition/srv/zope. You can see I respect the original tree of folders. On the root I create a symbolic link, so anyone can access to it without problems.

This is an example schema of my fs:

My backup suite is stored in /opt/backup_utils. Take care about path, because in config file there an explicit call to it.

Usually, we use monit to check the status of any application.

The Suite

The suite contains two tools: the first one make a copy of ami, the second one syncs the two EBS volumes and make snapshots. There’s a third tool to clean old snapshots, but is still in development. Soon will be available.

The first script is called amibackup.sh. It invokes in order: ec2-bundle-vol, ec2-upload-bundle and ec2-register. Calling this script is easy create a new ami starting from a running instance. It is usefull when bigs updated on server.

The second one is called mkbackup.sh and it isย  more complicated. It is developed for daily backup and allows plugins. The flow of the actions is the follow: mounts backup disk, runs every enabled plugins, unmounts backup disk and call ec2-create-snapshot. The plugins make the rest.

At this time there are four plugins:

  • base: to sync folders but srv/zope without shutdown any service
  • mysql: an easy mysqldump
  • postgres: an easy pg_dump
  • zope: a complex solution for zope instance (with buildout or not, with zeoserver or not, with backup scripts or not)

A complete explain on zope plugin would be great but it is a little bit long.

Configure

The configuration files are two: excluded and conf. The first one contains a list of expression to identify which files will not copied: more in detail, is the parameter of –exclude-from option of rsync. The second one is the real configuration file, and it is a little bit long. It contains: AWS Info, Location Info, Db Info and Zope Info.

AWS Info: contains informations about the location of your AWS private key, AWS certificate, AWS user id, AWS access key, AWS secret key. These files and informations are provided by AWS. If do not know what they are, please check Quick Guide of EC2. Other informations in this section are: the bucket of S3 where you want to store your ami, the prefix filename of the ami, the region and the location where you are running your instance.

Location Info: base is the mount point of the backup disk, source_backup is the base folder for backup, rsync_options_base and rsync_options are the sets of parameters for rsync. Take care about rsync two options, because everyone is needed and used.

Db Info: contains login, password, and path to make a dump.

Zope Info: contains an important parameter called zope_scripts who contains the list of available script to start and stop zope. By default, I set instance (default buildout installation) and zopectl (default zope installation), but usually I add others with grok applications for example. The other parameter in this section is zope_pack_days: it means that the day we use to make the pack of ZoDB is sunday. Remember that this option works only if you have made a buildout with zeo/zope architecture.

Install

The setup is very easy: unpack the file in /opt/backup_utils and be sure to set the rights on file, usually I use chmod 700ย  *.sh and plugins too. After that you have to going in plugins-enabled, and make a symbolic link for every plugin you want. The idea is the same of apache virtualhost on debian systems or rc scripts.

After that, you can setup in cron the mkbackup.sh script to work daily.

Download

Click on me to download.

Licence

GPL v2