mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 09:04:12 +02:00
fix onlyoffice
This commit is contained in:
parent
a9ab4d50f2
commit
32eaad7ccd
1 changed files with 45 additions and 5 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::cloud::CloudOptions;
|
use crate::cloud::CloudOptions;
|
||||||
use crate::config::HazeConfig;
|
use crate::config::HazeConfig;
|
||||||
|
use crate::exec::exec;
|
||||||
use crate::image::pull_image;
|
use crate::image::pull_image;
|
||||||
use crate::service::ServiceTrait;
|
use crate::service::ServiceTrait;
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
|
|
@ -8,6 +9,7 @@ use bollard::models::{ContainerState, EndpointSettings, HostConfig};
|
||||||
use bollard::Docker;
|
use bollard::Docker;
|
||||||
use maplit::hashmap;
|
use maplit::hashmap;
|
||||||
use miette::{IntoDiagnostic, Report};
|
use miette::{IntoDiagnostic, Report};
|
||||||
|
use std::net::Ipv4Addr;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct OnlyOffice;
|
pub struct OnlyOffice;
|
||||||
|
|
@ -80,7 +82,7 @@ impl ServiceTrait for OnlyOffice {
|
||||||
&self,
|
&self,
|
||||||
docker: &Docker,
|
docker: &Docker,
|
||||||
cloud_id: &str,
|
cloud_id: &str,
|
||||||
_config: &HazeConfig,
|
config: &HazeConfig,
|
||||||
) -> Result<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)
|
||||||
|
|
@ -106,9 +108,47 @@ impl ServiceTrait for OnlyOffice {
|
||||||
} else {
|
} else {
|
||||||
return Err(Report::msg("onlyoffice not started"));
|
return Err(Report::msg("onlyoffice not started"));
|
||||||
};
|
};
|
||||||
Ok(vec![format!(
|
|
||||||
"occ config:app:set onlyoffice DocumentServerUrl --value http://{}/",
|
let mut secret = Vec::new();
|
||||||
ip
|
let exit = exec(
|
||||||
)])
|
docker,
|
||||||
|
self.container_name(cloud_id).unwrap(),
|
||||||
|
"root",
|
||||||
|
vec![
|
||||||
|
"/var/www/onlyoffice/documentserver/npm/json",
|
||||||
|
"-f",
|
||||||
|
"/etc/onlyoffice/documentserver/local.json",
|
||||||
|
"services.CoAuthoring.secret.session.string",
|
||||||
|
],
|
||||||
|
Vec::<String>::default(),
|
||||||
|
Some(&mut secret),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
if !exit.is_ok() {
|
||||||
|
dbg!(String::from_utf8_lossy(&secret));
|
||||||
|
return Err(Report::msg("Failed to get onlyoffice secret"));
|
||||||
|
}
|
||||||
|
let secret = String::from_utf8_lossy(&secret);
|
||||||
|
let secret = secret.trim();
|
||||||
|
|
||||||
|
if config.proxy.https && !config.proxy.address.is_empty() {
|
||||||
|
let addr = config.proxy.addr(
|
||||||
|
&self.container_name(cloud_id).unwrap(),
|
||||||
|
Ipv4Addr::UNSPECIFIED.into(),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(vec![
|
||||||
|
format!("occ config:app:set onlyoffice DocumentServerUrl --value {addr}/"),
|
||||||
|
format!("occ config:app:set onlyoffice jwt_secret --value {secret}"),
|
||||||
|
"occ onlyoffice:documentserver --check".into(),
|
||||||
|
])
|
||||||
|
} else {
|
||||||
|
Ok(vec![
|
||||||
|
format!("occ config:app:set onlyoffice DocumentServerUrl --value https://{ip}/"),
|
||||||
|
"occ config:app:set onlyoffice verify_peer_off --value true".into(),
|
||||||
|
format!("occ config:app:set onlyoffice jwt_secret --value {secret}"),
|
||||||
|
"occ onlyoffice:documentserver --check".into(),
|
||||||
|
])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue