-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1713 from zmrow/etc-hosts-template
Add an entry to `/etc/hosts` for the current hostname
- Loading branch information
Showing
13 changed files
with
250 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 | ||
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 | ||
{{add_unresolvable_hostname settings.network.hostname}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
sources/api/migration/migrations/v1.2.1/etc-hosts-service/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "etc-hosts-service" | ||
version = "0.1.0" | ||
authors = ["Zac Mrowicki <[email protected]>"] | ||
license = "Apache-2.0 OR MIT" | ||
edition = "2018" | ||
publish = false | ||
# Don't rebuild crate just because of changes to README. | ||
exclude = ["README.md"] | ||
|
||
[dependencies] | ||
migration-helpers = { path = "../../../migration-helpers" } |
23 changes: 23 additions & 0 deletions
23
sources/api/migration/migrations/v1.2.1/etc-hosts-service/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#![deny(rust_2018_idioms)] | ||
|
||
use migration_helpers::common_migrations::AddPrefixesMigration; | ||
use migration_helpers::{migrate, Result}; | ||
use std::process; | ||
|
||
/// We added a new setting and generator for configuring hostname | ||
fn run() -> Result<()> { | ||
migrate(AddPrefixesMigration(vec![ | ||
"services.hosts", | ||
"configuration-files.hosts", | ||
])) | ||
} | ||
|
||
// Returning a Result from main makes it print a Debug representation of the error, but with Snafu | ||
// we have nice Display representations of the error, so we wrap "main" (run) and print any error. | ||
// https://github.com/shepmaster/snafu/issues/110 | ||
fn main() { | ||
if let Err(e) = run() { | ||
eprintln!("{}", e); | ||
process::exit(1); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
sources/api/migration/migrations/v1.2.1/hostname-affects-etc-hosts/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "hostname-affects-etc-hosts" | ||
version = "0.1.0" | ||
authors = ["Zac Mrowicki <[email protected]>"] | ||
license = "Apache-2.0 OR MIT" | ||
edition = "2018" | ||
publish = false | ||
# Don't rebuild crate just because of changes to README. | ||
exclude = ["README.md"] | ||
|
||
[dependencies] | ||
migration-helpers = { path = "../../../migration-helpers" } |
30 changes: 30 additions & 0 deletions
30
sources/api/migration/migrations/v1.2.1/hostname-affects-etc-hosts/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#![deny(rust_2018_idioms)] | ||
|
||
use migration_helpers::common_migrations::{ | ||
MetadataListReplacement, ReplaceMetadataListsMigration, | ||
}; | ||
use migration_helpers::{migrate, Result}; | ||
use std::process; | ||
|
||
/// We updated the 'affected-services' list metadata for 'settings.network.hostname' to include the | ||
/// hosts "service" on upgrade, and to remove it on downgrade. | ||
fn run() -> Result<()> { | ||
migrate(ReplaceMetadataListsMigration(vec![ | ||
MetadataListReplacement { | ||
setting: "settings.network.hostname", | ||
metadata: "affected-services", | ||
old_vals: &["hostname"], | ||
new_vals: &["hostname", "hosts"], | ||
}, | ||
])) | ||
} | ||
|
||
// Returning a Result from main makes it print a Debug representation of the error, but with Snafu | ||
// we have nice Display representations of the error, so we wrap "main" (run) and print any error. | ||
// https://github.com/shepmaster/snafu/issues/110 | ||
fn main() { | ||
if let Err(e) = run() { | ||
eprintln!("{}", e); | ||
process::exit(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.