1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-04 01:24:09 +02:00

Compare commits

..

No commits in common. "main" and "v2.2.2" have entirely different histories.

26 changed files with 211 additions and 493 deletions

109
Cargo.lock generated
View file

@ -25,7 +25,7 @@ checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"cipher", "cipher",
"cpufeatures 0.2.17", "cpufeatures",
] ]
[[package]] [[package]]
@ -266,9 +266,9 @@ dependencies = [
[[package]] [[package]]
name = "bollard" name = "bollard"
version = "0.21.0" version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9d0a013e3d3ee4edd61e779adf117944c08902d375f18630a0c5b8f95659734" checksum = "227aa051deec8d16bd9c34605e7aaf153f240e35483dd42f6f78903847934738"
dependencies = [ dependencies = [
"base64", "base64",
"bollard-stubs", "bollard-stubs",
@ -298,9 +298,9 @@ dependencies = [
[[package]] [[package]]
name = "bollard-stubs" name = "bollard-stubs"
version = "1.53.1-rc.29.3.1" version = "1.52.1-rc.29.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce412eb6f7096743011dc3cb5c674caeb24ced61d8c498fe07cf7998a4fea889" checksum = "0f0a8ca8799131c1837d1282c3f81f31e76ceb0ce426e04a7fe1ccee3287c066"
dependencies = [ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
@ -384,17 +384,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]]
name = "chacha20"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601"
dependencies = [
"cfg-if",
"cpufeatures 0.3.0",
"rand_core 0.10.1",
]
[[package]] [[package]]
name = "cipher" name = "cipher"
version = "0.4.4" version = "0.4.4"
@ -520,15 +509,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "cpufeatures"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.5.0" version = "1.5.0"
@ -917,7 +897,6 @@ dependencies = [
"js-sys", "js-sys",
"libc", "libc",
"r-efi", "r-efi",
"rand_core 0.10.1",
"wasip2", "wasip2",
"wasip3", "wasip3",
"wasm-bindgen", "wasm-bindgen",
@ -943,14 +922,15 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
[[package]] [[package]]
name = "git2" name = "git2"
version = "0.21.0" version = "0.20.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddddbf932745a6be37109b6112d3ee09696106f848449069d3a57bba937ab82e" checksum = "7b88256088d75a56f8ecfa070513a775dd9107f6530ef14919dac831af9cfe2b"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"libc", "libc",
"libgit2-sys", "libgit2-sys",
"log", "log",
"url",
] ]
[[package]] [[package]]
@ -970,7 +950,7 @@ checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
[[package]] [[package]]
name = "haze" name = "haze"
version = "2.3.0" version = "2.2.2"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"atty", "atty",
@ -1511,9 +1491,9 @@ checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112"
[[package]] [[package]]
name = "libgit2-sys" name = "libgit2-sys"
version = "0.18.5+1.9.4" version = "0.18.3+1.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "005d6ae6eac1912906073e069f7db60b1fa98e052a68227824afe3e3a1c59ca2" checksum = "c9b3acc4b91781bb0b3386669d325163746af5f6e4f73e6d2d630e09a35f3487"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
@ -1814,24 +1794,16 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]] [[package]]
name = "petname" name = "petname"
version = "3.0.0" version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ce610bff48dd7b6a127e45631795fbb0b302b99a39bef7e6da3d297e8eb2b6b" checksum = "9cd31dcfdbbd7431a807ef4df6edd6473228e94d5c805e8cf671227a21bad068"
dependencies = [ dependencies = [
"anyhow",
"clap", "clap",
"petname-macros", "itertools",
"rand 0.10.1",
]
[[package]]
name = "petname-macros"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "324239bd00dcf61f1a0e301d4d8f6f8c080a755248fc3fdc817ee1fdbbc27b8b"
dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "rand 0.8.5",
] ]
[[package]] [[package]]
@ -1993,23 +1965,33 @@ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.9.2" version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [ dependencies = [
"rand_chacha", "libc",
"rand_core 0.9.5", "rand_chacha 0.3.1",
"rand_core 0.6.4",
] ]
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.10.1" version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207" checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
dependencies = [ dependencies = [
"chacha20", "rand_chacha 0.9.0",
"getrandom 0.4.1", "rand_core 0.9.5",
"rand_core 0.10.1", ]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core 0.6.4",
] ]
[[package]] [[package]]
@ -2022,6 +2004,15 @@ dependencies = [
"rand_core 0.9.5", "rand_core 0.9.5",
] ]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom 0.2.15",
]
[[package]] [[package]]
name = "rand_core" name = "rand_core"
version = "0.9.5" version = "0.9.5"
@ -2031,12 +2022,6 @@ dependencies = [
"getrandom 0.3.4", "getrandom 0.3.4",
] ]
[[package]]
name = "rand_core"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
[[package]] [[package]]
name = "rayon" name = "rayon"
version = "1.12.0" version = "1.12.0"
@ -2389,7 +2374,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"cpufeatures 0.2.17", "cpufeatures",
"digest 0.10.7", "digest 0.10.7",
] ]
@ -2400,7 +2385,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"cpufeatures 0.2.17", "cpufeatures",
"digest 0.10.7", "digest 0.10.7",
] ]
@ -2411,7 +2396,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c5f3b1e2dc8aad28310d8410bd4d7e180eca65fca176c52ab00d364475d0024" checksum = "7c5f3b1e2dc8aad28310d8410bd4d7e180eca65fca176c52ab00d364475d0024"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"cpufeatures 0.2.17", "cpufeatures",
"digest 0.11.1", "digest 0.11.1",
] ]

View file

