mirror of
https://github.com/EvernodeXRPL/sashimono.git
synced 2026-07-30 10:30:23 +00:00
Added env variable to enable sashi create (#305)
This commit is contained in:
@@ -49,7 +49,13 @@ class SashiCLI {
|
||||
execSashiCli(msg) {
|
||||
this.#waiting = true;
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(`${this.cliPath} json -m '${JSON.stringify(msg)}'`, { stdio: 'pipe' }, (err, stdout, stderr) => {
|
||||
let command = `${this.cliPath} json -m '${JSON.stringify(msg)}'`;
|
||||
|
||||
if (msg.type === "create") {
|
||||
command = `DEV_MODE=1 ${command}`;
|
||||
}
|
||||
|
||||
exec(command, { stdio: 'pipe' }, (err, stdout, stderr) => {
|
||||
this.#waiting = false;
|
||||
|
||||
if (err || stderr) {
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "cli-manager.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
#define DEV_MODE "DEV_MODE"
|
||||
|
||||
std::string exec_dir;
|
||||
|
||||
/**
|
||||
@@ -90,6 +92,7 @@ int parse_cmd(int argc, char **argv)
|
||||
std::string json_message;
|
||||
json->add_option("-m,--message", json_message, "JSON message");
|
||||
|
||||
create->group(""); //Hides 'create' command from help-all
|
||||
std::string owner, contract_id, image, outbound_ipv6, outbound_net_interface;
|
||||
create->add_option("-o,--owner", owner, "Hex (ed-prefixed) public key of the instance owner");
|
||||
create->add_option("-c,--contract-id", contract_id, "Contract Id (GUID) of the instance");
|
||||
@@ -126,6 +129,25 @@ int parse_cmd(int argc, char **argv)
|
||||
}
|
||||
|
||||
// Verifying subcommands.
|
||||
|
||||
bool is_dev_mode = (getenv(DEV_MODE) != nullptr);
|
||||
|
||||
if (!is_dev_mode)
|
||||
{
|
||||
if(create->parsed()){
|
||||
std::cout << "Developer mode must be enabled to access this command." << std::endl;
|
||||
return -1;
|
||||
}
|
||||
if(json->parsed()){
|
||||
jsoncons::json json_data = jsoncons::json::parse(json_message);
|
||||
if (json_data.contains("type") && json_data["type"].as_string() == "create")
|
||||
{
|
||||
std::cout << "Developer mode must be enabled to access this command." << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version->parsed())
|
||||
{
|
||||
std::cout << "Sashimono CLI version " << version::CLI_VERSION << std::endl;
|
||||
|
||||
@@ -473,7 +473,7 @@ if [ $mode == "create" ] || [ $mode == "createall" ]; then
|
||||
config=$(echo "$config" | jq -c ".mesh.known_peers = [$peers]" | jq -c ".contract.unl = [\"$pubkey\"]")
|
||||
fi
|
||||
|
||||
command="sashi json -m '{\"type\":\"create\",\"owner_pubkey\":\"$ownerpubkey\",\"contract_id\":\"$contractid\",\"image\":\"$image\",\"config\":$config}'"
|
||||
command="DEV_MODE=1 sashi json -m '{\"type\":\"create\",\"owner_pubkey\":\"$ownerpubkey\",\"contract_id\":\"$contractid\",\"image\":\"$image\",\"config\":$config}'"
|
||||
output=$(sshskp $sshuser@$hostaddr $command | tr '\0' '\n')
|
||||
# If an output received consider updating the json file.
|
||||
if [ ! "$output" = "" ]; then
|
||||
|
||||
Reference in New Issue
Block a user