воскресенье, 31 августа 2014 г.

Хачим Openvox gsm gateway

Как говорится, just for memo.
Попал мне в руки девайс, под названием Openvox gsm gateway, такая коробочка на 4/8 линий gsm. Внутри ARM и свой кастом на базе openwrt с asterisk. Задача стояла использовать внутренний asterisk для простеньких ivr, что производителем не предусмотрено. 

Первым делом обновляем прошивку до самой свежей, в моем случае это 2.1.1
Далее, получаем на устройстве root, в закладке System->Login info включаем ssh и устанавливаем пароль пользователю super
Заходим в устройство, осматриваемся

root@Openvox-Wireless-Gateway:~# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro,relatime)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
none on /tmp type tmpfs (rw,nosuid,nodev,relatime)
tmpfs on /dev type tmpfs (rw,relatime,size=512k)
none on /dev/pts type devpts (rw,relatime,mode=600)
/dev/mtdblock8 on /data type jffs2 (rw,relatime)
/dev/mtdblock7 on /etc/cfg type jffs2 (rw,relatime)
root@Openvox-Wireless-Gateway:~# 

Видим, что / у нас на squashfs, значит что-то изменять можно только в /data или /etc/cfg. /data стартовыми скриптами очищается, поэтому храним наш кастом в /etc/cfg, где я создал /etc/cfg/data и /etc/cfg/data/sounds. В последнюю директорию кладем любой звук от asterisk, в формате gsm, пусть это будет для примера hello-world.gsm.

Далее, редактируем /etc/cfg/asterisk.conf, добавляем datadir

astdatadir => /etc/cfg/data

Устройство при внесении изменений через web синхронизирует /etc/asterisk с /etc/cfg, поэтому все долговременные изменения надо делать там. Часть файлов перетираются, но например 
/etc/asterisk/extensions_custom.conf сохраняется, добавляем туда макрос для нашего ivr, самый простой пока:

[macro-ivr]
exten => s,1,Answer()
same => n,Playback(hello-world)
same => n,NoOp(${PLAYBACKSTATUS}) 
same => n,MacroExit()

Далее, если мы хотим сохранить сохранить управление через web, неплохо бы сделать так, что-бы была возможность добавлять наш макрос по желанию к нужным routes, можно конечно влезть и сделать красиво с изменением в UI, но я пошел простым путем, если route name имеет вид <something>-macro-name, то достаем name и делаем вызов macro-name самой первой командой диалплана, т.е. как-то так:

[rtg-incoming-macro-ivr-1]
exten => s,1,NoOp(s matches Rule rtg-incoming-macro-ivr-1)
exten => s,n,Macro(ivr,s,1)
exten => s,n,Set(CDR_CALLEEID=${EXTEN})
exten => s,n,GrpPolicy(ops)
exten => s,n,Macro(dial-failover,,,${POLICY_ops})
exten => s,n,Goto(nocdr,s,1)

что-бы это работало красиво, берем и патчим /www/cgi-bin/inc/wrcfg.inc таким вот патчем:

