mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 17:14:08 +02:00
add support for imaginary
This commit is contained in:
parent
c49fb38a88
commit
a6abcc8c1e
3 changed files with 91 additions and 0 deletions
|
|
@ -73,6 +73,7 @@ Additionally, you can use the following options when starting an instance:
|
||||||
- `clamav-icap`: setup a clam av scanner in ICAP mode.
|
- `clamav-icap`: setup a clam av scanner in ICAP mode.
|
||||||
- `clamav-icap-tls`: setup a clam av scanner in ICAP mode with TLS encryption.
|
- `clamav-icap-tls`: setup a clam av scanner in ICAP mode with TLS encryption.
|
||||||
- `oc`: start an ownCloud instance in the same network.
|
- `oc`: start an ownCloud instance in the same network.
|
||||||
|
- `imaginary`: start an Imaginary service and configure it for preview generation
|
||||||
- The name of any configured preset
|
- The name of any configured preset
|
||||||
|
|
||||||
#### Run tests in a new instance
|
#### Run tests in a new instance
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
mod clam;
|
mod clam;
|
||||||
mod dav;
|
mod dav;
|
||||||
|
mod imaginary;
|
||||||
mod kaspersky;
|
mod kaspersky;
|
||||||
mod ldap;
|
mod ldap;
|
||||||
mod objectstore;
|
mod objectstore;
|
||||||
|
|
@ -13,6 +14,7 @@ mod smb;
|
||||||
use crate::config::{HazeConfig, Preset};
|
use crate::config::{HazeConfig, Preset};
|
||||||
pub use crate::service::clam::{ClamIcap, ClamIcapTls};
|
pub use crate::service::clam::{ClamIcap, ClamIcapTls};
|
||||||
use crate::service::dav::Dav;
|
use crate::service::dav::Dav;
|
||||||
|
use crate::service::imaginary::Imaginary;
|
||||||
use crate::service::kaspersky::{Kaspersky, KasperskyIcap};
|
use crate::service::kaspersky::{Kaspersky, KasperskyIcap};
|
||||||
pub use crate::service::ldap::{Ldap, LdapAdmin};
|
pub use crate::service::ldap::{Ldap, LdapAdmin};
|
||||||
pub use crate::service::objectstore::ObjectStore;
|
pub use crate::service::objectstore::ObjectStore;
|
||||||
|
|
@ -180,6 +182,7 @@ pub enum Service {
|
||||||
ClamIcap(ClamIcap),
|
ClamIcap(ClamIcap),
|
||||||
ClamIcapTls(ClamIcapTls),
|
ClamIcapTls(ClamIcapTls),
|
||||||
Oc(Oc),
|
Oc(Oc),
|
||||||
|
Imaginary(Imaginary),
|
||||||
Preset(PresetService),
|
Preset(PresetService),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,6 +201,7 @@ impl Service {
|
||||||
"dav" => Some(vec![Service::Dav(Dav)]),
|
"dav" => Some(vec![Service::Dav(Dav)]),
|
||||||
"sftp" => Some(vec![Service::Sftp(Sftp)]),
|
"sftp" => Some(vec![Service::Sftp(Sftp)]),
|
||||||
"oc" => Some(vec![Service::Oc(Oc)]),
|
"oc" => Some(vec![Service::Oc(Oc)]),
|
||||||
|
"imaginary" => Some(vec![Service::Imaginary(Imaginary)]),
|
||||||
"kaspersky" => Some(vec![Service::Kaspersky(Kaspersky)]),
|
"kaspersky" => Some(vec![Service::Kaspersky(Kaspersky)]),
|
||||||
"kaspersky-icap" => Some(vec![Service::KasperskyIcap(KasperskyIcap)]),
|
"kaspersky-icap" => Some(vec![Service::KasperskyIcap(KasperskyIcap)]),
|
||||||
"clamav-icap" => Some(vec![Service::ClamIcap(ClamIcap)]),
|
"clamav-icap" => Some(vec![Service::ClamIcap(ClamIcap)]),
|
||||||
|
|
|
||||||
86
src/service/imaginary.rs
Normal file
86
src/service/imaginary.rs
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
use crate::config::HazeConfig;
|
||||||
|
use crate::image::pull_image;
|
||||||
|
use crate::service::ServiceTrait;
|
||||||
|
use crate::Result;
|
||||||
|
use bollard::container::{Config, CreateContainerOptions, NetworkingConfig};
|
||||||
|
use bollard::models::{EndpointSettings, HostConfig};
|
||||||
|
use bollard::Docker;
|
||||||
|
use maplit::hashmap;
|
||||||
|
use miette::IntoDiagnostic;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
|
pub struct Imaginary;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl ServiceTrait for Imaginary {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"imaginary"
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn spawn(
|
||||||
|
&self,
|
||||||
|
docker: &Docker,
|
||||||
|
cloud_id: &str,
|
||||||
|
network: &str,
|
||||||
|
_config: &HazeConfig,
|
||||||
|
) -> Result<Option<String>> {
|
||||||
|
let image = "nextcloud/aio-imaginary:latest";
|
||||||
|
pull_image(docker, image).await?;
|
||||||
|
let options = Some(CreateContainerOptions {
|
||||||
|
name: self.container_name(cloud_id).unwrap(),
|
||||||
|
..CreateContainerOptions::default()
|
||||||
|
});
|
||||||
|
let config = Config {
|
||||||
|
image: Some(image),
|
||||||
|
host_config: Some(HostConfig {
|
||||||
|
network_mode: Some(network.to_string()),
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
labels: Some(hashmap! {
|
||||||
|
"haze-type" => self.name(),
|
||||||
|
"haze-cloud-id" => cloud_id
|
||||||
|
}),
|
||||||
|
networking_config: Some(NetworkingConfig {
|
||||||
|
endpoints_config: hashmap! {
|
||||||
|
network => EndpointSettings {
|
||||||
|
aliases: Some(vec![self.name().to_string()]),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let id = docker
|
||||||
|
.create_container(options, config)
|
||||||
|
.await
|
||||||
|
.into_diagnostic()?
|
||||||
|
.id;
|
||||||
|
docker
|
||||||
|
.start_container::<String>(&id, None)
|
||||||
|
.await
|
||||||
|
.into_diagnostic()?;
|
||||||
|
Ok(Some(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn container_name(&self, cloud_id: &str) -> Option<String> {
|
||||||
|
Some(format!("{}-imaginary", cloud_id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// no need to wait for imaginary, as it won't be used until the user logs in
|
||||||
|
async fn is_healthy(&self, _docker: &Docker, _cloud_id: &str) -> Result<bool> {
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn post_setup(
|
||||||
|
&self,
|
||||||
|
_docker: &Docker,
|
||||||
|
_cloud_id: &str,
|
||||||
|
_config: &HazeConfig,
|
||||||
|
) -> Result<Vec<String>> {
|
||||||
|
Ok(vec![
|
||||||
|
"occ config:system:set enabledPreviewProviders 0 --value='OC\\Preview\\Imaginary'"
|
||||||
|
.into(),
|
||||||
|
"occ config:system:set preview_imaginary_url --value='http://imaginary:9000'".into(),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue