# Smartkit Web.UP use

## How to download a OVA compatible with smartkit-web

Download the last OVA and import it in your hypervisor (ex: Virtualbox or Vmware):
* http://smeup-public-read.s3.eu-central-1.wasabisys.com/www_download/smartkit/iso/smartkit-commons-vmware-1.0.2.ova
* http://smeup-public-read.s3.eu-central-1.wasabisys.com/www_download/smartkit/iso/smartkit-commons-vbox-1.0.2.ova

## How to install or update smartkit-web

You can install on the virtual machine the smarkit-commons project that helps managing smarkits.

Or you can download a smartkit-web zipped version X.X.X from smeup repo, unzip inside /tmp dir and call installer.sh.

    cd /tmp
    wget https://repo.smeup.cloud/nexus/content/repositories/releases/com/smeup/smartkit/smartkit-web/X.X.X/smartkit-web-x.x.x-full.zip
    unzip smarkit-web-x.x.x-full.zip
    smarkit-web-x.x.x/installer.sh
    
smarkit-web dir will be ~/smarkit/smartkit-web.

To find last smartkit-web version you can use this command:

    xmllint --xpath "string(//release)" <(wget -O - "https://repo.smeup.cloud/nexus/content/repositories/releases/com/smeup/smartkit/smartkit-web/maven-metadata.xml")


## How to use smartkit-web

Call: 

    ~/smarkit/smartkit-commons/scripts/smart.sh --help

## How to install a wup net

The smartkit-web doesn't contain any running Web.UP at startup. You have to setup the software you want.

For example to create a new wup net with id prod1 (you have to choose a string made of max 6 lower case chars or numbers) call:

   * prepare configuration:
	
	~/smarkit/smartkit-web/smart.sh wupnet-create-config prod1

   * apply configuration:
	
	~/smarkit/smartkit-web/smart.sh wupnet-apply-config prod1
	
	
It will create three docker containers with these names:
* wn-prod1-webup
* wn-prod1-as400-proxy	
* wn-prod1-h53	

For each wup net ports are pre calculated on a specific portbase but you can change them if you want.

### Useful infos about a providerless Web.UP configuration

Note1: the containers are all in a docker bridge network so they can be accessed each other with container name and internal ports.

#### as400-proxy configuration

As400-proxy configuration is entirely in terraform tfvars. 

#### h53 configuration

H53 configuration is in container's etc volume configuration.properties file.

It must contains the next rows (auto filled in wup net installation):

    imageServiceUrl=http://{$webup_container_name:8080}/WebUP/services/images/download
    fileServiceUrl=http://{$webup_container_name:8080}/WebUP/services/files/download
    logLevel=DEBUG

#### Webup configuration

Optional custom mounted volumes are to be configured in terraform tfvars. There are 20 max shared volumes that can be configured. Their paths inside container will be: "/mnt/share_0", "/mnt/share_0".

All other configs can be done inside Web.UP admin UI (they will be suggested during wup net installation).

## How to check a wup net

For installation check call this command:

    ~/smarkit/smartkit-commons/scripts/smart.sh wupnet-detail prod1

This return docker status of containers and http status. Below detail of curl: 


* webup responds:

```sh
curl http://virtual-machine-ip:($portbase+8080)/WebUP
```

* as400-proxy responds:

```sh
curl http://virtual-machine-ip:($portbase+9996)/as400-proxy/openapi.yaml
```

* h53-service responds:

```sh
curl http://virtual-machine-ip:($portbase+9997)/h53/swagger.yml
```

* as400-proxy and JA_00_05 well configured inside Web.UP: login into a module, if you call the next funs you will 

   * see the content of your shared volume:
   
    F(EXB;JA_00_05;LIS.ALL) 1(J1;PATHDIR;\\srv005.smeup.com\smeup)   
    F(EXD;*SCO;) 1(J1;PATHDIR;\\srv005.smeup.com\smeup) 

   * create a sample file in your shared volume:
   
    F(INT;JA_00_05;WRI) 1(J1;PATHFILE;\\srv005.smeup.com\smeup\sample-file.txt) P(OVERW(Append) ENC(UTF-8)) INPUT(TXT(sample))

NB: permission to create and delete files must be:

    ls -lrt /mnt/
    drwxrwxrwx. 2 root root 49152 Jul 27 10:11 share_0 
    drwxrwxrwx. 2 root root  4096 Jul  9 15:06 share_1
    ...

* as400-proxy and H53 service well configured inside Web.UP: login into a Sme.UP srvlab01.smeup.com SVI module, if you call the next fun you will download a not empty pdf:

   * only text: F(G53;B£SER_43;STR.SIM) 1(MB;SCP_G53;ESE_B11) P(Opn(Yes))
   * with images: F(G53;B£SER_43;STR.SIM) 1(MB;SCP_G53;ESE_S02) P(Opn(Yes)) 
    
    
## How to see wup net logs

To see logs of a running docker container: 

```sh
docker logs container_name
```

You can find specific log files of each application in its container var dir (ex: ~/smartkit/smartkit-web/wn-prod1/containers/as400-proxy/var dir).

For webup you can find webup logs in container payara log dir (ex: ~/smartkit/smartkit-web/wn-prod1/containers/webup/payara dir). 


## How to update a wup net

To update a wup net with id prod1 call:

   * prepare configuration:

    ~/smarkit/smartkit-web/smart.sh wupnet-update-config prod1 

   * apply configuration:

    ~/smarkit/smartkit-web/smart.sh wupnet-apply-config prod1 
    
It will backup old wup net dir, it will destroy all containers and redo new containers.   

You cannot update single app version (ex: webup version), you have to update wup net version.  

If you add version you can upload to a specific smartkit-web version. If you don't give a version the last smartkit-web release software will be used.


## System requirements

At least a CPU Quad core.

Suggested for each wup net:
* 8GB RAM (Web.UP Payara Server with -Xmx4096m:-Xms2048m, h53 Payara Micro with -Xmx1024:-Xms512, as400-proxy Payara Micro with -Xmx1024:-Xms512)
* 10GB HDD
