Using the Install Script

A step-by-step guide on how to prepare a fully-functional Development environment using the install script.

Getting Started

The instructions on this page will guide you through creating a new user account with the correct privileges, installing and configuring Mainsail Core, then starting a node instance and logging the output using the installation script.

Directly below is a quick summary of these install commands:

sudo adduser mainsail
sudo usermod -a -G sudo mainsail
sudo su - mainsail

wget https://raw.githubusercontent.com/ArkEcosystem/mainsail/develop/scripts/install-testnet.sh
chmod +x install-testnet.sh
./install-testnet.sh

mainsail core:start

pm2 logs

Step-by-Step Installation via the Script

If you are planning to setup a new server you can execute the following steps.

Step 1: Create a New Account

Create a new dedicated user account to manage Mainsail-related software.

We’ll illustrate this command as sudo adduser mainsail to create a user by the name of ‘mainsail’, but you can chose something else, if preferred.

On your server, type the following into the command line:

sudo adduser mainsail

You'll be asked to create and confirm a new user password, and be prompted to enter the user’s full name and some other information. (Feel free to leave them blank by pressing ‘enter’, they are all optional fields.)

When prompted to confirm, type ‘Y’ and press ‘enter’ to finish.

Adding user `mainsail' ...
Adding new group `mainsail' (1001) ...
Adding new user `mainsail' (1001) with group `mainsail' ...
Creating home directory `/home/mainsail' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for mainsail
Enter the new value, or press ENTER for the default
    Full Name []:
    Room Number []:
    Work Phone []:
    Home Phone []:
    Other []:
Is the information correct? [Y/n] Y

Step 2: Grant Sudo Privileges

Next, we need to make sure that our user account has all of the necessary privileges to run Mainsail software properly. This will give our user account sudo privileges.

Type or copy-paste the following command into your terminal:

sudo usermod -a -G sudo mainsail

Step 3: Login as the New User

We now should switch to the user account created above, this will also land us in the user's base directory (~/).

Type or copy-paste the following command into your terminal:

sudo su - mainsail

Step 4: Run the Installation Script

Here, we will use the install-testnet.sh script. This installs Mainsail Core and all of its dependencies onto your server, then publishes the configuration files for it.

You can download script by copying and pasting this one line command into your terminal:

wget https://raw.githubusercontent.com/ArkEcosystem/mainsail/develop/scripts/install-testnet.sh
chmod +x install-testnet.sh

Then, run the install script by copying and pasting this one line command into your terminal:

bash install-testnet.sh

You will be asked to input your user password to grant sudo privileges:

[sudo] password for mainsail: <input your password for user you created>

At this point, Mainsail Core has been successfully installed with it's configuration options properly published.

Success

That’s it, your installation is all set! 🎉

API installation

Mainsail core installation comes without the active API server. Additional steps are required to install the API server. Once installed API server for Mainsail will be available as mainsail-api CLI command.

The easiest way to install the API server is to use the install-testnet.sh script. This script will install the API server and all of its dependencies onto your server, then publish the configuration files for it. API server can be installed besides the Mainsail Core server or on a separate node. We will illustrate the installation on the same node as the core server.

To install the API server, you can use the following commands:

./install-testnet.sh --api

mainsail-api api:start

pm2 logs

Step-by-Step API Installation via the Script

Step 1: Ensure the user account exist with sudo privileges

Ensure the user account has all of the necessary privileges to run Mainsail software properly. This will give our user account sudo privileges. We already created a user account in the previous steps when we install Mainsail core, so we can skip this step.

sudo adduser mainsail
sudo usermod -a -G sudo mainsail
sudo su - mainsail

Step 2: Run the Installation Script

Run the install script by copying and pasting this one line command into your terminal. Be aware that the --api flag is used to install the API server.

./install-testnet.sh --api

You will be asked to input your user password to grant sudo privileges:

[sudo] password for mainsail: <input your password for user you created>

Step 3: Configure PostgreSQL database

After the installation of the API server, you will be asked to configure the database. You can use the following example to configure the database:

    ==> Installed PostgreSQL!
Would you like to configure the database? [y/N]: y
Enter the database username: ark
Enter the database password: password
Enter the database name: ark_testnet
database username: ark
database password: password
database name: ark_testnet
Proceed? [y/N]: y

This will create a PostgreSQL role and database to be used for storing blockchain data.

Step 4: Configure Mainsail core

After the installation of the API server, you will be asked to configure the Mainsail core. You can use the following example to configure the Mainsail. Following configuration will update Mainsail configuration to use the PostgreSQL database for API server.

    ==> Installed Mainsail API Server!
Are you going to run the backend Core server on the same node? [y/N]: y