Apache configuration

Configure the apache server on alpha to accept and redirect viniswap petitions:

Domain http://viniswap.costaflores.com

<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
    ServerName viniswap.costaflores.com
    ProxyPass / http://10.112.48.25:2018/
ProxyPassReverse / http://10.112.48.25:2018/
    ProxyPass /mtb19/ http://10.112.48.25:2019/
ProxyPassReverse /mtb19/ http://10.112.48.25:2019/
    <Proxy *>
Order deny,allow
Allow from all
</Proxy>
    CustomLog logs/viniswap.costaflores.com.log combined
    ErrorLog logs/viniswap.costaflores.com.error.log
</VirtualHost>

App Installation on echo

Install NVM to upgrade NODE to an exact version

First install NVM:

[root@echo viniswap]# curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 12819 100 12819 0 0 17974 0 --:--:-- --:--:-- --:--:-- 17953
=> Downloading nvm from git to '/root/.nvm'
=> Cloning into '/root/.nvm'...
remote: Enumerating objects: 267, done.
remote: Counting objects: 100% (267/267), done.
remote: Compressing objects: 100% (242/242), done.
remote: Total 267 (delta 31), reused 80 (delta 15), pack-reused 0
Receiving objects: 100% (267/267), 119.47 KiB | 0 bytes/s, done.
Resolving deltas: 100% (31/31), done.
=> Compressing and cleaning up git repository
=> Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[root@echo viniswap]#


Once the nvm is installed, we install the v10.18 version of the node:

[root@echo viniswap]# nvm install 10.18
Downloading and installing node v10.18.1...
Downloading https://nodejs.org/dist/v10.18.1/node-v10.18.1-linux-x64.tar.xz...
######################################################################## 100,0%
Computing checksum with sha256sum
Checksums matched!
Now using node v10.18.1 (npm v6.13.4)
Creating default alias: default -> 10.18 (-> v10.18.1)
[root@echo viniswap]# node -v
v10.18.1
[root@echo viniswap]#

Install YARN

[root@echo viniswap]# curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
[yarn]
name=Yarn Repository
baseurl=https://dl.yarnpkg.com/rpm/
enabled=1
gpgcheck=1
gpgkey=https://dl.yarnpkg.com/rpm/pubkey.gpg
[root@echo viniswap]# yum install yarn
Complementos cargados:fastestmirror
Determining fastest mirrors
epel/x86_64/metalink | 28 kB 00:00:00
* base: mirror.airenetworks.es
* epel: mir01.syntis.net
* extras: repo.nixval.com
* updates: mirror.airenetworks.es
base | 3.6 kB 00:00:00
epel | 5.3 kB 00:00:00
extras | 2.9 kB 00:00:00
ius | 1.3 kB 00:00:00
nodesource | 2.5 kB 00:00:00
updates | 2.9 kB 00:00:00
yarn | 2.9 kB 00:00:00
(1/6): extras/7/x86_64/primary_db | 153 kB 00:00:01
(2/6): epel/x86_64/updateinfo | 1.0 MB 00:00:01
(3/6): updates/7/x86_64/primary_db | 5.9 MB 00:00:01
(4/6): yarn/primary_db | 21 kB 00:00:00
(5/6): epel/x86_64/primary_db | 6.9 MB 00:00:02
(6/6): ius/x86_64/primary | 170 kB 00:00:02
ius 867/867
Resolviendo dependencias
--> Ejecutando prueba de transacción
---> Paquete yarn.noarch 0:1.21.1-1 debe ser instalado
--> Resolución de dependencias finalizada
Dependencias resueltas
===================================================================================================================================================
Package Arquitectura Versión Repositorio Tamaño
===================================================================================================================================================
Instalando:
yarn noarch 1.21.1-1 yarn 1.2 M
Resumen de la transacción
===================================================================================================================================================
Instalar 1 Paquete
Tamaño total de la descarga: 1.2 M
Tamaño instalado: 5.1 M
Is this ok [y/d/N]: y
Downloading packages:
advertencia:/var/cache/yum/x86_64/7/yarn/packages/yarn-1.21.1-1.noarch.rpm: EncabezadoV4 RSA/SHA512 Signature, ID de clave 6963f07f: NOKEY-:-- ETA
No se ha instalado la llave pública de yarn-1.21.1-1.noarch.rpm
yarn-1.21.1-1.noarch.rpm | 1.2 MB 00:00:00
Obteniendo clave desde https://dl.yarnpkg.com/rpm/pubkey.gpg
Importando llave GPG 0x6963F07F:
Usuarioid : "Yarn RPM Packaging <yarn@dan.cx>"
Huella : 9a6f 73f3 4beb 7473 4d8c 6914 9cbb b558 6963 f07f
Desde : https://dl.yarnpkg.com/rpm/pubkey.gpg
Está de acuerdo [s/N]:s
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Instalando : yarn-1.21.1-1.noarch 1/1
Comprobando : yarn-1.21.1-1.noarch 1/1
Instalado:
yarn.noarch 0:1.21.1-1
¡Listo!
[root@echo viniswap]# yarn -v
1.21.1
[root@echo viniswap]#

