mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 09:04:12 +02:00
fix office
This commit is contained in:
parent
3b4014b5e4
commit
a80354c922
1 changed files with 39 additions and 25 deletions
|
|
@ -32,6 +32,23 @@ impl ServiceTrait for Office {
|
||||||
config: &HazeConfig,
|
config: &HazeConfig,
|
||||||
_options: &CloudOptions,
|
_options: &CloudOptions,
|
||||||
) -> Result<Vec<String>> {
|
) -> Result<Vec<String>> {
|
||||||
|
let network_info = docker
|
||||||
|
.inspect_network(&network, None)
|
||||||
|
.await
|
||||||
|
.into_diagnostic()?;
|
||||||
|
let gateway = network_info
|
||||||
|
.ipam
|
||||||
|
.as_ref()
|
||||||
|
.ok_or_else(|| Report::msg("Network has no ip info"))?
|
||||||
|
.config
|
||||||
|
.as_deref()
|
||||||
|
.ok_or_else(|| Report::msg("Network has no ip info"))?
|
||||||
|
.first()
|
||||||
|
.ok_or_else(|| Report::msg("Network has no ip info"))?
|
||||||
|
.gateway
|
||||||
|
.as_deref()
|
||||||
|
.ok_or_else(|| Report::msg("Network has no ip info"))?;
|
||||||
|
|
||||||
let image = "collabora/code";
|
let image = "collabora/code";
|
||||||
pull_image(docker, image).await?;
|
pull_image(docker, image).await?;
|
||||||
let container_id = self.container_name(cloud_id).unwrap();
|
let container_id = self.container_name(cloud_id).unwrap();
|
||||||
|
|
@ -39,28 +56,31 @@ impl ServiceTrait for Office {
|
||||||
name: Some(container_id.clone()),
|
name: Some(container_id.clone()),
|
||||||
..CreateContainerOptions::default()
|
..CreateContainerOptions::default()
|
||||||
});
|
});
|
||||||
let mut env = vec!["extra_params=--o:ssl.enable=false --o:ssl.termination=true"];
|
let mut env =
|
||||||
|
vec![r#"extra_params=--o:ssl.enable=false --o:ssl.termination=true --o:net.frame_ancestors=*"#.to_string()];
|
||||||
|
|
||||||
|
let proxy_base = &config.proxy.address;
|
||||||
let clean_id = container_id.strip_prefix("haze-").unwrap_or(&container_id);
|
let clean_id = container_id.strip_prefix("haze-").unwrap_or(&container_id);
|
||||||
let server_name_opt = match (&config.proxy.address, config.proxy.https) {
|
if !proxy_base.is_empty() {
|
||||||
(public, true) if !public.is_empty() => {
|
env.push(format!("server_name={clean_id}.{}", config.proxy.address));
|
||||||
format!("server_name={clean_id}.{public}")
|
|
||||||
}
|
|
||||||
(public, false) if !public.is_empty() => {
|
|
||||||
format!("server_name={clean_id}.{public}")
|
|
||||||
}
|
|
||||||
_ => "".to_string(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if !server_name_opt.is_empty() {
|
|
||||||
env.push(&server_name_opt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let clean_cloud_id = cloud_id.strip_prefix("haze-").unwrap_or(&cloud_id);
|
||||||
|
let hosts = if proxy_base.is_empty() {
|
||||||
|
vec![]
|
||||||
|
} else {
|
||||||
|
vec![
|
||||||
|
format!("{proxy_base}:{gateway}"),
|
||||||
|
format!("{clean_cloud_id}.{proxy_base}:{gateway}"),
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
let config = ContainerCreateBody {
|
let config = ContainerCreateBody {
|
||||||
image: Some(image.into()),
|
image: Some(image.into()),
|
||||||
env: Some(env.into_iter().map(String::from).collect()),
|
env: Some(env.into_iter().map(String::from).collect()),
|
||||||
host_config: Some(HostConfig {
|
host_config: Some(HostConfig {
|
||||||
network_mode: Some(network.to_string()),
|
network_mode: Some(network.to_string()),
|
||||||
|
extra_hosts: Some(hosts),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
labels: Some(hashmap! {
|
labels: Some(hashmap! {
|
||||||
|
|
@ -127,19 +147,13 @@ impl ServiceTrait for Office {
|
||||||
} else {
|
} else {
|
||||||
return Err(Report::msg("office not started"));
|
return Err(Report::msg("office not started"));
|
||||||
};
|
};
|
||||||
|
let public = config
|
||||||
|
.proxy
|
||||||
|
.addr_with_port(container, ip, self.proxy_port());
|
||||||
|
|
||||||
Ok(vec![
|
Ok(vec![
|
||||||
format!(
|
format!(r#"occ config:app:set richdocuments public_wopi_url --value="{public}""#),
|
||||||
r#"occ config:app:set richdocuments wopi_url --value="http://{}:9980""#,
|
r#"occ richdocuments:setup --wopi-url "http://office:9980" --callback-url "http://cloud""#.into(),
|
||||||
ip
|
|
||||||
),
|
|
||||||
format!(
|
|
||||||
r#"occ config:app:set richdocuments public_wopi_url --value="{}""#,
|
|
||||||
config.proxy.addr_with_port(container, ip, 9980)
|
|
||||||
),
|
|
||||||
format!(
|
|
||||||
r#"occ config:app:set richdocuments wopi_root --value="http://{}""#,
|
|
||||||
cloud_id
|
|
||||||
),
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue