mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 17:14:08 +02:00
autosetup
This commit is contained in:
parent
fadc4e14d0
commit
222c500e5c
3 changed files with 84 additions and 2 deletions
16
README.md
16
README.md
|
|
@ -14,9 +14,10 @@ Create a file `~/.config/haze/haze.toml` with the following options:
|
|||
|
||||
```toml
|
||||
sources_root = "/path/to/nextcloud/sources"
|
||||
work_dir = "/path/to/temp/folder" # optional, defaults to /tmp/haze
|
||||
```
|
||||
|
||||
See the [configuration section](#configuration) for more options.
|
||||
|
||||
## Managing instances
|
||||
|
||||
#### Start an instance
|
||||
|
|
@ -95,3 +96,16 @@ haze [match] logs
|
|||
```bash
|
||||
haze [match] stop
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Configuration is loaded from `~/.config/haze/haze.toml` and has the following options
|
||||
|
||||
```toml
|
||||
sources_root = "/srv/http/owncloud"
|
||||
|
||||
[auto_setup] # optional
|
||||
enabled = false # whether or not to automatically install nextcloud on `haze start`. optional, defaults to false
|
||||
username = "foo" # username for admin user during auto setup. optional, defaults to "admin"
|
||||
password = "bar" # password for admin user during auto setup. optional, defaults to "admin"
|
||||
```
|
||||
|
|
@ -9,12 +9,41 @@ pub struct HazeConfig {
|
|||
pub sources_root: Utf8PathBuf,
|
||||
#[serde(default = "default_work_dir")]
|
||||
pub work_dir: Utf8PathBuf,
|
||||
#[serde(default)]
|
||||
pub auto_setup: HazeAutoSetupConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct HazeAutoSetupConfig {
|
||||
pub enabled: bool,
|
||||
#[serde(default = "default_auto_setup_username")]
|
||||
pub username: String,
|
||||
#[serde(default = "default_auto_setup_password")]
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
impl Default for HazeAutoSetupConfig {
|
||||
fn default() -> HazeAutoSetupConfig {
|
||||
HazeAutoSetupConfig {
|
||||
enabled: false,
|
||||
username: default_auto_setup_username(),
|
||||
password: default_auto_setup_password(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_work_dir() -> Utf8PathBuf {
|
||||
"/tmp/haze".into()
|
||||
}
|
||||
|
||||
fn default_auto_setup_username() -> String {
|
||||
"admin".to_string()
|
||||
}
|
||||
|
||||
fn default_auto_setup_password() -> String {
|
||||
"admin".to_string()
|
||||
}
|
||||
|
||||
impl HazeConfig {
|
||||
pub fn load() -> Result<Self> {
|
||||
let dirs = ProjectDirs::from("nl", "icewind", "haze").unwrap();
|
||||
|
|
|
|||
41
src/main.rs
41
src/main.rs
|
|
@ -52,6 +52,37 @@ async fn main() -> Result<()> {
|
|||
HazeArgs::Start { options } => {
|
||||
let cloud = Cloud::create(&mut docker, options, &config).await?;
|
||||
println!("http://{}", cloud.ip.unwrap());
|
||||
if config.auto_setup.enabled {
|
||||
println!("Waiting for servers to start");
|
||||
cloud.wait_for_start(&mut docker).await?;
|
||||
println!(
|
||||
"Installing with username {} and password {}",
|
||||
config.auto_setup.username, config.auto_setup.password
|
||||
);
|
||||
cloud
|
||||
.exec(
|
||||
&mut docker,
|
||||
vec![
|
||||
"install",
|
||||
&config.auto_setup.username,
|
||||
&config.auto_setup.password,
|
||||
],
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
cloud
|
||||
.exec(
|
||||
&mut docker,
|
||||
vec![
|
||||
"sed",
|
||||
"-i",
|
||||
&format!("s/0 => 'localhost'/'{}'/", cloud.ip.unwrap()),
|
||||
"config/config.php",
|
||||
],
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
HazeArgs::Stop { filter } => {
|
||||
let cloud = Cloud::get_by_filter(&mut docker, filter, &config).await?;
|
||||
|
|
@ -103,7 +134,15 @@ async fn main() -> Result<()> {
|
|||
cloud.wait_for_start(&mut docker).await?;
|
||||
println!("Installing");
|
||||
cloud
|
||||
.exec(&mut docker, vec!["install", "admin", "admin"], false)
|
||||
.exec(
|
||||
&mut docker,
|
||||
vec![
|
||||
"install",
|
||||
&config.auto_setup.username,
|
||||
&config.auto_setup.password,
|
||||
],
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
if let Some(app) = path
|
||||
.as_ref()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue