WIP Impl Action

This commit is contained in:
Adrian Heine 2017-07-28 22:46:40 +02:00
parent 23fed5b6ca
commit b8bac1142c
28 changed files with 363 additions and 58 deletions

View file

@ -1,8 +1,7 @@
use std::error::Error;
use std::os::unix::fs::PermissionsExt;
use std::fmt;
use std::io;
use std::fs::{self, Metadata};
use std::fs;
use std::process::Output;
use std::thread::sleep;
use std::time::Duration;
@ -10,7 +9,7 @@ use std::ops::Deref;
use command_runner::{CommandRunner, SetuidCommandRunner};
use resources::Resource;
use symbols::Symbol;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use symbols::file::File as FileSymbol;
#[derive(Debug)]
@ -152,6 +151,14 @@ impl<'a, C, R> Symbol for NodeJsSystemdUserService<'a, C, R> where C: Deref<Targ
r.extend(self.file.get_prerequisites().into_iter());
r
}
fn as_action<'b>(&'b self, runner: &'b SymbolRunner) -> Box<Action + 'b> {
Box::new(SymbolAction::new(runner, self))
}
fn into_action<'b>(self: Box<Self>, runner: &'b SymbolRunner) -> Box<Action + 'b> where Self: 'b {
Box::new(OwnedSymbolAction::new(runner, *self))
}
}
impl<'a, C, R> fmt::Display for NodeJsSystemdUserService<'a, C, R> where C: Deref<Target=str>, R: CommandRunner {

View file

@ -2,7 +2,7 @@ use std::error::Error;
use std::fmt;
use command_runner::CommandRunner;
use symbols::Symbol;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct ReloadService<'a> {
service: &'a str,
@ -26,6 +26,14 @@ impl<'a> Symbol for ReloadService<'a> {
fn execute(&self) -> Result<(), Box<Error>> {
self.command_runner.run_successfully("systemctl", &["reload-or-restart", self.service])
}
fn as_action<'b>(&'b self, runner: &'b SymbolRunner) -> Box<Action + 'b> {
Box::new(SymbolAction::new(runner, self))
}
fn into_action<'b>(self: Box<Self>, runner: &'b SymbolRunner) -> Box<Action + 'b> where Self: 'b {
Box::new(OwnedSymbolAction::new(runner, *self))
}
}
impl<'a> fmt::Display for ReloadService<'a> {

View file

@ -4,7 +4,7 @@ use std::fmt;
use std::path::PathBuf;
use command_runner::CommandRunner;
use symbols::Symbol;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
#[derive(Debug)]
pub enum SystemdUserSessionError<E: Error> {
@ -58,6 +58,14 @@ impl<'a> Symbol for SystemdUserSession<'a> {
fn execute(&self) -> Result<(), Box<Error>> {
self.command_runner.run_successfully("loginctl", &["enable-linger", self.user_name.borrow()])
}
fn as_action<'b>(&'b self, runner: &'b SymbolRunner) -> Box<Action + 'b> {
Box::new(SymbolAction::new(runner, self))
}
fn into_action<'b>(self: Box<Self>, runner: &'b SymbolRunner) -> Box<Action + 'b> where Self: 'b {
Box::new(OwnedSymbolAction::new(runner, *self))
}
}
impl<'a> fmt::Display for SystemdUserSession<'a> {