Introduction

This document shows how to deploy Projects in Linux through code lines (without graphics image in Ubuntu Server) and too how to initialize the FactoryStudio TServer automatically when Ubuntu is initialized. However, you need a PC as a client for doing the deployment in Linux and make all necessary settings, after it, your Linux Server will keep running. 



The solution

Installation and Deploy Ubuntu


We used Putty and FileZilla software to access the Ubuntu Server.


On Ubuntu Server: 

> sudo apt-get install openssh-server


On Computer:
Open putty and connect in Ubuntu Server


Through Putty or Linux Terminal:
commands of the PDF ‘How to Deploy Projects on Raspberry Pi or Linux’:

> sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys
3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

> echo "deb http://download.mono-project.com/repo/debian wheezy
main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list

> echo "deb http://download.mono-project.com/repo/debian wheezyapache24-compat main" | sudo tee -a /etc/apt/sources.list.d/monoxamarin.list

> sudo apt-get update
> sudo apt-get upgrade
> sudo apt-get install mono-devel
> sudo apt-get install mono-complete
> sudo apt-get install referenceassemblies-pcl


On computer:
Transfer folder "ProjectServer" localized in C:\Program Files (x86)\\\\IoT\ProjectServer .. and transfer to /home/username/ in Server Ubuntu. We used FileZilla software to transfer. 


On Putty or Linux Terminal:
install the xvfb with: 

> sudo apt-get install xvfb


Create a screen with command: 

> screen -S 'screen_name'


Use command to run server: 

> xvfb-run mono /home/username/ProjectServer/ProjectServer.exe


Open 'Welcome' in FactoryStudio ->
Create new project with - Product Family: EdgeGateway;
Target Framework: Linux/Mono 


In Welcome -> Server tab -> Remote -> Server Ip -> Connect button -> Update button -> Upload Project, you can choose the project created before 


License tab -> Load license key


Projects -> Refresh -> Open project


Run -> Startup -> Run Startup button


If you wish you can run the project via ubuntu server using command:

> xvfb-run --auto-servernum --server-num=1 mono
/home/username/TServer/TServer.exe /Project:project_name.tproj

AutoLogin Ubuntu

If your Ubuntu Server have Login and Password and you wish to enter in your Ubuntu server automatically you can do the steps below: 


On Putty or Linux Terminal:

> sudo systemctl edit getty@tty1.service

This will the create a drop-in file (if neccessary) and open it an editor. Add the following, replacing myusername with your user name

[Service]
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin myusername %I $TERM
Type=idle


This will:
Create the folder /etc/systemd/system/getty@tty1.service.d if necessary
Create the file /etc/systemd/system/getty@tty1.smervice.d/override.conf if necessary

AutoRun FactoryStudio TServer with Service

When Ubuntu initializes your FactoryStudio TServer will initialize automatically.

On Putty or Linux Terminal:

> sudo su
> nano /usr/local/sbin/my-startup.sh

You can write the text below to initialized your Server with this command: 

#!/bin/sh
xvfb-run mono /home/username/ProjectServer/ProjectServer.exe

Save it! 


After: 

> chmod +x /usr/local/sbin/my-startup.sh
> nano /etc/systemd/system/my-startup.service 

You can write the text below: 

[Unit]
Description=My Startup
[Service]
ExecStart=/usr/local/sbin/my-startup.sh
[Install]
WantedBy=multi-user.target

Save it too!
After:

> systemctl status my-startup.service
> systemctl enable my-startup.service
> reboot

Your Server will be running when Ubuntu initialized!


After reboot your Server Ubuntu you can open Welcome of FactoryStudio, 'Server' tab
and connect again in "Remote -> Server IP" you can open your project and Run it.


In your FactoryStudio you can open "Trace Window" and you will could see information,
errors, warning and debugs of your project.


In Putty you can write "systemctl status my-startup.service" and you will see status of
project working.


On the computer, you can keep your project running and close the ‘Project Engineering’.
In ‘Welcome FactoryStudio’ you can alter the ‘Remote’ to ‘Local’ and when you need to
open your project and manage it, you need only access via “remote” again. 

  • No labels