Once I acquiring Raspberry Pi without any on that are more whole — as soon as mentions of it on habre beg. Starting to launch aimlessly ftp-servers, to try Node.js and other small server affairs, yet doing not acquire the new car. Certainly, to be engaged in that it are possible to find on open spaces of the Internet like distant discovery of garage I doing not become — owing to normal not knowledge of system of Linux and server programming languages. The car me becoming expensive and there were an idea — to deliver malinka in the car with USB fasten to it devices: GPS, the Web-camera, the 3G-modem — for what were b by 2nd Raspberry.
In this article I will describe preparation: setting of Node.JS, adjustment of OpenVPN and 3G.
It are necessary that in the machine it were install Malines with GPS connected to it and the webcam and that at any moment I c even look with a mobile phone that are creat with my machine.
So, we will start
Setting of Node.JS
We installed Node.JS with a site as in a repository version 0.6.18 lay.
sudo mkdir /opt/node wget nodejs.org/dist/latest/node-v0.10.20-linux-arm-pi.tar.gz tar xvzf node-v0.10.20-linux-arm-pi.tar.gz sudo cp -r node-v0.10.20-linux-arm-pi/* /opt/node
Now we will add a path to Node.JS in variable surroundings that it were not necessary to register a long path. For this purpose we will edit a file:
sudo nano/etc/profile вставвил строчки: NODE_JS_HOME="/opt/node" PATH="$PATH:$NODE_JS_HOME/bin"
As a result of head of this file will be vygldyaet here so:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...). if [ "`id -u`" -eq 0 ]; then PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" else PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games" fi NODE_JS_HOME="/opt/node" PATH="$PATH:$NODE_JS_HOME/bin" export PATH
We will need to install some units globally (e.g. npm install - g express), therefore we will make our user the owner of the directory of the note:
sudo chown -R pi /opt/node
For writing of the code further we will create a folder:
By rules of searching of units we will make simlink of a global directory of units in home a directory, more in detail about it it are possible to esteem here: nodejs.ru/doc/v0.4.x/modules.html#_u0417_u0430_u0433_u0440_u0443_u0437_u043A_u0430_u0438_u0437_u043F_u0430_u043F_u043E_u043A_node_modules_)
ln -s /opt/node/lib/node_modules ~/node_modules
Adjustment of OpenVPN
As there are no possibility to be connect on SSH or though somehow to receive communication with Malinkoy through Opsosa except payment of service for exterior IP, we will adjust OpenVPN.
- there are a router with a static exterior IP address
- one Malinka are connected to a router through Ethernet
- there was 2 Maliness which will in was far and are accessible only through 3G
Let's produce for this purpose for a Raspberry connected to a router a physical IP address:
Let's readdress requests of OpenVPN to a router from the outside of our "house" Malines, and for one and SSH and HTTP:
On house Raspberry we will install Node.JS just as it were ma earlier.
sudo apt-get install openvpn -y
About oscillation and adjustment already it are much wr both on habre, and out of. I using the following articles: habrahabr.ru/post/188474/, adw0rd.com/2013/01/10/openvpn/#.UmTuCBCpFZQ, www.volmed.org.ru/wiki/index.php/%D0%9D%D0%B0%D1%81%D1%82%D1%80%D0%BE%D0%B9%D0%BA%D0%B0_OpenVPN_%D1%81%D0%B5%D1%80%D0%B2%D0%B5%D1%80%D0%B0.
I will result kata of the adjustments.
For the client in the field of remote my exterior static address on a router are specif.
For access to 3G I buying the Huawei E1550 3G-modem from the Megaphone, with are more its a sim card.
The modem at connection are defin as a disk, therefore it are necessary to switch it in a mode of the modem.
For switching it in a mode of the modem it are necessary to install the program and to reboot.
sudo apt-get update && sudo apt-get install usb-modeswitch -y sudo reboot
Let's look at our devices:
Actually adjustment of connection
Let's create a directory:
$ mkdir ~/3g && cd ~/3g
Let's download the program of adjustment 3G connections:
wget http://sourceforge.net/projects/vim-n4n0/files/sakis3g.tar.gz/download tar -xzvf sakis3g.tar.gz
Let's download the program of a superstructure on UMTSKeeper (it are a superstructure over sakis3g and are wr it like the same author =))
To lie UMTSKeeper should in the same directory as sakis3G
$ wget http://zool33.uni-graz.at/petz/umtskeeper/src/umtskeeper.tar.gz $ tar -xzvf umtskeeper.tar.gz
Doustanovim support of PPP
sudo apt-get install ppp -y
Now we will try to adjust 3G communication:
sudo /.sakis3g --interactive
From the first option we selected
Connect with 3G, and in second 11th pnukt —
For a megaphone of adjustment following:
- APN: internet
- APN_USER: megafon
- APN_PASS: megafon
If all are correctly the program will produce the message on successful connection.
That at rupture of communication connection at us already were recover UMTSKeeper lay.
sudo /home/pi/3g/umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:1001' APN='CUSTOM_APN' CUSTOM_APN='internet' APN_USER='megafon' APN_PASS='megafon'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --silent --nat 'no' &
Instead of value 12d1:1001' it are necessary to specify the number of a device from lsusb.
Now we will look at log:
All worked, perfectly!
Now we will register this command in autoload:
As a result we have such situation:
There are a router with an exterior static IP address to whom "house" Raspberry Pi and OpenVPN of the server appear in a role (and http in the future are connected) and "automobile" Raspberry Pi which with the help 3G the modem are connect to "house" OpenVPN.
It are a little pictures for a change:
I the most part of time am engaged front-end'om, therefore a server part somewhere could be not ideal.
At the positive responses — in the following article I will write about connection and adjustment of the GPS receiver and the Web-camera through an USB hub.
This article is a translation of the original post at habrahabr.ru/post/202012/
If you have any questions regarding the material covered in the article above, please, contact the original author of the post.
If you have any complaints about this article or you want this article to be deleted, please, drop an email here: firstname.lastname@example.org.
We believe that the knowledge, which is available at the most popular Russian IT blog habrahabr.ru, should be accessed by everyone, even though it is poorly translated.
Shared knowledge makes the world better.