@ -1,6 +1,6 @@
[package] [package]
name = "haze" name = "haze"
version = "2.3.0" version = "2.2.2"
authors = ["Robin Appelman <robin@icewind.nl>"] authors = ["Robin Appelman <robin@icewind.nl>"]
edition = "2021" edition = "2021"
repository = "https://codeberg.org/icewind/haze" repository = "https://codeberg.org/icewind/haze"
@ -8,7 +8,7 @@ license = "MIT"
description = "Easy setup and management of Nextcloud test instances using docker" description = "Easy setup and management of Nextcloud test instances using docker"
[dependencies] [dependencies]
bollard = "0.21.0" bollard = "0.20.1"
maplit = "1.0.2" maplit = "1.0.2"
camino = { version = "1.2.2", features = ["serde1"] } camino = { version = "1.2.2", features = ["serde1"] }
tokio = { version = "1.49.0", features = ["fs", "macros", "signal", "rt-multi-thread"] } tokio = { version = "1.49.0", features = ["fs", "macros", "signal", "rt-multi-thread"] }
@ -20,7 +20,7 @@ toml = "1.0.3"
directories-next = "2.0.0" directories-next = "2.0.0"
serde = "1.0.228" serde = "1.0.228"
serde_json = "1.0.149" serde_json = "1.0.149"
petname = "3.0.0" petname = "2.0.2"
reqwest = { version = "0.13.2", default-features = false, features = ["rustls"] } reqwest = { version = "0.13.2", default-features = false, features = ["rustls"] }
tar = "0.4.44" tar = "0.4.44"
flate2 = "1.1.9" flate2 = "1.1.9"
@ -31,7 +31,7 @@ shell-words = "1.1.1"
tracing = "0.1.44" tracing = "0.1.44"
tracing-subscriber = "0.3.22" tracing-subscriber = "0.3.22"
atty = "0.2.14" atty = "0.2.14"
git2 = { version = "0.21.0", default-features = false } git2 = { version = "0.20.4", default-features = false }
itertools = { version = "0.14.0", features = ["use_alloc"] } itertools = { version = "0.14.0", features = ["use_alloc"] }
local-ip-address = "0.6.10" local-ip-address = "0.6.10"
strum = { version = "0.28.0", features = ["derive"] } strum = { version = "0.28.0", features = ["derive"] }

View file

@ -81,8 +81,6 @@ Additionally, you can use the following options when starting an instance:
- `smb`: set up a samba server for external storage use. - `smb`: set up a samba server for external storage use.
- `dav`: set up a WebDAV server for external storage use. - `dav`: set up a WebDAV server for external storage use.
- `sftp`: set up a SFTP server for external storage use. - `sftp`: set up a SFTP server for external storage use.
- `sftp-key`: set up a SFTP server for external storage use with public key
authentication.
- `kaspersky`: set up a kaspersky scan engine server in http mode. ( Requires - `kaspersky`: set up a kaspersky scan engine server in http mode. ( Requires
[manually setting up the image](https://github.com/icewind1991/kaspersky-docker)) [manually setting up the image](https://github.com/icewind1991/kaspersky-docker))
- `kaspersky-icap`: setup a kaspersky scan engine server in ICAP mode. - `kaspersky-icap`: setup a kaspersky scan engine server in ICAP mode.
@ -151,14 +149,11 @@ haze [match] db
#### Execute a command on an instance #### Execute a command on an instance
```bash ```bash
haze [match] [service] [cmd] haze [match] exec [cmd]
``` ```
If no `cmd` is specified it will launch `bash` If no `cmd` is specified it will launch `bash`
If a service name or `db` is provided, the command will be in the container of
the service or database.
#### Create a new instance and run a command #### Create a new instance and run a command
```bash ```bash

View file

@ -1,38 +0,0 @@
-----BEGIN OPENSSH PRIVATE KEY-----
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
Y6CAchnyhHO0BTAAAACWhhemVAaGF6ZQE=
-----END OPENSSH PRIVATE KEY-----

View file

@ -1 +0,0 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDfbdpaofpjBEtsIE73hQo6R+cnabpmyJzR0y3dOYOeMtTQnOk63vC3n6YxmsQpBOl5+jPJQejfP4eSaWUsAY66k3LcD6MbY73nlRSDDR0Z+7qPo45vroO72Omq3wFDqCvdwRgBKmU8jsHzz39xWknmXUeIFSDJHtnXq/XmoIO2akVUgQIB0gISY+ix+Zm623dhiX3EtrLlYKZTO1ZL9qY9wazQM4QatZ4K13EYpZPdPLB0ErJDQ9t1gxqaAMhPslXVlLNk9qXLiwHsT52lLkCAEVVeZnrXXnUo3VMnyDKhSMWFjty1gQimdxmbJPg9i/Ii/FGxsm28RGJ40fwOhfkPC2pzFuAcrQ7Bi12XjJ1FdOhijeX6oiJ1/6DwANV5r+ZuR9M96B1Oijcs65OFc7ATEOW6SkzyhsUOnPViXUvqtEkBU07UqYdaGfq2jbeO1iMGFzMDaeR6ZBdBtVKNz+Ei2NAMgU0w6wtbfc/5jaT0uSkjRMvT2iA7E4VnMZmna00= haze@haze

View file

@ -38,7 +38,7 @@ in
imagick imagick
] ]
++ optionals (!debug) [ ++ optionals (!debug) [
# smbclient # this breaks the build for no apparent reason smbclient # this breaks the build for no apparent reason
] ]
++ optionals withBlackfire [ ++ optionals withBlackfire [
blackfire blackfire

View file

@ -1,5 +1,6 @@
{ {
rustPlatform, rustPlatform,
pkg-config,
lib, lib,
git, git,
}: let }: let
@ -9,7 +10,7 @@
src = sourceByRegex ../. ["Cargo.*" "(src|certificates)(/.*)?"]; src = sourceByRegex ../. ["Cargo.*" "(src|certificates)(/.*)?"];
version = (fromTOML (readFile ../Cargo.toml)).package.version; version = (fromTOML (readFile ../Cargo.toml)).package.version;
in in
rustPlatform.buildRustPackage { rustPlatform.buildRustPackage rec {
pname = "haze"; pname = "haze";
inherit src version; inherit src version;

View file

@ -165,7 +165,6 @@ impl LogService {
#[derive(Debug, Clone, Eq, PartialEq)] #[derive(Debug, Clone, Eq, PartialEq)]
pub enum ExecService { pub enum ExecService {
Db, Db,
Service(Service),
} }
impl HazeArgs { impl HazeArgs {
@ -233,14 +232,6 @@ impl HazeArgs {
args.next(); args.next();
Some(ExecService::Db) Some(ExecService::Db)
} }
Some(arg) => Service::from_type(&[], arg.as_ref())
.into_iter()
.filter_map(|services| services.into_iter().next())
.next()
.map(|service| {
args.next();
ExecService::Service(service)
}),
_ => None, _ => None,
}; };

View file

@ -219,6 +219,14 @@ impl Database {
} }
}), }),
}), }),
cmd: if self.image() == "mysql:8" {
Some(vec![
"--default-authentication-plugin".into(),
"mysql_native_password".into(),
])
} else {
None
},
..Default::default() ..Default::default()
}; };
let id = docker let id = docker

View file

@ -148,9 +148,6 @@ async fn main() -> Result<ExitCode> {
root, root,
} => { } => {
let cloud = Cloud::get_by_filter(&docker, filter, &config).await?; let cloud = Cloud::get_by_filter(&docker, filter, &config).await?;
let env = get_forward_env();
let tty = atty::is(atty::Stream::Stdout);
match service { match service {
None => { None => {
let command = if command.is_empty() { let command = if command.is_empty() {
@ -158,7 +155,8 @@ async fn main() -> Result<ExitCode> {
} else { } else {
command command
}; };
let env = get_forward_env();
let tty = atty::is(atty::Stream::Stdout);
let user = if root { "root" } else { "haze" }; let user = if root { "root" } else { "haze" };
if tty { if tty {
exec_tty(&docker, &cloud.id, user, command, env).await?; exec_tty(&docker, &cloud.id, user, command, env).await?;
@ -167,42 +165,19 @@ async fn main() -> Result<ExitCode> {
} }
} }
Some(ExecService::Db) => { Some(ExecService::Db) => {
let command = if command.is_empty() { cloud
.db()
.exec_sh(
&docker,
&cloud.id,
if command.is_empty() {
vec!["bash".to_string()] vec!["bash".to_string()]
} else { } else {
command command
}; },
atty::is(atty::Stream::Stdout),
cloud.db().exec_sh(&docker, &cloud.id, command, tty).await?; )
} .await?;
Some(ExecService::Service(service)) => {
let Some(container) = service.container_name(&cloud.id) else {
eprintln!(
"Service {} can't be exec'ed as it has no associated container",
service.name()
);
return Ok(ExitCode::FAILURE);
};
if service.exec_shell() == "" && command.is_empty() {
eprintln!(
"Service {} can't be exec'ed as it has no shell",
service.name()
);
return Ok(ExitCode::FAILURE);
}
let command = if command.is_empty() {
vec![service.exec_shell().to_string()]
} else {
command
};
let user = if root { "root" } else { service.exec_user() };
if tty {
exec_tty(&docker, &container, user, command, env).await?;
} else {
exec(&docker, &container, user, command, env, Some(stdout())).await?;
}
} }
} }
} }
@ -658,7 +633,12 @@ async fn setup(docker: &Docker, options: CloudOptions, config: &HazeConfig) -> R
for service in cloud.services() { for service in cloud.services() {
for cmd in service.post_setup(docker, &cloud.id, config).await? { for cmd in service.post_setup(docker, &cloud.id, config).await? {
cloud cloud
.exec(docker, cmd, false, Vec::<String>::default()) .exec(
docker,
shell_words::split(&cmd).into_diagnostic()?,
false,
Vec::<String>::default(),
)
.await?; .await?;
} }
} }

View file

@ -30,7 +30,7 @@ pub use crate::service::office::Office;
pub use crate::service::onlyoffice::OnlyOffice; pub use crate::service::onlyoffice::OnlyOffice;
pub use crate::service::push::NotifyPush; pub use crate::service::push::NotifyPush;
use crate::service::redis::Redis; use crate::service::redis::Redis;
use crate::service::sftp::{Sftp, SftpKey}; use crate::service::sftp::Sftp;
use crate::service::sharded::{Sharding, ShardingMigrate, ShardingMigrateUnset, SingleShard}; use crate::service::sharded::{Sharding, ShardingMigrate, ShardingMigrateUnset, SingleShard};
use crate::service::smb::Smb; use crate::service::smb::Smb;
use crate::service::webhook::Webhook; use crate::service::webhook::Webhook;
@ -116,7 +116,7 @@ pub trait ServiceTrait {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
Ok(Vec::new()) Ok(Vec::new())
} }
@ -194,14 +194,6 @@ pub trait ServiceTrait {
fn proxy_port(&self) -> u16 { fn proxy_port(&self) -> u16 {
80 80
} }
fn exec_user(&self) -> &'static str {
"root"
}
fn exec_shell(&self) -> &'static str {
"bash"
}
} }
#[derive(Clone, Eq, PartialEq, Debug)] #[derive(Clone, Eq, PartialEq, Debug)]
@ -250,7 +242,6 @@ pub enum ServiceType {
/// Ldap admin interface /// Ldap admin interface
LdapAdmin, LdapAdmin,
/// OnlyOffice /// OnlyOffice
#[strum(serialize = "onlyoffice", serialize = "only-office")]
OnlyOffice, OnlyOffice,
/// Libre office online /// Libre office online
Office, Office,
@ -276,8 +267,6 @@ pub enum ServiceType {
Dav, Dav,
/// Sftp external storage /// Sftp external storage
Sftp, Sftp,
/// Sftp external storage with public key authentication
SftpKey,
/// ownCloud instance for migration /// ownCloud instance for migration
Oc, Oc,
/// Imaginary for preview generation /// Imaginary for preview generation
@ -329,7 +318,6 @@ pub enum Service {
ShardingMigrate(ShardingMigrate), ShardingMigrate(ShardingMigrate),
ShardingMigrateUnset(ShardingMigrateUnset), ShardingMigrateUnset(ShardingMigrateUnset),
Sftp(Sftp), Sftp(Sftp),
SftpKey(SftpKey),
Kaspersky(Kaspersky), Kaspersky(Kaspersky),
KasperskyIcap(KasperskyIcap), KasperskyIcap(KasperskyIcap),
Clam(Clam), Clam(Clam),
@ -373,7 +361,6 @@ impl Service {
} }
ServiceType::Dav => Some(vec![Service::Dav(Dav)]), ServiceType::Dav => Some(vec![Service::Dav(Dav)]),
ServiceType::Sftp => Some(vec![Service::Sftp(Sftp)]), ServiceType::Sftp => Some(vec![Service::Sftp(Sftp)]),
ServiceType::SftpKey => Some(vec![Service::SftpKey(SftpKey)]),
ServiceType::Oc => Some(vec![Service::Oc(Oc)]), ServiceType::Oc => Some(vec![Service::Oc(Oc)]),
ServiceType::Imaginary => Some(vec![Service::Imaginary(Imaginary)]), ServiceType::Imaginary => Some(vec![Service::Imaginary(Imaginary)]),
ServiceType::Kaspersky => Some(vec![Service::Kaspersky(Kaspersky)]), ServiceType::Kaspersky => Some(vec![Service::Kaspersky(Kaspersky)]),
@ -450,29 +437,15 @@ impl ServiceTrait for PresetService {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
config: &HazeConfig, config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
let preset = let preset =
get_preset(&config.preset, &self.0).ok_or_else(|| Report::msg("invalid preset"))?; get_preset(&config.preset, &self.0).ok_or_else(|| Report::msg("invalid preset"))?;
let mut commands: Vec<_> = preset let mut commands: Vec<_> = preset
.apps .apps
.iter() .iter()
.map(|app| { .map(|app| format!("occ app:enable {app} --force"))
vec![
"occ".into(),
"app:enable".into(),
app.clone(),
"--force".into(),
]
})
.collect(); .collect();
for cmnd in &preset.commands { commands.extend_from_slice(&preset.commands);
commands.push(shell_words::split(cmnd).into_diagnostic()?);
}
Ok(commands) Ok(commands)
} }
} }
fn split_cmnd(s: &str) -> Vec<String> {
s.split(' ').map(String::from).collect()
}

View file

@ -2,7 +2,7 @@ use crate::cloud::CloudOptions;
use crate::config::HazeConfig; use crate::config::HazeConfig;
use crate::exec::exec; use crate::exec::exec;
use crate::image::pull_image; use crate::image::pull_image;
use crate::service::{split_cmnd, ServiceTrait}; use crate::service::ServiceTrait;
use crate::Result; use crate::Result;
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig}; use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig};
use bollard::query_parameters::CreateContainerOptions; use bollard::query_parameters::CreateContainerOptions;
@ -85,13 +85,14 @@ impl ServiceTrait for ClamIcap {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
Ok(vec![ Ok(vec![
split_cmnd("occ config:app:set files_antivirus av_mode --value=icap"), "occ config:app:set files_antivirus av_mode --value=icap".into(),
split_cmnd("occ config:app:set files_antivirus av_host --value=clamav-icap"), "occ config:app:set files_antivirus av_host --value=clamav-icap".into(),
split_cmnd("occ config:app:set files_antivirus av_port --value=1344"), "occ config:app:set files_antivirus av_port --value=1344".into(),
split_cmnd("occ config:app:set files_antivirus av_icap_request_service --value=avscan"), "occ config:app:set files_antivirus av_icap_request_service --value=avscan".into(),
split_cmnd("occ config:app:set files_antivirus av_icap_response_header --value=X-Infection-Found"), "occ config:app:set files_antivirus av_icap_response_header --value=X-Infection-Found"
.into(),
]) ])
} }
} }
@ -170,7 +171,7 @@ impl ServiceTrait for ClamIcapTls {
docker: &Docker, docker: &Docker,
cloud_id: &str, cloud_id: &str,
config: &HazeConfig, config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
let mut cert = Vec::new(); let mut cert = Vec::new();
exec( exec(
docker, docker,
@ -190,13 +191,14 @@ impl ServiceTrait for ClamIcapTls {
.wrap_err("Failed to write icap certificate")?; .wrap_err("Failed to write icap certificate")?;
Ok(vec![ Ok(vec![
split_cmnd("occ config:app:set files_antivirus av_mode --value=icap"), "occ config:app:set files_antivirus av_mode --value=icap".into(),
split_cmnd("occ config:app:set files_antivirus av_icap_tls --value=1"), "occ config:app:set files_antivirus av_icap_tls --value=1".into(),
split_cmnd("occ config:app:set files_antivirus av_host --value=clamav-icap-tls"), "occ config:app:set files_antivirus av_host --value=clamav-icap-tls".into(),
split_cmnd("occ config:app:set files_antivirus av_port --value=1345"), "occ config:app:set files_antivirus av_port --value=1345".into(),
split_cmnd("occ config:app:set files_antivirus av_icap_request_service --value=avscan"), "occ config:app:set files_antivirus av_icap_request_service --value=avscan".into(),
split_cmnd("occ config:app:set files_antivirus av_icap_response_header --value=X-Infection-Found"), "occ config:app:set files_antivirus av_icap_response_header --value=X-Infection-Found"
split_cmnd("occ security:certificates:import data/icap-cert.pem"), .into(),
"occ security:certificates:import data/icap-cert.pem".into(),
]) ])
} }
} }
@ -219,10 +221,10 @@ impl ServiceTrait for Clam {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
Ok(vec![ Ok(vec![
split_cmnd("occ config:app:set files_antivirus av_mode --value=executable"), "occ config:app:set files_antivirus av_mode --value=executable".into(),
split_cmnd("occ config:app:set files_antivirus av_path --value=/bin/clamscan"), "occ config:app:set files_antivirus av_path --value=/bin/clamscan".into(),
]) ])
} }
} }
@ -292,12 +294,10 @@ impl ServiceTrait for ClamSocket {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
Ok(vec![ Ok(vec![
split_cmnd("occ config:app:set files_antivirus av_mode --value=socket"), "occ config:app:set files_antivirus av_mode --value=socket".into(),
split_cmnd( "occ config:app:set files_antivirus av_socket --value=tcp://clamav-socket:3310".into(),
"occ config:app:set files_antivirus av_socket --value=tcp://clamav-socket:3310",
),
]) ])
} }
} }

View file

@ -1,7 +1,7 @@
use crate::cloud::CloudOptions; use crate::cloud::CloudOptions;
use crate::config::HazeConfig; use crate::config::HazeConfig;
use crate::image::pull_image; use crate::image::pull_image;
use crate::service::{split_cmnd, ServiceTrait}; use crate::service::ServiceTrait;
use crate::Result; use crate::Result;
use bollard::config::ContainerCreateBody; use bollard::config::ContainerCreateBody;
use bollard::models::{EndpointSettings, HostConfig, NetworkingConfig}; use bollard::models::{EndpointSettings, HostConfig, NetworkingConfig};
@ -76,12 +76,12 @@ impl ServiceTrait for Dav {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
Ok(vec![ Ok(vec![
split_cmnd("occ files_external:create dav dav password::password"), "occ files_external:create dav dav password::password".into(),
split_cmnd("occ files_external:config 1 host dav"), "occ files_external:config 1 host dav".into(),
split_cmnd("occ files_external:config 1 user test"), "occ files_external:config 1 user test".into(),
split_cmnd("occ files_external:config 1 password test"), "occ files_external:config 1 password test".into(),
]) ])
} }
} }

View file

@ -1,7 +1,7 @@
use crate::cloud::CloudOptions; use crate::cloud::CloudOptions;
use crate::config::HazeConfig; use crate::config::HazeConfig;
use crate::image::pull_image; use crate::image::pull_image;
use crate::service::{split_cmnd, ServiceTrait}; use crate::service::ServiceTrait;
use crate::Result; use crate::Result;
use bollard::config::NetworkingConfig; use bollard::config::NetworkingConfig;
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig}; use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig};
@ -71,14 +71,11 @@ impl ServiceTrait for Imaginary {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
Ok(vec![ Ok(vec![
split_cmnd( "occ config:system:set enabledPreviewProviders 0 --value='OC\\Preview\\Imaginary'"
"occ config:system:set enabledPreviewProviders 0 --value='OC\\Preview\\Imaginary'", .into(),
), "occ config:system:set preview_imaginary_url --value='http://imaginary:9000'".into(),
split_cmnd(
"occ config:system:set preview_imaginary_url --value='http://imaginary:9000'",
),
]) ])
} }
} }

View file

@ -2,7 +2,7 @@ use crate::cloud::CloudOptions;
use crate::config::HazeConfig; use crate::config::HazeConfig;
use crate::exec::exec; use crate::exec::exec;
use crate::image::{image_exists, pull_image}; use crate::image::{image_exists, pull_image};
use crate::service::{split_cmnd, ServiceTrait}; use crate::service::ServiceTrait;
use crate::Result; use crate::Result;
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig}; use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig};
use bollard::query_parameters::CreateContainerOptions; use bollard::query_parameters::CreateContainerOptions;
@ -101,11 +101,11 @@ impl ServiceTrait for Kaspersky {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
Ok(vec![ Ok(vec![
split_cmnd("occ config:app:set files_antivirus av_mode --value=kaspersky"), "occ config:app:set files_antivirus av_mode --value=kaspersky".into(),
split_cmnd("occ config:app:set files_antivirus av_host --value=kaspersky"), "occ config:app:set files_antivirus av_host --value=kaspersky".into(),
split_cmnd("occ config:app:set files_antivirus av_port --value=80"), "occ config:app:set files_antivirus av_port --value=80".into(),
]) ])
} }
} }
@ -187,15 +187,13 @@ impl ServiceTrait for KasperskyIcap {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
Ok(vec![ Ok(vec![
split_cmnd("occ config:app:set files_antivirus av_mode --value=icap"), "occ config:app:set files_antivirus av_mode --value=icap".into(),
split_cmnd("occ config:app:set files_antivirus av_host --value=kaspersky-icap"), "occ config:app:set files_antivirus av_host --value=kaspersky-icap".into(),
split_cmnd("occ config:app:set files_antivirus av_port --value=1344"), "occ config:app:set files_antivirus av_port --value=1344".into(),
split_cmnd("occ config:app:set files_antivirus av_icap_request_service --value=req"), "occ config:app:set files_antivirus av_icap_request_service --value=req".into(),
split_cmnd( "occ config:app:set files_antivirus av_icap_response_header --value=X-Virus-ID".into(),
"occ config:app:set files_antivirus av_icap_response_header --value=X-Virus-ID",
),
]) ])
} }
} }

View file

@ -1,7 +1,7 @@
use crate::cloud::CloudOptions; use crate::cloud::CloudOptions;
use crate::config::{HazeConfig, ProxyConfig}; use crate::config::{HazeConfig, ProxyConfig};
use crate::image::pull_image; use crate::image::pull_image;
use crate::service::{split_cmnd, ServiceTrait}; use crate::service::ServiceTrait;
use crate::Result; use crate::Result;
use bollard::config::NetworkingConfig; use bollard::config::NetworkingConfig;
use bollard::models::{ContainerCreateBody, ContainerState, EndpointSettings, HostConfig}; use bollard::models::{ContainerCreateBody, ContainerState, EndpointSettings, HostConfig};
@ -92,29 +92,30 @@ impl ServiceTrait for Ldap {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
Ok(vec![ Ok(vec![
split_cmnd("occ ldap:create-empty-config"), "occ ldap:create-empty-config".into(),
split_cmnd("occ ldap:set-config s01 ldapHost ldap://ldap"), "occ ldap:set-config s01 ldapHost 'ldap://ldap'".into(),
split_cmnd("occ ldap:set-config s01 ldapPort 389"), "occ ldap:set-config s01 ldapPort '389'".into(),
split_cmnd("occ ldap:set-config s01 ldapAgentName cn=admin,dc=example,dc=org"), "occ ldap:set-config s01 ldapAgentName 'cn=admin,dc=example,dc=org'".into(),
split_cmnd("occ ldap:set-config s01 ldapAgentPassword haze"), "occ ldap:set-config s01 ldapAgentPassword 'haze'".into(),
split_cmnd("occ ldap:set-config s01 ldapBase dc=example,dc=org"), "occ ldap:set-config s01 ldapBase 'dc=example,dc=org'".into(),
split_cmnd("occ ldap:set-config s01 ldapBaseUsers dc=example,dc=org"), "occ ldap:set-config s01 ldapBaseUsers 'dc=example,dc=org'".into(),
split_cmnd("occ ldap:set-config s01 ldapBaseGroups dc=example,dc=org"), "occ ldap:set-config s01 ldapBaseGroups 'dc=example,dc=org'".into(),
split_cmnd("occ ldap:set-config s01 ldapLoginFilter (&(&(objectclass=inetOrgPerson))(uid=%uid))"), "occ ldap:set-config s01 ldapLoginFilter '(&(&(objectclass=inetOrgPerson))(uid=%uid))'"
split_cmnd("occ ldap:set-config s01 ldapUserFilter ((objectclass=inetOrgPerson))"), .into(),
split_cmnd("occ ldap:set-config s01 ldapUserFilterMode 0"), "occ ldap:set-config s01 ldapUserFilter '((objectclass=inetOrgPerson))'".into(),
split_cmnd("occ ldap:set-config s01 ldapUserDisplayName sn"), "occ ldap:set-config s01 ldapUserFilterMode '0'".into(),
split_cmnd("occ ldap:set-config s01 ldapUserFilterObjectclass inetOrgPerson"), "occ ldap:set-config s01 ldapUserDisplayName 'sn'".into(),
split_cmnd("occ ldap:set-config s01 ldapGroupFilter (&(|(objectclass=posixGroup)))"), "occ ldap:set-config s01 ldapUserFilterObjectclass 'inetOrgPerson'".into(),
split_cmnd("occ ldap:set-config s01 ldapGroupFilterObjectclass posixGroup"), "occ ldap:set-config s01 ldapGroupFilter '(&(|(objectclass=posixGroup)))'".into(),
split_cmnd("occ ldap:set-config s01 ldapEmailAttribute email"), "occ ldap:set-config s01 ldapGroupFilterObjectclass 'posixGroup'".into(),
split_cmnd("occ ldap:set-config s01 ldapUuidUserAttribute email"), "occ ldap:set-config s01 ldapEmailAttribute 'email'".into(),
split_cmnd("occ ldap:set-config s01 ldapUuidUserAttribute auto"), "occ ldap:set-config s01 ldapUuidUserAttribute 'email'".into(),
split_cmnd("occ ldap:set-config s01 ldapUuidGroupAttribute auto"), "occ ldap:set-config s01 ldapUuidUserAttribute 'auto'".into(),
split_cmnd("occ ldap:set-config s01 ldapLoginFilterUsername 1"), "occ ldap:set-config s01 ldapUuidGroupAttribute 'auto'".into(),
split_cmnd("occ ldap:set-config s01 ldapConfigurationActive 1"), "occ ldap:set-config s01 ldapLoginFilterUsername '1'".into(),
"occ ldap:set-config s01 ldapConfigurationActive '1'".into(),
]) ])
} }