Install VINISWAP

Follow instruccions of GitHub proyect on https://github.com/OpenVino/viniswap

Clone the project:

[root@echo viniswap]# git clone https://github.com/OpenVino/viniswap.git
Cloning into 'viniswap'...
remote: Enumerating objects: 327, done.
remote: Counting objects: 100% (327/327), done.
remote: Compressing objects: 100% (157/157), done.
remote: Total 1236 (delta 188), reused 258 (delta 131), pack-reused 909
Receiving objects: 100% (1236/1236), 4.69 MiB | 4.23 MiB/s, done.
Resolving deltas: 100% (743/743), done.
Tiene correo nuevo en /var/spool/mail/root
[root@echo viniswap]# ll
total 4
drwxr-xr-x 6 root root 4096 ene 10 13:43 viniswap
[root@echo viniswap]#


Rename de new folder for MTB18 app:

[root@echo viniswap]# mv viniswap/ viniswapMTB18/


Go to new folder:

[root@echo viniswap]# cd viniswapMTB18


Create .env file and paste configuration code for MTB18:

SKIP_PREFLIGHT_CHECK=true
REACT_APP_PROVIDER_URL=https://mainnet.infura.io/v3/XXXXXXXX
REACT_APP_TOKEN_NAME=MTB18
REACT_APP_TOKEN_SUPPLY=16384
REACT_APP_TOKEN_ADDRESS=0x1bcfd19f541eb62c8cfebe53fe72bf2afc35a255
REACT_APP_REDEEM_MESSAGE='You can redeem your MTB18 tokens for bottles of wine, starting on May 6, 2021.'
PORT=2018

Finally install VINISWAP for MTB18

[root@echo viniswapMTB18]# yarn install

Start VINISWAP

[root@echo viniswapMTB18]# yarn start

Install VINISWAP for MTB19

Go to /opt/viniswap/ forder and clone again the project.

[root@echo viniswap]# git clone https://github.com/OpenVino/viniswap.git


Rename de new folder for MTB19 app:

[root@echo viniswap]# mv viniswap/ viniswapMTB19/


Go to new folder:

[root@echo viniswap]# cd viniswapMTB19


Create .env file and paste configuration code for MTB19:

SKIP_PREFLIGHT_CHECK=true
REACT_APP_PROVIDER_URL=https://mainnet.infura.io/v3/XXXXXXXX
REACT_APP_TOKEN_NAME=MTB19
REACT_APP_TOKEN_SUPPLY=17707
REACT_APP_TOKEN_ADDRESS=0x87ab739464881af0011052d4ca0b0d657e8c3b48
REACT_APP_REDEEM_MESSAGE='You can redeem your MTB19 tokens for bottles of wine, starting on May 6, 2022.'
PORT=2019


Finally install VINISWAP for MTB19

[root@echo viniswapMTB19]# yarn install

Automate the viniswap app boot on echo

Create a user and group viniswap, and change ownership of everything in /opt/viniswap

Set up a systemctl service that starts the  /etc/systemd/system/viniswap-mtb18.service file:


vi /etc/systemd/system/viniswap-mtb18.service


[Unit]
Description=-Viniswap exchange app for MTB18
After=network.target

[Service]
Type=simple
Restart=always
RestartSec=1
User=root
ExecStart= /bin/yarn start 
WorkingDirectory=/opt/viniswap/viniswapMTB18
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=viniswapMTB18
User=viniswap
Group=viniswap

[Install]
WantedBy=multi-user.target


Finally, reload the daemon list and to test and enable it to run on boot using this commands:


Enable the Service:

systemctl enable viniswap-mtb18.service

Restart the daemon

systemctl daemon-reload

Start the service

systemctl start viniswap-mtb18.service

Restart the service (to test)

sudo systemctl restart viniswap-mtb18.service

Show logs

tail -f /var/log/messages