Merge pull request 'Merge dev in testing: Fix: mount/unmount melden Fehlschläge jetzt korrekt, Logs im Journal sichtbar und persistent' (#6) from dev into testing
Unit-Tests / Unit-Tests (pull_request) Skipped
Auto-PR (Testing → Main) / Erstelle automatisch PR von testing nach main (push) Successful in 12s
Testing Build, Publish & Preview Release / Erkenne relevante Code-Änderungen (push) Successful in 12s
TruffleHog Secret Scan / TruffleHog (pull_request) Successful in 26s
Security Scans / Trivy & OSV-Scanner (push) Successful in 43s
Security Scans / Trivy & OSV-Scanner (pull_request) Successful in 43s
Testing Build, Publish & Preview Release / Build, Publish Packages (Testing) & Create Preview Release (push) Successful in 15m53s
TruffleHog Secret Scan / TruffleHog (push) Successful in 10s
Unit-Tests / Unit-Tests (pull_request) Skipped
Auto-PR (Testing → Main) / Erstelle automatisch PR von testing nach main (push) Successful in 12s
Testing Build, Publish & Preview Release / Erkenne relevante Code-Änderungen (push) Successful in 12s
TruffleHog Secret Scan / TruffleHog (pull_request) Successful in 26s
Security Scans / Trivy & OSV-Scanner (push) Successful in 43s
Security Scans / Trivy & OSV-Scanner (pull_request) Successful in 43s
Testing Build, Publish & Preview Release / Build, Publish Packages (Testing) & Create Preview Release (push) Successful in 15m53s
TruffleHog Secret Scan / TruffleHog (push) Successful in 10s
Reviewed-on: #6
This commit was merged in pull request #6.
This commit is contained in:
Generated
+1
-1
@@ -2052,7 +2052,7 @@ checksum = "ba467056f1b547ed52077911161fc86985becbc60e8e1857c8a144dab0def891"
|
||||
|
||||
[[package]]
|
||||
name = "smart-mount"
|
||||
version = "2.0.2"
|
||||
version = "2.0.3"
|
||||
dependencies = [
|
||||
"aes-gcm 0.11.1",
|
||||
"anyhow",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "smart-mount"
|
||||
version = "2.0.2"
|
||||
version = "2.0.3"
|
||||
edition = "2024"
|
||||
authors = ['DragonSlayer_14']
|
||||
readme = "README.md"
|
||||
|
||||
@@ -162,6 +162,15 @@ sudo systemctl edit smart-mount-watch.timer
|
||||
# OnUnitActiveSec=60s
|
||||
```
|
||||
|
||||
**Logs:** beide Units schreiben mit festem `SyslogIdentifier=smart-mount` ins systemd-Journal -
|
||||
`journalctl -u smart-mount-mount` / `-u smart-mount-watch` (oder gebündelt `journalctl -t
|
||||
smart-mount`) zeigt sie an. Zusätzlich schreibt smart-mount dieselben Meldungen dauerhaft nach
|
||||
`/var/log/smart-mount/log-<Datum>.log` (siehe `settings.log_level` für die Ausführlichkeit,
|
||||
Standard `info`) - unabhängig von der Journal-Rotation. `smart-mount-mount.service` bleibt nach
|
||||
einem erfolgreichen Lauf als "active (exited)" sichtbar (`RemainAfterExit=yes`), und ein
|
||||
Fehlschlag beim Mounten mindestens eines konfigurierten Laufwerkspaars lässt den Dienst jetzt
|
||||
auch tatsächlich als "failed" erscheinen, statt es stillschweigend zu ignorieren.
|
||||
|
||||
### Cron-Fallback (Systeme ohne systemd)
|
||||
|
||||
Ist beim Installieren/Upgraden des Pakets kein `systemctl` gefunden, aber `/etc/cron.d`
|
||||
|
||||
@@ -5,7 +5,18 @@ Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
# Bleibt nach einem erfolgreichen Lauf als "active (exited)" sichtbar (statt sofort wieder
|
||||
# "inactive") - macht in 'systemctl status' auf einen Blick erkennbar, dass der letzte Boot-Lauf
|
||||
# tatsächlich durchlief, statt nur "inactive" zu zeigen (das genauso gut "nie gelaufen" heißen
|
||||
# könnte).
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/bin/smart-mount mount --all
|
||||
# Explizit (statt sich auf den systemd-Standard zu verlassen): stdout/stderr gehen ins Journal,
|
||||
# unter einem festen, von der jeweiligen Unit unabhängigen Tag - 'journalctl -t smart-mount'
|
||||
# zeigt damit die Ausgaben aller smart-mount-Units gebündelt.
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=smart-mount
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
@@ -4,3 +4,6 @@ Description=smart-mount: check reachability and switch local/cloud if needed
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/smart-mount watch
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=smart-mount
|
||||
|
||||
+22
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
use crate::config::{self, DrivePair};
|
||||
use crate::db::credentials::CredentialStore;
|
||||
use crate::reconcile;
|
||||
use crate::reconcile::{self, Action};
|
||||
|
||||
fn select_pairs(
|
||||
cfg: &crate::config::AppConfig,
|
||||
@@ -32,9 +32,21 @@ pub async fn run_mount(name: Option<String>, all: bool) -> anyhow::Result<()> {
|
||||
);
|
||||
|
||||
let creds = CredentialStore::open().await?;
|
||||
let mut had_failure = false;
|
||||
for pair in &pairs {
|
||||
let outcome = reconcile::reconcile_pair(pair, &cfg.settings, &creds).await;
|
||||
print_outcome(&outcome);
|
||||
if matches!(outcome.action, Action::Failed(_)) {
|
||||
had_failure = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Ohne dies wäre `smart-mount-mount.service` (siehe packaging/systemd/) beim Booten selbst
|
||||
// dann "erfolgreich" (Exit-Code 0), wenn tatsächlich kein einziges Laufwerkspaar gemountet
|
||||
// werden konnte - `systemctl status` würde den Fehlschlag also nie sichtbar machen. Analog
|
||||
// zu `watch::run` unten.
|
||||
if had_failure {
|
||||
anyhow::bail!("at least one drive pair could not be mounted");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -52,17 +64,24 @@ pub async fn run_unmount(name: Option<String>, all: bool) -> anyhow::Result<()>
|
||||
&format!("unmount: processing {} drive pair(s)", pairs.len()),
|
||||
);
|
||||
|
||||
let mut had_failure = false;
|
||||
for pair in &pairs {
|
||||
match reconcile::unmount_pair(pair, &cfg.settings).await {
|
||||
Ok(_) => println!("{} ({}): unmounted", pair.name, pair.id),
|
||||
Err(e) => println!("{} ({}): ERROR: {e}", pair.name, pair.id),
|
||||
Err(e) => {
|
||||
println!("{} ({}): ERROR: {e}", pair.name, pair.id);
|
||||
had_failure = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if had_failure {
|
||||
anyhow::bail!("at least one drive pair could not be unmounted");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn print_outcome(outcome: &reconcile::ReconcileOutcome) {
|
||||
use reconcile::Action;
|
||||
let action_str = match &outcome.action {
|
||||
Action::NoOp => "no change".to_string(),
|
||||
Action::MountedLocal => "mounted local".to_string(),
|
||||
|
||||
@@ -7,6 +7,12 @@ use smart_mount::cli;
|
||||
async fn main() -> ExitCode {
|
||||
smart_mount::config::init();
|
||||
|
||||
// Persistentes, gut auffindbares Log-Verzeichnis statt logger-ctdras Standard-Fallback
|
||||
// (ein Ordner im System-Temp-Verzeichnis, siehe logger-ctdra-Doku) - smart-mount läuft
|
||||
// ausschließlich als root/System-Dienst (siehe crate::systemd), daher immer derselbe,
|
||||
// feste Pfad. Muss vor dem ersten Log-Aufruf stehen (siehe logger_ctdra::set_log_dir).
|
||||
logger_ctdra::set_log_dir("/var/log/smart-mount");
|
||||
|
||||
let log_level = match smart_mount::config::pairs::load() {
|
||||
Ok(cfg) => cfg.settings.log_level,
|
||||
Err(_) => "info".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user