The Cumulocity agent in LXC Container

Create a new LXC Container

First you have to create e new container. To do this please follow this:

LXC Virtualization

Generate a new SSH public key

We need for the agent SSH. We create the key in the lxc container.

#The new key
cat /root/.ssh/
#cp the key and go to the router and copy the key in this file
vi /etc/dropbear/authorized_keys

Build the agent

Now we need to make some installation.

apt-get install g++
#curl and libcurl
apt-get install libcurl3-dev & apt-get install curl
#make for Makefile
apt-get install make

Download the Cumulocity C/C++ SDK:

cd m2m-cumulocity-sdk-c-d627781f3afa

Create an file, and define specific macros CPPFLAGS, CXXFLAGS and LDFLAGS, LDLIBS and CXX for compiling.

CXXFLAGS:=-Wall -pedantic -Wextra

If you have defined now you have to create the makefile.

cp Makefile.template Makefile

Add the Cumulocity agent to the SDK:netmodulecumulocityagentlxc.tar.gz

tar -xvzf netmodulecumulocityagentlxc.tar.gz
cd netmoduleCumulocityAgentLXC

Move the content of src folder to the src folders of the SDK.

cp src/* sdk_folder/src/
#Copy also the srtemplate.txt
cp srtemplate.txt sdk_folder/src/

Edit the configfile (c8yAgent.conf) and move it.

cp c8yAgent.conf /etc/

Now we can build the agent.

#If you want, you can delete all and rebuild again:
make clean

Now go to the src folder.

chmod 775 -R main