View file

@ -1,7 +1,7 @@
use crate::cloud::CloudOptions; use crate::cloud::CloudOptions;
use crate::config::HazeConfig; use crate::config::HazeConfig;
use crate::image::pull_image; use crate::image::pull_image;
use crate::service::{split_cmnd, ServiceTrait}; use crate::service::ServiceTrait;
use crate::Result; use crate::Result;
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig}; use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig};
use bollard::query_parameters::CreateContainerOptions; use bollard::query_parameters::CreateContainerOptions;
@ -70,14 +70,14 @@ impl ServiceTrait for Mail {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
Ok(vec![ Ok(vec![
split_cmnd("occ config:system:set mail_smtpmode --value smtp"), "occ config:system:set mail_smtpmode --value smtp".into(),
split_cmnd("occ config:system:set mail_sendmailmode --value smtp"), "occ config:system:set mail_sendmailmode --value smtp".into(),
split_cmnd("occ config:system:set mail_domain --value haze"), "occ config:system:set mail_domain --value haze".into(),
split_cmnd("occ config:system:set mail_smtphost --value mail"), "occ config:system:set mail_smtphost --value mail".into(),
split_cmnd("occ config:system:set mail_smtpport --value 25"), "occ config:system:set mail_smtpport --value 25".into(),
split_cmnd("occ user:setting admin settings email admin@haze"), "occ user:setting admin settings email admin@haze".into(),
]) ])
} }
} }

View file

