Adrian Heine
7 years ago
22 changed files with 220 additions and 148 deletions
-
25src/command_runner.rs
-
26src/symbols/acme/account_key.rs
-
12src/symbols/acme/cert.rs
-
14src/symbols/acme/chain.rs
-
2src/symbols/acme/mod.rs
-
66src/symbols/acme/user.rs
-
14src/symbols/git/checkout.rs
-
14src/symbols/git/submodules.rs
-
12src/symbols/mariadb/database.rs
-
12src/symbols/mariadb/database_dump.rs
-
12src/symbols/mariadb/user.rs
-
36src/symbols/nginx/server.rs
-
12src/symbols/npm.rs
-
12src/symbols/owner.rs
-
12src/symbols/stored_directory.rs
-
12src/symbols/systemd/reload.rs
-
12src/symbols/systemd/user_session.rs
-
12src/symbols/tls/csr.rs
-
12src/symbols/tls/key.rs
-
12src/symbols/tls/self_signed_cert.rs
-
22src/symbols/user.rs
-
5src/symbols/wordpress/plugin.rs
@ -1,7 +1,9 @@ |
|||||
mod account_key;
|
mod account_key;
|
||||
mod cert;
|
mod cert;
|
||||
mod chain;
|
mod chain;
|
||||
|
mod user;
|
||||
|
|
||||
pub use self::account_key::AcmeAccountKey;
|
pub use self::account_key::AcmeAccountKey;
|
||||
pub use self::cert::AcmeCert;
|
pub use self::cert::AcmeCert;
|
||||
pub use self::chain::AcmeCertChain;
|
pub use self::chain::AcmeCertChain;
|
||||
|
pub use self::user::new as newAcmeUser;
|
@ -0,0 +1,66 @@ |
|||||
|
use std::borrow::{Borrow, Cow};
|
||||
|
use std::error::Error;
|
||||
|
use std::fmt;
|
||||
|
use std::ops::Deref;
|
||||
|
use std::path::PathBuf;
|
||||
|
use resources::Resource;
|
||||
|
|
||||
|
use command_runner::CommandRunner;
|
||||
|
use symbols::{Action, OwnedSymbolAction, SymbolAction, SymbolRunner, Symbol};
|
||||
|
use symbols::acme::AcmeAccountKey;
|
||||
|
use symbols::dir::Dir;
|
||||
|
use symbols::file::File;
|
||||
|
use symbols::hook::Hook;
|
||||
|
use symbols::list::List;
|
||||
|
use symbols::owner::Owner;
|
||||
|
|
||||
|
pub struct AcmeUser<'a>(Cow<'a, str>);
|
||||
|
|
||||
|
impl<'a> AcmeUser<'a> {
|
||||
|
pub fn new<S: Into<Cow<'a, str>>>(user_name: S) -> Self {
|
||||
|
AcmeUser(user_name.into())
|
||||
|
}
|
||||
|
}
|
||||
|
|
||||
|
impl<'a> Symbol for AcmeUser<'a> {
|
||||
|
fn target_reached(&self) -> Result<bool, Box<Error>> {
|
||||
|
Ok(false)
|
||||
|
}
|
||||
|
fn execute(&self) -> Result<(), Box<Error>> {
|
||||
|
Ok(())
|
||||
|
}
|
||||
|
fn get_prerequisites(&self) -> Vec<Resource> {
|
||||
|
vec![]
|
||||
|
}
|
||||
|
fn provides(&self) -> Option<Vec<Resource>> {
|
||||
|
None
|
||||
|
}
|
||||
|
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 AcmeUser<'a> {
|
||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
|
write!(f, "AcmeUser {}", self.0)
|
||||
|
}
|
||||
|
}
|
||||
|
|
||||
|
pub fn new<'a, S: Into<Cow<'a, str>>, C: CommandRunner, P: 'a + Deref<Target=str>>(command_runner: &'a C, cert: P, user_name: S) -> Box<Symbol + 'a> { // impl trait
|
||||
|
let user_name_cow = user_name.into();
|
||||
|
let account_key_file: PathBuf = ["home", user_name_cow.borrow(), "account.key"].iter().collect();
|
||||
|
Box::new(List::new(vec![
|
||||
|
Box::new(AcmeAccountKey::new(account_key_file.clone().into(), command_runner)),
|
||||
|
Box::new(Owner::new(account_key_file.to_string_lossy().into_owned(), user_name_cow.clone(), command_runner)),
|
||||
|
Box::new(Dir::new("/home/acme/challenges")),
|
||||
|
Box::new(Owner::new("/home/acme/challenges", user_name_cow.clone(), command_runner)),
|
||||
|
Box::new(Dir::new("/etc/ssl/local_certs")),
|
||||
|
Box::new(Owner::new("/etc/ssl/local_certs", user_name_cow, command_runner)),
|
||||
|
Box::new(File::new("/home/acme/lets_encrypt_x3_cross_signed.pem", cert))
|
||||
|
]))
|
||||
|
}
|
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue