github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/ci/dev/build.go (about)

     1  /*
     2   * Copyright (C) 2019 The "MysteriumNetwork/node" Authors.
     3   *
     4   * This program is free software: you can redistribute it and/or modify
     5   * it under the terms of the GNU General Public License as published by
     6   * the Free Software Foundation, either version 3 of the License, or
     7   * (at your option) any later version.
     8   *
     9   * This program is distributed in the hope that it will be useful,
    10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12   * GNU General Public License for more details.
    13   *
    14   * You should have received a copy of the GNU General Public License
    15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16   */
    17  
    18  package dev
    19  
    20  import (
    21  	"fmt"
    22  	"runtime"
    23  	"strings"
    24  
    25  	"github.com/magefile/mage/mg"
    26  	"github.com/magefile/mage/sh"
    27  	"github.com/mysteriumnetwork/node/ci/packages"
    28  )
    29  
    30  // Daemon builds and runs myst daemon
    31  func Daemon() error {
    32  	mg.Deps(packages.Build)
    33  
    34  	cmd := "build/myst/myst daemon"
    35  	if runtime.GOOS == "darwin" {
    36  		cmd = "sudo " + cmd
    37  	}
    38  	cmdParts := strings.Split(cmd, " ")
    39  	return sh.RunV(cmdParts[0], cmdParts[1:]...)
    40  }
    41  
    42  // Consumer builds and runs myst daemon in usermode for consumer (without sudo) - same way as it is run in the desktop client.
    43  func Consumer() error {
    44  	mg.Deps(packages.Build)
    45  	port := 44050 // Port is the same as used by the desktop app.
    46  	cmd := fmt.Sprintf("build/myst/myst --usermode --consumer --tequilapi.port=%d --ui.enable=false --discovery.type=api daemon", port)
    47  	cmdParts := strings.Split(cmd, " ")
    48  	return sh.RunV(cmdParts[0], cmdParts[1:]...)
    49  }
    50  
    51  // Openvpn builds and starts openvpn service with terms accepted
    52  func Openvpn() error {
    53  	mg.Deps(packages.Build)
    54  
    55  	cmd := "build/myst/myst service --agreed-terms-and-conditions openvpn"
    56  	if runtime.GOOS == "darwin" {
    57  		cmd = "sudo " + cmd
    58  	}
    59  	cmdParts := strings.Split(cmd, " ")
    60  	return sh.RunV(cmdParts[0], cmdParts[1:]...)
    61  }
    62  
    63  // Wireguard builds and starts wireguard service with terms accepted
    64  func Wireguard() error {
    65  	mg.Deps(packages.Build)
    66  
    67  	cmd := "build/myst/myst service --agreed-terms-and-conditions wireguard"
    68  	if runtime.GOOS == "darwin" {
    69  		cmd = "sudo " + cmd
    70  	}
    71  	cmdParts := strings.Split(cmd, " ")
    72  	return sh.RunV(cmdParts[0], cmdParts[1:]...)
    73  }
    74  
    75  // CLI builds and runs myst CLI
    76  func CLI() error {
    77  	mg.Deps(packages.Build)
    78  
    79  	return sh.RunV("build/myst/myst", "cli", "--agreed-terms-and-conditions")
    80  }