@ -2,7 +2,7 @@ use crate::cloud::CloudOptions;
use crate::config::HazeConfig; use crate::config::HazeConfig;
use crate::exec::exec; use crate::exec::exec;
use crate::image::pull_image; use crate::image::pull_image;
use crate::service::{split_cmnd, ServiceTrait}; use crate::service::ServiceTrait;
use crate::Result; use crate::Result;
use bollard::models::{ use bollard::models::{
ContainerCreateBody, ContainerState, EndpointSettings, HostConfig, NetworkingConfig, ContainerCreateBody, ContainerState, EndpointSettings, HostConfig, NetworkingConfig,
@ -247,18 +247,18 @@ impl ServiceTrait for ObjectStore {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
match self { match self {
ObjectStore::S3 => Ok(vec![ ObjectStore::S3 => Ok(vec![
split_cmnd("occ files_external:create s3 amazons3 amazons3::accesskey"), "occ files_external:create s3 amazons3 amazons3::accesskey".into(),
split_cmnd("occ files_external:config 1 bucket ext"), "occ files_external:config 1 bucket ext".into(),
split_cmnd("occ files_external:config 1 hostname s3"), "occ files_external:config 1 hostname s3".into(),
split_cmnd("occ files_external:config 1 port 9000"), "occ files_external:config 1 port 9000".into(),
split_cmnd("occ files_external:config 1 use_ssl false"), "occ files_external:config 1 use_ssl false".into(),
split_cmnd("occ files_external:config 1 use_path_style true"), "occ files_external:config 1 use_path_style true".into(),
split_cmnd("occ files_external:config 1 key minio"), "occ files_external:config 1 key minio".into(),
split_cmnd("occ files_external:config 1 secret minio123"), "occ files_external:config 1 secret minio123".into(),
split_cmnd("mc alias set s3 http://s3:9000 minio minio123"), "mc alias set s3 http://s3:9000 minio minio123".into(),
]), ]),
// ObjectStore::S3s => Ok(vec![ // ObjectStore::S3s => Ok(vec![
// "occ files_external:create s3 amazons3 amazons3::accesskey".into(), // "occ files_external:create s3 amazons3 amazons3::accesskey".into(),

View file

@ -83,7 +83,7 @@ impl ServiceTrait for Oc {
docker: &Docker, docker: &Docker,
cloud_id: &str, cloud_id: &str,
config: &HazeConfig, config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
if let Some(ip) = self.get_ips(docker, cloud_id).await?.next() { if let Some(ip) = self.get_ips(docker, cloud_id).await?.next() {
let container = self.container_name(cloud_id).unwrap(); let container = self.container_name(cloud_id).unwrap();
let addr = config.proxy.addr(&container, ip); let addr = config.proxy.addr(&container, ip);

View file

@ -119,7 +119,7 @@ impl ServiceTrait for Office {
docker: &Docker, docker: &Docker,
cloud_id: &str, cloud_id: &str,
config: &HazeConfig, config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
let container = &self.container_name(cloud_id).unwrap(); let container = &self.container_name(cloud_id).unwrap();
let info = docker let info = docker
.inspect_container(container, None) .inspect_container(container, None)
@ -152,22 +152,8 @@ impl ServiceTrait for Office {
.addr_with_port(container, ip, self.proxy_port()); .addr_with_port(container, ip, self.proxy_port());
Ok(vec![ Ok(vec![
vec![ format!(r#"occ config:app:set richdocuments public_wopi_url --value="{public}""#),
"occ".into(), r#"occ richdocuments:setup --wopi-url "http://office:9980" --callback-url "http://cloud""#.into(),
"config:app:set".into(),
"richdocuments".into(),
"public_wopi_url".into(),
"--value".into(),
public,
],
vec![
"occ".into(),
"richdocuments:setup".into(),
"--wopi-url".into(),
"http://office:9980".into(),
"--callback-url".into(),
"http://cloud".into(),
],
]) ])
} }

View file

@ -2,7 +2,7 @@ use crate::cloud::CloudOptions;
use crate::config::HazeConfig; use crate::config::HazeConfig;
use crate::exec::exec; use crate::exec::exec;
use crate::image::pull_image; use crate::image::pull_image;
use crate::service::{split_cmnd, ServiceTrait}; use crate::service::ServiceTrait;
use crate::Result; use crate::Result;
use bollard::models::{ use bollard::models::{
ContainerCreateBody, ContainerState, EndpointSettings, HostConfig, NetworkingConfig, ContainerCreateBody, ContainerState, EndpointSettings, HostConfig, NetworkingConfig,
@ -82,7 +82,7 @@ impl ServiceTrait for OnlyOffice {
docker: &Docker, docker: &Docker,
cloud_id: &str, cloud_id: &str,
config: &HazeConfig, config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
let info = docker let info = docker
.inspect_container(&self.container_name(cloud_id).unwrap(), None) .inspect_container(&self.container_name(cloud_id).unwrap(), None)
.await .await
@ -137,44 +137,16 @@ impl ServiceTrait for OnlyOffice {
); );
Ok(vec![ Ok(vec![
vec![ format!("occ config:app:set onlyoffice DocumentServerUrl --value {addr}/"),
"occ".into(), format!("occ config:app:set onlyoffice jwt_secret --value {secret}"),
"config:app:set".into(), "occ onlyoffice:documentserver --check".into(),
"onlyoffice".into(),
"DocumentServerUrl".into(),
"--value".into(),
addr,
],
vec![
"occ".into(),
"config:app:set".into(),
"onlyoffice".into(),
"jwt_secret".into(),
"--value".into(),
secret.into(),
],
split_cmnd("occ onlyoffice:documentserver --check"),
]) ])
} else { } else {
Ok(vec![ Ok(vec![
vec![ format!("occ config:app:set onlyoffice DocumentServerUrl --value https://{ip}/"),
"occ".into(), "occ config:app:set onlyoffice verify_peer_off --value true".into(),
"config:app:set".into(), format!("occ config:app:set onlyoffice jwt_secret --value {secret}"),
"onlyoffice".into(), "occ onlyoffice:documentserver --check".into(),
"DocumentServerUrl".into(),
"--value".into(),
format!("https://{ip}/"),
],
split_cmnd("occ config:app:set onlyoffice verify_peer_off --value true"),
vec![
"occ".into(),
"config:app:set".into(),
"onlyoffice".into(),
"jwt_secret".into(),
"--value".into(),
secret.into(),
],
split_cmnd("occ onlyoffice:documentserver --check"),
]) ])
} }
} }

View file

@ -87,7 +87,7 @@ impl ServiceTrait for NotifyPush {
docker: &Docker, docker: &Docker,
cloud_id: &str, cloud_id: &str,
config: &HazeConfig, config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
let mut ips: Vec<_> = self.get_ips(docker, cloud_id).await?.collect(); let mut ips: Vec<_> = self.get_ips(docker, cloud_id).await?.collect();
if let Ok(local_interfaces) = list_afinet_netifas() { if let Ok(local_interfaces) = list_afinet_netifas() {
ips.extend(local_interfaces.into_iter().map(|(_, ip)| ip)); ips.extend(local_interfaces.into_iter().map(|(_, ip)| ip));
@ -97,14 +97,10 @@ impl ServiceTrait for NotifyPush {
.iter() .iter()
.enumerate() .enumerate()
.map(|(i, ip)| { .map(|(i, ip)| {
vec![ format!(
"occ".into(), "occ config:system:set trusted_proxies {} --value {ip}",
"config:system:set".into(), i + 1
"trusted_proxies".into(), )
(i + 1).to_string(),
"--value".into(),
ip.to_string(),
]
}) })
.collect(); .collect();
@ -112,7 +108,7 @@ impl ServiceTrait for NotifyPush {
config config
.proxy .proxy
.addr_with_port(&self.container_name(cloud_id).unwrap(), ips[0], 7867); .addr_with_port(&self.container_name(cloud_id).unwrap(), ips[0], 7867);
commands.push(vec!["occ".into(), "notify_push:setup".into(), addr]); commands.push(format!("occ notify_push:setup {}", addr));
Ok(commands) Ok(commands)
} }

View file

@ -1,7 +1,7 @@
use crate::cloud::CloudOptions; use crate::cloud::CloudOptions;
use crate::config::HazeConfig; use crate::config::HazeConfig;
use crate::image::pull_image; use crate::image::pull_image;
use crate::service::{split_cmnd, ServiceTrait}; use crate::service::ServiceTrait;
use crate::Result; use crate::Result;
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig}; use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig};
use bollard::query_parameters::CreateContainerOptions; use bollard::query_parameters::CreateContainerOptions;
@ -70,13 +70,7 @@ impl ServiceTrait for Redis {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
Ok(vec![split_cmnd( Ok(vec!["occ config:system:set redis host --value redis".into()])
"occ config:system:set redis host --value redis",
)])
}
fn exec_shell(&self) -> &'static str {
"sh"
} }
} }

View file

@ -1,14 +1,13 @@
use crate::cloud::CloudOptions; use crate::cloud::CloudOptions;
use crate::config::HazeConfig; use crate::config::HazeConfig;
use crate::image::pull_image; use crate::image::pull_image;
use crate::service::{split_cmnd, ServiceTrait}; use crate::service::ServiceTrait;
use crate::Result; use crate::Result;
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig}; use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig};
use bollard::query_parameters::CreateContainerOptions; use bollard::query_parameters::CreateContainerOptions;
use bollard::Docker; use bollard::Docker;
use maplit::hashmap; use maplit::hashmap;
use miette::{Context, IntoDiagnostic}; use miette::IntoDiagnostic;
use std::fs::{create_dir_all, write};
#[derive(Debug, Clone, Eq, PartialEq)] #[derive(Debug, Clone, Eq, PartialEq)]
pub struct Sftp; pub struct Sftp;
@ -51,10 +50,7 @@ impl ServiceTrait for Sftp {
} }
}), }),
}), }),
cmd: Some(vec![ cmd: Some(vec!["test:test:::data".into()]),
"test:test:::data".into(),
"ldaptest:test:::data".into(),
]),
..Default::default() ..Default::default()
}; };
let id = docker let id = docker
@ -79,119 +75,13 @@ impl ServiceTrait for Sftp {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> {
Ok(vec![
split_cmnd("occ files_external:create sftp sftp password::password"),
split_cmnd("occ files_external:config 1 host sftp"),
split_cmnd("occ files_external:config 1 user test"),
split_cmnd("occ files_external:config 1 root data"),
split_cmnd("occ files_external:config 1 password test"),
])
}
}
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct SftpKey;
#[async_trait::async_trait]
impl ServiceTrait for SftpKey {
fn name(&self) -> &str {
"sftp-key"
}
async fn spawn(
&self,
docker: &Docker,
cloud_id: &str,
network: &str,
config: &HazeConfig,
_options: &CloudOptions,
) -> Result<Vec<String>> { ) -> Result<Vec<String>> {
let image = "atmoz/sftp:alpine";
pull_image(docker, image).await?;
let options = Some(CreateContainerOptions {
name: self.container_name(cloud_id),
..CreateContainerOptions::default()
});
let key_dir = config.work_dir.join("certificates/sftp");
create_dir_all(&key_dir)
.into_diagnostic()
.wrap_err("Failed to create sftp certificate directory")?;
let private_path = key_dir.join("id_rsa");
let public_path = key_dir.join("id_rsa.pub");
let private_key = include_str!("../../certificates/sftp/id_rsa");
let public_key = include_str!("../../certificates/sftp/id_rsa.pub");
if !private_path.exists() {
write(&private_path, private_key)
.into_diagnostic()
.wrap_err("Failed to write sftp client certificate")?;
}
if !public_path.exists() {
write(&public_path, public_key)
.into_diagnostic()
.wrap_err("Failed to write sftp client key")?;
}
let volumes = vec![format!("{public_path}:/home/test/.ssh/keys/id_rsa:ro")];
let config = ContainerCreateBody {
image: Some(image.into()),
host_config: Some(HostConfig {
network_mode: Some(network.to_string()),
binds: Some(volumes),
..Default::default()
}),
labels: Some(hashmap! {
"haze-type".into() => self.name().into(),
"haze-cloud-id".into() => cloud_id.into(),
}),
networking_config: Some(NetworkingConfig {
endpoints_config: Some(hashmap! {
network.into() => EndpointSettings {
aliases: Some(vec![self.name().to_string()]),
..Default::default()
}
}),
}),
cmd: Some(vec!["test::::data".into()]),
..Default::default()
};
let id = docker
.create_container(options, config)
.await
.into_diagnostic()?
.id;
docker.start_container(&id, None).await.into_diagnostic()?;
Ok(vec![id])
}
fn container_name(&self, cloud_id: &str) -> Option<String> {
Some(format!("{}-sftp-key", cloud_id))
}
fn apps(&self) -> &'static [&'static str] {
&["files_external"]
}
async fn post_setup(
&self,
_docker: &Docker,
_cloud_id: &str,
_config: &HazeConfig,
) -> Result<Vec<Vec<String>>> {
Ok(vec![ Ok(vec![
split_cmnd("occ files_external:create sftp sftp publickey::rsa_private"), "occ files_external:create sftp sftp password::password".into(),
split_cmnd("occ files_external:config 1 host sftp-key"), "occ files_external:config 1 host sftp".into(),
split_cmnd("occ files_external:config 1 user test"), "occ files_external:config 1 user test".into(),
split_cmnd("occ files_external:config 1 root data"), "occ files_external:config 1 root data".into(),
vec![ "occ files_external:config 1 password test".into(),
"occ".into(),
"files_external:config".into(),
"--value-from-file".into(),
"1".into(),
"private_key".into(),
"/certificates/sftp/id_rsa".into(),
],
]) ])
} }
} }

View file

@ -1,7 +1,7 @@
use crate::cloud::CloudOptions; use crate::cloud::CloudOptions;
use crate::config::HazeConfig; use crate::config::HazeConfig;
use crate::image::pull_image; use crate::image::pull_image;
use crate::service::{split_cmnd, ServiceTrait}; use crate::service::ServiceTrait;
use crate::Result; use crate::Result;
use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig}; use bollard::models::{ContainerCreateBody, EndpointSettings, HostConfig, NetworkingConfig};
use bollard::query_parameters::CreateContainerOptions; use bollard::query_parameters::CreateContainerOptions;
@ -40,10 +40,8 @@ impl ServiceTrait for Smb {
}), }),
env: Some(vec![ env: Some(vec![
"ACCOUNT_test=test".into(), "ACCOUNT_test=test".into(),
"ACCOUNT_ldaptest=test".into(),
"UID_test=1000".into(), "UID_test=1000".into(),
"SAMBA_VOLUME_CONFIG_test=[test]; path=/tmp; valid users = test; guest ok = no; read only = no; browseable = yes".into(), "SAMBA_VOLUME_CONFIG_test=[test]; path=/tmp; valid users = test; guest ok = no; read only = no; browseable = yes".into(),
"SAMBA_VOLUME_CONFIG_ldaptest=[ldaptest]; path=/tmp; valid users = ldaptest; guest ok = no; read only = no; browseable = yes".into(),
]), ]),
labels: Some(hashmap! { labels: Some(hashmap! {
"haze-type".into() => self.name().into(), "haze-type".into() => self.name().into(),
@ -81,17 +79,13 @@ impl ServiceTrait for Smb {
_docker: &Docker, _docker: &Docker,
_cloud_id: &str, _cloud_id: &str,
_config: &HazeConfig, _config: &HazeConfig,
) -> Result<Vec<Vec<String>>> { ) -> Result<Vec<String>> {
Ok(vec![ Ok(vec![
split_cmnd("occ files_external:create smb smb password::password"), "occ files_external:create smb smb password::password".into(),
split_cmnd("occ files_external:config 1 host smb"), "occ files_external:config 1 host smb".into(),
split_cmnd("occ files_external:config 1 user test"), "occ files_external:config 1 user test".into(),
split_cmnd("occ files_external:config 1 password test"), "occ files_external:config 1 password test".into(),
split_cmnd("occ files_external:config 1 share test"), "occ files_external:config 1 share test".into(),
]) ])
} }
fn exec_shell(&self) -> &'static str {
"sh"
}
} }

View file

@ -68,8 +68,4 @@ impl ServiceTrait for Webhook {
fn proxy_port(&self) -> u16 { fn proxy_port(&self) -> u16 {
8080 8080
} }
fn exec_shell(&self) -> &'static str {
""
}
} }