1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 17:14:08 +02:00

overwrite hosts

This commit is contained in:
Robin Appelman 2021-08-13 16:48:01 +02:00
commit e92b595804
2 changed files with 39 additions and 33 deletions

View file

@ -302,7 +302,8 @@ impl Cloud {
.unwrap() .unwrap()
.networks .networks
.unwrap() .unwrap()
.values() .iter()
.filter_map(|(name, network)| name.eq("haze").then(|| network))
.next() .next()
.unwrap() .unwrap()
.ip_address .ip_address
@ -401,9 +402,18 @@ impl Cloud {
} }
} }
pub async fn occ<S: Into<String>>(
&self,
docker: &Docker,
cmd: Vec<S>,
output: Option<&mut Vec<u8>>,
) -> Result<ExitCode> {
self.exec_with_output(docker, cmd, output).await
}
pub async fn exec_with_output<S: Into<String>>( pub async fn exec_with_output<S: Into<String>>(
&self, &self,
docker: &mut Docker, docker: &Docker,
cmd: Vec<S>, cmd: Vec<S>,
output: Option<impl Write>, output: Option<impl Write>,
) -> Result<ExitCode> { ) -> Result<ExitCode> {
@ -445,7 +455,7 @@ impl Cloud {
let cloud = cloud?; let cloud = cloud?;
let network = id.clone(); let network = id.clone();
let networks = cloud.network_settings?.networks?; let networks = cloud.network_settings?.networks?;
let network_info = networks.get(&network)?; let network_info = networks.get("haze")?;
let workdir = config.work_dir.join(&id); let workdir = config.work_dir.join(&id);
let labels = cloud.labels?; let labels = cloud.labels?;
let db = labels.get("haze-db")?.parse().ok()?; let db = labels.get("haze-db")?.parse().ok()?;

View file

@ -70,6 +70,7 @@ async fn main() -> Result<()> {
"Installing with username {} and password {}", "Installing with username {} and password {}",
config.auto_setup.username, config.auto_setup.password config.auto_setup.username, config.auto_setup.password
); );
let ip_str = format!("{}", cloud.ip.unwrap());
cloud cloud
.exec( .exec(
&mut docker, &mut docker,
@ -82,47 +83,42 @@ async fn main() -> Result<()> {
) )
.await?; .await?;
cloud cloud
.exec_with_output( .occ(
&mut docker, &mut docker,
vec![ vec![
"occ",
"config:system:set", "config:system:set",
"trusted_domains", "overwrite.cli.url",
"1",
"--value", "--value",
&format!("{}", cloud.ip.unwrap()), &format!("http://{}", cloud.ip.unwrap()),
], ],
Option::<&mut Vec<u8>>::None, None,
) )
.await?; .await?;
cloud cloud
.exec_with_output( .occ(
&mut docker, &mut docker,
vec![ vec!["config:system:set", "overwritehost", "--value", &ip_str],
"occ", None,
"config:system:set",
"trusted_domains",
"2",
"--value",
"cloud",
],
Option::<&mut Vec<u8>>::None,
)
.await?;
cloud
.exec_with_output(
&mut docker,
vec![
"occ",
"config:system:set",
"trusted_domains",
"3",
"--value",
&cloud.id,
],
Option::<&mut Vec<u8>>::None,
) )
.await?; .await?;
let domains = [ip_str.as_str(), "cloud", &cloud.id];
for (i, domain) in domains.iter().enumerate() {
cloud
.occ(
&mut docker,
vec![
"config:system:set",
"trusted_domains",
&format!("{}", i),
"--value",
domain,
],
None,
)
.await?;
}
for service in &cloud.services { for service in &cloud.services {
for app in service.apps() { for app in service.apps() {
cloud cloud