Add maintenance task
This commit is contained in:
parent
5121b7de6d
commit
51f32f7ec3
|
@ -110,18 +110,10 @@ fn main() -> Result<()> {
|
|||
);
|
||||
let monitor = term("Monitor", "htop");
|
||||
let wifi = term("WLAN", "nmtui");
|
||||
let update_home = term("Update Home", "home-manager switch");
|
||||
let update_sys = term("Update Sys", "sudo nixos-rebuild switch");
|
||||
let gc = term("Collect Garbage", "nix-collect-garbage -d");
|
||||
let optimise = term("Optimise", "nix optimise-store");
|
||||
menu(
|
||||
"Maintenance",
|
||||
vec![
|
||||
wifi,
|
||||
update_home,
|
||||
update_sys,
|
||||
gc,
|
||||
optimise,
|
||||
monitor,
|
||||
keymenu,
|
||||
run("Bildschirme", "arandr"),
|
||||
|
|
|
@ -19,7 +19,7 @@ use error::{Result, ResultExt, ErrorKind as EK, Error};
|
|||
use hotkeys::{term_cmd, str2cmd};
|
||||
use tasktree::{TreeCache, TaskNode};
|
||||
use well_known::{INBOX, ACCOUNTING, TREESORT, PRIVATE_MAILBOX, KIVA_MAILBOX, AK_MAILBOX,
|
||||
SORT_INBOX, SORT_INBOX_AK, SORT_INBOX_KIVA};
|
||||
SORT_INBOX, SORT_INBOX_AK, SORT_INBOX_KIVA, MAINTENANCE};
|
||||
use mail::{sort_mailbox, SortBox};
|
||||
use generate::GeneratedTask;
|
||||
|
||||
|
@ -220,6 +220,7 @@ impl Kassandra {
|
|||
// maralorn.de
|
||||
// kiva
|
||||
// ak
|
||||
process_task(self, &*MAINTENANCE)?;
|
||||
process_task(self, &*SORT_INBOX)?;
|
||||
process_task(self, &*SORT_INBOX_KIVA)?;
|
||||
process_task(self, &*SORT_INBOX_AK)?;
|
||||
|
|
|
@ -3,7 +3,7 @@ use task_hookrs::cache::TaskCache;
|
|||
use refresh::TaskRefresher;
|
||||
use tasktree::{TreeCache, TaskNode};
|
||||
use well_known::{SIMPLE, WellKnown, INBOX, ACCOUNTING, TREESORT, SORT_INBOX, SORT_INBOX_AK,
|
||||
SORT_INBOX_KIVA};
|
||||
SORT_INBOX_KIVA, MAINTENANCE};
|
||||
use error::Result;
|
||||
use kassandra::Kassandra;
|
||||
use mail::create_tasks;
|
||||
|
@ -59,6 +59,7 @@ pub fn update_tasks(cache: &mut TaskCache) -> Result<()> {
|
|||
update_task(cache, &*SORT_INBOX)?;
|
||||
update_task(cache, &*SORT_INBOX_KIVA)?;
|
||||
update_task(cache, &*SORT_INBOX_AK)?;
|
||||
update_task(cache, &*MAINTENANCE)?;
|
||||
update_task(cache, &*INBOX)?;
|
||||
update_task(cache, &*TREESORT)?;
|
||||
update_task(cache, &*ACCOUNTING)?;
|
||||
|
|
|
@ -35,6 +35,7 @@ lazy_static! {
|
|||
pub static ref INBOX: Inbox = Inbox { timer: DAILY.clone() };
|
||||
pub static ref TREESORT: Treesort = Treesort { timer: DAILY.clone() };
|
||||
pub static ref ACCOUNTING: Accounting = Accounting { timer: DAILY.clone() };
|
||||
pub static ref MAINTENANCE: Maintenance = Maintenance { timer: DAILY.clone() };
|
||||
pub static ref CHECK_MEDIUM: SimpleTask = unimplemented!(); // auch +await // einfach
|
||||
pub static ref CHECK_LOW: SimpleTask = unimplemented!(); // einfach
|
||||
pub static ref CHECK_NONE: SimpleTask = unimplemented!(); //einfach
|
||||
|
@ -47,10 +48,6 @@ lazy_static! {
|
|||
pub static ref SORT_MAIL_KIVA: SimpleTask = unimplemented!(); // nicht so wichtig
|
||||
pub static ref SORT_MAIL_AK: SimpleTask = unimplemented!(); // nicht so wichtig
|
||||
pub static ref SORT_SPAM: SimpleTask = unimplemented!(); // nicht so wichtig
|
||||
pub static ref UPDATE_APOLLO: SimpleTask = unimplemented!(); // einfach aber nicht dringend
|
||||
pub static ref GC_APOLLO: SimpleTask = unimplemented!(); // einfach aber nicht dringend
|
||||
pub static ref OPT_APOLLO: SimpleTask = unimplemented!(); // einfach aber nicht dringend
|
||||
pub static ref BACKUP_APOLLO: SimpleTask = unimplemented!(); // einfach aber nicht dringend
|
||||
pub static ref PRIVATE_MAILBOX: SortBox = SortBox {
|
||||
mailbox: "m-0/INBOX",
|
||||
option_dirs: vec![
|
||||
|
@ -333,3 +330,41 @@ impl WellKnown for Mailsort {
|
|||
self.timer.clone()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Maintenance {
|
||||
timer: Timer,
|
||||
}
|
||||
|
||||
impl WellKnown for Maintenance {
|
||||
fn definition(&self) -> &Task {
|
||||
lazy_static! {
|
||||
static ref TASK: Task = {
|
||||
let mut t = TaskBuilder::default()
|
||||
.description("Run system Maintenance")
|
||||
.build()
|
||||
.expect("TaskBuilding failed inspite of set description");
|
||||
t.set_gen_name(Some("maintenance"));
|
||||
t.set_gen_id(Some("apollo"));
|
||||
t
|
||||
};
|
||||
};
|
||||
&TASK
|
||||
}
|
||||
|
||||
fn action_necessary(&self, _cache: &TaskCache) -> Result<bool> {
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn process(&self, kassandra: &mut Kassandra) -> Result<()> {
|
||||
str2cmd(&term_cmd("maintenance")).spawn()?;
|
||||
for task in kassandra.cache.filter_mut(|t| self.is_this(t)) {
|
||||
task.tw_done()
|
||||
}
|
||||
kassandra.cache.write()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn refresh(&self) -> Timer {
|
||||
self.timer.clone()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,5 +28,14 @@ m-0.mail = {
|
|||
sendmail = with config.m-0.private.sendmail; [ private work work2 club club2 ];
|
||||
default = config.m-0.private.sendmail.private;
|
||||
};
|
||||
home.packages = [
|
||||
(pkgs.writeShellScriptBin "maintenance" ''
|
||||
sudo -A nix-channel --update
|
||||
sudo -A nixos-rebuild switch
|
||||
sudo -A nix-collect-garbage -d
|
||||
nix optimise-store
|
||||
sudo -A systemctl start borgbackup-job-data.service
|
||||
'')
|
||||
];
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue