mirror of
https://github.com/creating2morrow/neveko.git
synced 2025-01-03 09:29:39 +00:00
add monero to installation manager
This commit is contained in:
parent
3ba866277c
commit
4f5ad19c7b
6 changed files with 131 additions and 5 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -8,4 +8,5 @@ genkey-batch
|
||||||
monero-wallet-rpc.log
|
monero-wallet-rpc.log
|
||||||
notes.txt
|
notes.txt
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
.bz2
|
*.bz2
|
||||||
|
*/monero-x86_64-linux-gnu-v0.18.2.2/**
|
||||||
|
|
|
@ -15,4 +15,7 @@ pub mod user; // user rep/service layer
|
||||||
pub const NEVMES_JWP_SECRET_KEY: &str = "NEVMES_JWP_SECRET_KEY";
|
pub const NEVMES_JWP_SECRET_KEY: &str = "NEVMES_JWP_SECRET_KEY";
|
||||||
pub const NEVMES_JWT_SECRET_KEY: &str = "NEVMES_JWT_SECRET_KEY";
|
pub const NEVMES_JWT_SECRET_KEY: &str = "NEVMES_JWT_SECRET_KEY";
|
||||||
|
|
||||||
|
// set the latest monero release download here
|
||||||
|
pub const MONERO_RELEASE_VERSION: &str = "monero-linux-x64-v0.18.2.2.tar.bz2";
|
||||||
|
|
||||||
// DO NOT EDIT BELOW THIS LINE
|
// DO NOT EDIT BELOW THIS LINE
|
||||||
|
|
|
@ -238,7 +238,7 @@ pub async fn retry_fts() {
|
||||||
let list_key = format!("fts");
|
let list_key = format!("fts");
|
||||||
let r = db::Interface::read(&s.env, &s.handle, &String::from(list_key));
|
let r = db::Interface::read(&s.env, &s.handle, &String::from(list_key));
|
||||||
if r == utils::empty_string() {
|
if r == utils::empty_string() {
|
||||||
error!("fts message index not found");
|
info!("fts message index not found");
|
||||||
}
|
}
|
||||||
let v_mid = r.split(",");
|
let v_mid = r.split(",");
|
||||||
let v: Vec<String> = v_mid.map(|s| String::from(s)).collect();
|
let v: Vec<String> = v_mid.map(|s| String::from(s)).collect();
|
||||||
|
|
|
@ -1,10 +1,27 @@
|
||||||
use rand_core::RngCore;
|
use rand_core::RngCore;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use rocket::serde::json::Json;
|
use rocket::serde::json::Json;
|
||||||
use crate::{args, db, i2p, message, models, monero, gpg, utils, reqres};
|
use crate::{args, db, i2p, message, models, monero, gpg, utils, reqres, MONERO_RELEASE_VERSION };
|
||||||
use log::{info, debug, error, warn};
|
use log::{info, debug, error, warn};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
/// Handles the state for the installation manager popup
|
||||||
|
pub struct Installations {
|
||||||
|
pub xmr: bool,
|
||||||
|
pub i2p: bool,
|
||||||
|
pub i2p_zero: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Installations {
|
||||||
|
fn default() -> Self {
|
||||||
|
Installations {
|
||||||
|
xmr: false,
|
||||||
|
i2p: false,
|
||||||
|
i2p_zero: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Handles the state for the connection manager popup
|
/// Handles the state for the connection manager popup
|
||||||
pub struct Connections {
|
pub struct Connections {
|
||||||
pub blockchain_dir: String,
|
pub blockchain_dir: String,
|
||||||
|
@ -378,3 +395,38 @@ pub fn stage_cleanup(f: String) {
|
||||||
.expect("cleanup staging failed");
|
.expect("cleanup staging failed");
|
||||||
debug!("{:?}", output.stdout);
|
debug!("{:?}", output.stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Handle the request from user to additional software
|
||||||
|
///
|
||||||
|
/// from gui startup. Power users will most like install
|
||||||
|
///
|
||||||
|
/// software on their own. Note that software pull is over
|
||||||
|
///
|
||||||
|
/// clearnet. TODO(c2m): trusted download locations over i2p.
|
||||||
|
pub async fn install_software(installations: Installations) {
|
||||||
|
if installations.i2p {
|
||||||
|
info!("installing i2p");
|
||||||
|
}
|
||||||
|
if installations.i2p_zero {
|
||||||
|
info!("installing i2p-zero");
|
||||||
|
}
|
||||||
|
if installations.xmr {
|
||||||
|
info!("installing monero");
|
||||||
|
let link = format!("https://downloads.getmonero.org/cli/{}", crate::MONERO_RELEASE_VERSION);
|
||||||
|
let curl = std::process::Command::new("curl")
|
||||||
|
.args(["-O#", &link])
|
||||||
|
.status();
|
||||||
|
match curl {
|
||||||
|
Ok(curl_output) => {
|
||||||
|
debug!("{:?}", curl_output);
|
||||||
|
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||||
|
let tar_output = std::process::Command::new("tar")
|
||||||
|
.args(["-xvf", MONERO_RELEASE_VERSION])
|
||||||
|
.spawn()
|
||||||
|
.expect("monero tar extraction failed");
|
||||||
|
debug!("{:?}", tar_output.stdout);
|
||||||
|
},
|
||||||
|
_=> error!("monero download failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,9 +12,13 @@ pub struct HomeApp {
|
||||||
connections: utils::Connections,
|
connections: utils::Connections,
|
||||||
core_timeout_tx: Sender<bool>,
|
core_timeout_tx: Sender<bool>,
|
||||||
core_timeout_rx: Receiver<bool>,
|
core_timeout_rx: Receiver<bool>,
|
||||||
|
installations: utils::Installations,
|
||||||
|
installation_tx: Sender<bool>,
|
||||||
|
installation_rx: Receiver<bool>,
|
||||||
is_core_running: bool,
|
is_core_running: bool,
|
||||||
is_editing_connections: bool,
|
is_editing_connections: bool,
|
||||||
is_init: bool,
|
is_init: bool,
|
||||||
|
is_installing: bool,
|
||||||
is_loading: bool,
|
is_loading: bool,
|
||||||
is_timeout: bool,
|
is_timeout: bool,
|
||||||
is_updated: bool,
|
is_updated: bool,
|
||||||
|
@ -46,9 +50,11 @@ pub struct HomeApp {
|
||||||
impl Default for HomeApp {
|
impl Default for HomeApp {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let connections = Default::default();
|
let connections = Default::default();
|
||||||
|
let installations = Default::default();
|
||||||
let is_core_running = false;
|
let is_core_running = false;
|
||||||
let is_editing_connections = false;
|
let is_editing_connections = false;
|
||||||
let is_init = true;
|
let is_init = true;
|
||||||
|
let is_installing = false;
|
||||||
let is_loading = false;
|
let is_loading = false;
|
||||||
let is_timeout = false;
|
let is_timeout = false;
|
||||||
let is_updated = false;
|
let is_updated = false;
|
||||||
|
@ -59,6 +65,7 @@ impl Default for HomeApp {
|
||||||
let (xmr_balance_tx, xmr_balance_rx) = std::sync::mpsc::channel();
|
let (xmr_balance_tx, xmr_balance_rx) = std::sync::mpsc::channel();
|
||||||
let (can_refresh_tx, can_refresh_rx) = std::sync::mpsc::channel();
|
let (can_refresh_tx, can_refresh_rx) = std::sync::mpsc::channel();
|
||||||
let (i2p_status_tx, i2p_status_rx) = std::sync::mpsc::channel();
|
let (i2p_status_tx, i2p_status_rx) = std::sync::mpsc::channel();
|
||||||
|
let (installation_tx, installation_rx) = std::sync::mpsc::channel();
|
||||||
let s_xmr_rpc_ver = Default::default();
|
let s_xmr_rpc_ver = Default::default();
|
||||||
let s_xmr_address = Default::default();
|
let s_xmr_address = Default::default();
|
||||||
let s_xmr_balance = Default::default();
|
let s_xmr_balance = Default::default();
|
||||||
|
@ -73,9 +80,13 @@ impl Default for HomeApp {
|
||||||
connections,
|
connections,
|
||||||
core_timeout_rx,
|
core_timeout_rx,
|
||||||
core_timeout_tx,
|
core_timeout_tx,
|
||||||
|
installations,
|
||||||
|
installation_rx,
|
||||||
|
installation_tx,
|
||||||
is_core_running,
|
is_core_running,
|
||||||
is_editing_connections,
|
is_editing_connections,
|
||||||
is_init,
|
is_init,
|
||||||
|
is_installing,
|
||||||
is_loading,
|
is_loading,
|
||||||
is_timeout,
|
is_timeout,
|
||||||
is_updated,
|
is_updated,
|
||||||
|
@ -126,11 +137,16 @@ impl eframe::App for HomeApp {
|
||||||
if let Ok(info) = self.xmrd_get_info_rx.try_recv() {
|
if let Ok(info) = self.xmrd_get_info_rx.try_recv() {
|
||||||
self.s_xmrd_get_info = info;
|
self.s_xmrd_get_info = info;
|
||||||
}
|
}
|
||||||
|
if let Ok(install) = self.installation_rx.try_recv() {
|
||||||
|
self.is_installing = !install;
|
||||||
|
self.is_loading = false;
|
||||||
|
}
|
||||||
if let Ok(timeout) = self.core_timeout_rx.try_recv() {
|
if let Ok(timeout) = self.core_timeout_rx.try_recv() {
|
||||||
self.is_timeout = true;
|
self.is_timeout = true;
|
||||||
if timeout {
|
if timeout {
|
||||||
self.is_loading = false;
|
self.is_loading = false;
|
||||||
self.is_core_running = false;
|
self.is_core_running = false;
|
||||||
|
self.is_installing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +210,38 @@ impl eframe::App for HomeApp {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Installation Manager window
|
||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
let mut is_installing = self.is_installing;
|
||||||
|
egui::Window::new("Installation Manager")
|
||||||
|
.open(&mut is_installing)
|
||||||
|
.vscroll(true)
|
||||||
|
.show(&ctx, |ui| {
|
||||||
|
// let mut wants_i2p = self.installations.i2p;
|
||||||
|
// let mut wants_i2p_zero = self.installations.i2p_zero;
|
||||||
|
let mut wants_xmr = self.installations.xmr;
|
||||||
|
// if ui.checkbox(&mut wants_i2p, "i2p").changed() {
|
||||||
|
// self.installations.i2p = !self.installations.i2p;
|
||||||
|
// }
|
||||||
|
// if ui.checkbox(&mut wants_i2p_zero, "i2p-zero").changed() {
|
||||||
|
// self.installations.i2p_zero = !self.installations.i2p_zero;
|
||||||
|
// }
|
||||||
|
if ui.checkbox(&mut wants_xmr, "xmr").changed() {
|
||||||
|
self.installations.xmr = !self.installations.xmr;
|
||||||
|
}
|
||||||
|
let install = &self.installations;
|
||||||
|
if install.i2p || install.i2p_zero || install.xmr {
|
||||||
|
if ui.button("Install").clicked() {
|
||||||
|
self.is_loading = true;
|
||||||
|
install_software_req(self.installation_tx.clone(), ctx.clone(), &self.installations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ui.button("Exit").clicked() {
|
||||||
|
self.is_installing = false;
|
||||||
|
self.is_loading = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
if !self.is_updated {
|
if !self.is_updated {
|
||||||
|
@ -245,8 +293,9 @@ impl eframe::App for HomeApp {
|
||||||
ui.label("____________________________________________________________________\n");
|
ui.label("____________________________________________________________________\n");
|
||||||
ui.label("\n");
|
ui.label("\n");
|
||||||
if self.is_loading {
|
if self.is_loading {
|
||||||
|
let label = if self.is_installing { "installing software" } else { "starting nevmes-core..." };
|
||||||
ui.add(egui::Spinner::new());
|
ui.add(egui::Spinner::new());
|
||||||
ui.label("starting nevmes-core...");
|
ui.label(label);
|
||||||
}
|
}
|
||||||
if !self.is_core_running && self.s_xmr_rpc_ver.result.version == 0 {
|
if !self.is_core_running && self.s_xmr_rpc_ver.result.version == 0 {
|
||||||
if !self.is_loading {
|
if !self.is_loading {
|
||||||
|
@ -255,6 +304,14 @@ impl eframe::App for HomeApp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !self.is_core_running && !self.is_installing
|
||||||
|
&& (self.s_xmr_rpc_ver.result.version == 0 || self.s_i2p_status) {
|
||||||
|
if !self.is_loading {
|
||||||
|
if ui.button("Install Software").clicked() {
|
||||||
|
self.is_installing = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,3 +379,17 @@ fn start_core_timeout
|
||||||
ctx.request_repaint();
|
ctx.request_repaint();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn install_software_req
|
||||||
|
(tx: Sender<bool>, ctx: egui::Context, installations: &utils::Installations) {
|
||||||
|
let req_install: utils::Installations = utils::Installations {
|
||||||
|
i2p: installations.i2p,
|
||||||
|
i2p_zero: installations.i2p_zero,
|
||||||
|
xmr: installations.xmr,
|
||||||
|
};
|
||||||
|
tokio::spawn(async move {
|
||||||
|
utils::install_software(req_install).await;
|
||||||
|
let _ = tx.send(true);
|
||||||
|
ctx.request_repaint();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ use sha2::{Digest, Sha512};
|
||||||
|
|
||||||
use crate::CREDENTIAL_KEY;
|
use crate::CREDENTIAL_KEY;
|
||||||
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct SettingsApp {
|
pub struct SettingsApp {
|
||||||
credential: String,
|
credential: String,
|
||||||
|
|
Loading…
Reference in a new issue