Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cd5ef65d3d | |||
| 7bf9ca6201 | |||
| f587b42797 | |||
| 7ae464e172 |
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.88"
|
version = "0.1.92"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -301,7 +301,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.88"
|
version = "0.1.92"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -324,7 +324,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.88"
|
version = "0.1.92"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.88"
|
version = "0.1.92"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.88"
|
version = "0.1.92"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ pub struct SystemConfig {
|
|||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct SshConfig {
|
pub struct SshConfig {
|
||||||
pub rebuild_user: String,
|
pub rebuild_user: String,
|
||||||
pub rebuild_alias: String,
|
pub rebuild_cmd: String,
|
||||||
pub backup_alias: String,
|
pub service_manage_cmd: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Service log file configuration per host
|
/// Service log file configuration per host
|
||||||
|
|||||||
@@ -220,12 +220,12 @@ impl TuiApp {
|
|||||||
let connection_ip = self.get_connection_ip(&hostname);
|
let connection_ip = self.get_connection_ip(&hostname);
|
||||||
// Create command that shows logo, rebuilds, and waits for user input
|
// Create command that shows logo, rebuilds, and waits for user input
|
||||||
let logo_and_rebuild = format!(
|
let logo_and_rebuild = format!(
|
||||||
"echo 'Rebuilding system: {} ({})' && ssh -tt {}@{} \"bash -ic {}\" && echo 'Press any key to close...' && read -n 1 -s",
|
"echo 'Rebuilding system: {} ({})' && ssh -tt {}@{} \"bash -ic '{}'\"",
|
||||||
hostname,
|
hostname,
|
||||||
connection_ip,
|
connection_ip,
|
||||||
self.config.ssh.rebuild_user,
|
self.config.ssh.rebuild_user,
|
||||||
connection_ip,
|
connection_ip,
|
||||||
self.config.ssh.rebuild_alias
|
self.config.ssh.rebuild_cmd
|
||||||
);
|
);
|
||||||
|
|
||||||
std::process::Command::new("tmux")
|
std::process::Command::new("tmux")
|
||||||
@@ -244,12 +244,12 @@ impl TuiApp {
|
|||||||
let connection_ip = self.get_connection_ip(&hostname);
|
let connection_ip = self.get_connection_ip(&hostname);
|
||||||
// Create command that shows logo, runs backup, and waits for user input
|
// Create command that shows logo, runs backup, and waits for user input
|
||||||
let logo_and_backup = format!(
|
let logo_and_backup = format!(
|
||||||
"echo 'Running backup: {} ({})' && ssh -tt {}@{} \"bash -ic {}\" && echo 'Press any key to close...' && read -n 1 -s",
|
"echo 'Running backup: {} ({})' && ssh -tt {}@{} \"bash -ic '{}'\"",
|
||||||
hostname,
|
hostname,
|
||||||
connection_ip,
|
connection_ip,
|
||||||
self.config.ssh.rebuild_user,
|
self.config.ssh.rebuild_user,
|
||||||
connection_ip,
|
connection_ip,
|
||||||
self.config.ssh.backup_alias
|
format!("{} start borgbackup", self.config.ssh.service_manage_cmd)
|
||||||
);
|
);
|
||||||
|
|
||||||
std::process::Command::new("tmux")
|
std::process::Command::new("tmux")
|
||||||
@@ -267,14 +267,12 @@ impl TuiApp {
|
|||||||
if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) {
|
if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) {
|
||||||
let connection_ip = self.get_connection_ip(&hostname);
|
let connection_ip = self.get_connection_ip(&hostname);
|
||||||
let service_start_command = format!(
|
let service_start_command = format!(
|
||||||
"echo 'Starting service: {} on {}' && ssh -tt {}@{} \"sudo systemctl start {} & sudo journalctl -fu {} --since=\\\"1 second ago\\\" --no-pager & while ! systemctl is-active {} >/dev/null 2>&1; do sleep 0.5; done; sudo pkill -f 'journalctl -fu {}' 2>/dev/null || true; echo 'Press any key to close...'; read -n 1 -s\"",
|
"echo 'Starting service: {} on {}' && ssh -tt {}@{} \"bash -ic '{} start {}'\"",
|
||||||
service_name,
|
service_name,
|
||||||
hostname,
|
hostname,
|
||||||
self.config.ssh.rebuild_user,
|
self.config.ssh.rebuild_user,
|
||||||
connection_ip,
|
connection_ip,
|
||||||
service_name,
|
self.config.ssh.service_manage_cmd,
|
||||||
service_name,
|
|
||||||
service_name,
|
|
||||||
service_name
|
service_name
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -293,14 +291,12 @@ impl TuiApp {
|
|||||||
if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) {
|
if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) {
|
||||||
let connection_ip = self.get_connection_ip(&hostname);
|
let connection_ip = self.get_connection_ip(&hostname);
|
||||||
let service_stop_command = format!(
|
let service_stop_command = format!(
|
||||||
"echo 'Stopping service: {} on {}' && ssh -tt {}@{} \"sudo systemctl stop {} & sudo journalctl -fu {} --since=\\\"1 second ago\\\" --no-pager & sleep 1; while systemctl is-active {} >/dev/null 2>&1; do sleep 0.5; done; sleep 2; sudo pkill -f 'journalctl -fu {}' 2>/dev/null || true; echo 'Press any key to close...'; read -n 1 -s\"",
|
"echo 'Stopping service: {} on {}' && ssh -tt {}@{} \"bash -ic '{} stop {}'\"",
|
||||||
service_name,
|
service_name,
|
||||||
hostname,
|
hostname,
|
||||||
self.config.ssh.rebuild_user,
|
self.config.ssh.rebuild_user,
|
||||||
connection_ip,
|
connection_ip,
|
||||||
service_name,
|
self.config.ssh.service_manage_cmd,
|
||||||
service_name,
|
|
||||||
service_name,
|
|
||||||
service_name
|
service_name
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -397,7 +393,7 @@ impl TuiApp {
|
|||||||
if let Some(hostname) = self.current_host.clone() {
|
if let Some(hostname) = self.current_host.clone() {
|
||||||
let connection_ip = self.get_connection_ip(&hostname);
|
let connection_ip = self.get_connection_ip(&hostname);
|
||||||
let ssh_command = format!(
|
let ssh_command = format!(
|
||||||
"echo 'Opening SSH terminal to: {}' && ssh -tt {}@{} && echo 'Press any key to close...' && read -n 1 -s",
|
"echo 'Opening SSH terminal to: {}' && ssh -tt {}@{}",
|
||||||
hostname,
|
hostname,
|
||||||
self.config.ssh.rebuild_user,
|
self.config.ssh.rebuild_user,
|
||||||
connection_ip
|
connection_ip
|
||||||
|
|||||||
@@ -209,36 +209,13 @@ impl ServicesWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get currently selected service name (for actions)
|
/// Get currently selected service name (for actions)
|
||||||
|
/// Only returns parent service names since only parent services can be selected
|
||||||
pub fn get_selected_service(&self) -> Option<String> {
|
pub fn get_selected_service(&self) -> Option<String> {
|
||||||
// Build the same display list to find the selected service
|
// Only parent services can be selected, so just get the parent service at selected_index
|
||||||
let mut display_lines: Vec<(String, Status, bool, Option<(ServiceInfo, bool)>, String)> = Vec::new();
|
|
||||||
|
|
||||||
let mut parent_services: Vec<_> = self.parent_services.iter().collect();
|
let mut parent_services: Vec<_> = self.parent_services.iter().collect();
|
||||||
parent_services.sort_by(|(a, _), (b, _)| a.cmp(b));
|
parent_services.sort_by(|(a, _), (b, _)| a.cmp(b));
|
||||||
|
|
||||||
for (parent_name, parent_info) in parent_services {
|
|
||||||
let parent_line = self.format_parent_service_line(parent_name, parent_info);
|
|
||||||
display_lines.push((parent_line, parent_info.widget_status, false, None, parent_name.clone()));
|
|
||||||
|
|
||||||
if let Some(sub_list) = self.sub_services.get(parent_name) {
|
|
||||||
let mut sorted_subs = sub_list.clone();
|
|
||||||
sorted_subs.sort_by(|(a, _), (b, _)| a.cmp(b));
|
|
||||||
|
|
||||||
for (i, (sub_name, sub_info)) in sorted_subs.iter().enumerate() {
|
|
||||||
let is_last_sub = i == sorted_subs.len() - 1;
|
|
||||||
let full_sub_name = format!("{}_{}", parent_name, sub_name);
|
|
||||||
display_lines.push((
|
|
||||||
sub_name.clone(),
|
|
||||||
sub_info.widget_status,
|
|
||||||
true,
|
|
||||||
Some((sub_info.clone(), is_last_sub)),
|
|
||||||
full_sub_name,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
display_lines.get(self.selected_index).map(|(_, _, _, _, raw_name)| raw_name.clone())
|
parent_services.get(self.selected_index).map(|(name, _)| name.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get total count of selectable services (parent services only, not sub-services)
|
/// Get total count of selectable services (parent services only, not sub-services)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.88"
|
version = "0.1.92"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
Reference in New Issue
Block a user