Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
app-notes:cumulocity-agent-in-lxc-container [2017/02/08 09:57] shashaapp-notes:cumulocity-agent-in-lxc-container [2017/02/10 12:03] (current) – [Build the agent] shasha
Line 3: Line 3:
 First you have to create e new container. To do this please follow this: First you have to create e new container. To do this please follow this:
  
-http://wiki.netmodule.com/app-notes/virtualisation?s[]=lxc+[[http://wiki.netmodule.com/app-notes/virtualisation?s[]=lxc|LXC Virtualization]] 
 +====Generate a new SSH public key==== 
 +We need for the agent SSH. We create the key in the lxc container. 
 +<code bash> 
 +ssh-keygen 
 +#The new key 
 +cat /root/.ssh/id_rsa.pub 
 +#cp the key and go to the router and copy the key in this file 
 +vi /etc/dropbear/authorized_keys 
 +</code> 
 +====Build the agent==== 
 +Now we need to make some installation. 
 +<code bash> 
 +#g++ 
 +apt-get install g++ 
 +#curl and libcurl 
 +apt-get install libcurl3-dev & apt-get install curl 
 +#make for Makefile 
 +apt-get install make 
 +</code> 
 +Download the Cumulocity C/C++ SDK: 
 +<code bash>wget https://bitbucket.org/m2m/cumulocity-sdk-c/get/d627781f3afa.zip 
 +unzip d627781f3afa.zip 
 +cd m2m-cumulocity-sdk-c-d627781f3afa 
 +</code> 
 +Create an init.mk file, and define specific macros CPPFLAGS, CXXFLAGS and LDFLAGS, LDLIBS and CXX for compiling. 
 +<code bash> 
 +CXX:=/usr/bin/g++ 
 +CPPFLAGS:=-I/usr/include 
 +CXXFLAGS:=-Wall -pedantic -Wextra 
 +LDFLAGS:=-L/usr/lib 
 +LDLIBS:=-lcurl 
 +</code> 
 +If you have defined init.mk now you have to create the makefile. 
 +<code bash> 
 +cp Makefile.template Makefile 
 +</code> 
 +Add the Cumulocity agent to the SDK:{{:app-notes:netmodulecumulocityagentlxc.tar.gz|}} 
 +<code bash> 
 +tar -xvzf netmodulecumulocityagentlxc.tar.gz 
 +cd netmoduleCumulocityAgentLXC 
 +</code> 
 +Move the content of **src** folder to the **src** folders of the SDK. 
 +<code bash> 
 +cp src/* sdk_folder/src/ 
 +#Copy also the srtemplate.txt 
 +cp srtemplate.txt sdk_folder/src/ 
 +</code> 
 +Edit the configfile (c8yAgent.conf) and move it. 
 +<code bash> 
 +cp c8yAgent.conf /etc/ 
 +</code> 
 +Now we can build the agent. 
 +<code bash> 
 +make 
 + 
 +#If you want, you can delete all and rebuild again: 
 +make clean 
 +make 
 +</code> 
 +Now go to the **src** folder. 
 +<code bash> 
 +make 
 +chmod 775 -R main 
 +</code> 
 +<code bash> 
 +./main 
 +</code>