--- wrcfg.inc.orig      2014-08-31 16:03:51.000000000 +0300
+++ wrcfg.inc   2014-08-31 16:04:09.000000000 +0300
@@ -832,6 +832,11 @@
                                $routing_content = '';
                                foreach($exten as $each) {
                                        $routing_content .= "exten => $each[e],1,NoOp($each[e] matches Rule $routing_context)\n";
+                                       if(strpos($routing_name, '-macro-')) {
+                                               $pieces = explode('-', $routing_name);
+                                               $macro_name = end($pieces);
+                                               $routing_content .= "exten => $each[e],n,Macro($macro_name,s,1)\n";
+                                       }
                                        if($from_channel_info['type'] == 'brd') {
                                                //Modify CALLERID(number)
                                                //SIP From header:

если китайские товарищи изменят код и патчик будет не подходить, то просто гляньте функцию save_routings_to_extensions() там все очевидно. Далее, раз /www у нас на squashfs и после перезагрузки мы его теряем, то копируем измененный wrcfg.inc в наш /etc/cfg/data/, после чего в скрипте /etc/cfg/gw/custom.sh добавляем строчку

cp /etc/cfg/data/wrcfg.inc /www/cgi-bin/inc/wrcfg.inc

Вуаля, мы можем добавлять нужные нам роуты, и после перегрузки устройство все помнит. 

И еще статейка про это на Хабре

воскресенье, 10 февраля 2013 г.


Few days ago I had talks with guys who wanna open outsource software development office in Kiev, Ukraine. After that I tried to summarize my thoughts about what is the best way to do this. Also this will work for any startup-style company who is going to start office in Kiev or in major Ukraine cities.  So, let's start from the beginning:

Pre-requisites

- Number of people
My writeup covers small teams, like 7-12 people, larger teams will have more administrative load

- Legal form
All workers in my model are Ukraine Private Entrepreneurs, category 3 (5% of tax from income) and have direct contracts with HQ office nominated in currency different from UAH.

Let's start from office space. First of all, think about location. Personally, I hate downtown. Why ? Lot of reasons, let's enumerate:

pros:

  • prestige place
  • can be nice architecture building
  • equal path from any disctrict 


cons:

  • expensive
  • old planing, old buildings
  • no parking or parking lots are expensive to rent
  • usually no shower
  • no place to park bikes
  • sometimes can be issues with internet connection (old communications)


How about business centers ? With them you can run into additional issues like payments for security, only one ISP connection which price can be surprising or minimal rent amount which is usually half of floor or full floor. 

This brings us to idea, that possibility to have equal path for all of employes transforms into everyday issues for all of them. My idea is to search apartment converted to office in one of the suburbs districts close to subway station. Let's analyze this:

pros:

  • cheaper then downtown
  • apartments can be used for office
  • if apartment, you will have 1-2 bath's 
  • parking lots available 
  • put bike to elevator and bring to apartment hall
  • usually 2-3 internet providers available
  • very comfort for those who live in that suburb
  • when driving or using public transportation, you always going in opposite direction to traffic
  • smokers can use balcony 


cons: 

  • long way for guys from other districts
  • can be issues with neighbors in apartments, if office is illegally converted
  • hard to expand if you need increase number of workers


May be I'm cheating, but all my experience tells me that large apartment, in suburb, near public transportation and in the district where more then half of team lives will be a best choice for classics Two Pizza team :))

Thus, our choice is apartment. Let's think about it's area and number of rooms. My preferred agile style of working is one or two big desks, where all team members can sit on any place. Such kind of workplace works wary well in teams which have a free schedule. We need one big room for this - this will be living room of apartment. Then, we need meeting room and a place where people can relax - tv, xbox, sofa. Also a big kitchen with refrigerator, microwave, dishwasher, teapot and coffee machine. Two bathrooms. So two bedroom apartment  total with area 100-120m2 (1070-1300 sq, feet) will be enough. Check owner papers - apartment should be converted to office officially. 

And how typical office works ? If you need to run it on your own, you will have some administrative load. This includes:

office stuff:

  • rental payments
  • utilities payments
  • internet payments
  • cleaning services
  • coffee, tea, milk, sugar and other food 
  • paper, pens and other small stationery


paperwork and accounting:

  • establish PE's for newcomers
  • prepare declarations for PE's 
  • preparing Act of performing services for banks to be able converting money
  • budgeting 
  • ticketing, hotel allocations, collecting receipts from business travelers
  • pre-hiring communications


Possibly any other things depending of style of your business process, I do not want to focus a lot on this. Idea is in splitting duties between two people, one is Technical Lead which handle all business process and another is Administrative Assistant, who can work even 20 hours/week to handle office stuff and paperwork. 

Need any info about getting into IT business in Ukraine ? Feel free to contact me.