diff --git a/Cargo.lock b/Cargo.lock index 6b47eee..e76bfbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1299,7 +1299,7 @@ dependencies = [ ] [[package]] -name = "peach-dyndns-host" +name = "peach-dyndns-server" version = "0.1.0" dependencies = [ "clap-log-flag", diff --git a/Cargo.toml b/Cargo.toml index 772d13d..76a495b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "peach-dyndns-host" +name = "peach-dyndns-server" version = "0.1.0" authors = ["Michael Williams ", "Max Fowler "] edition = "2018" @@ -24,6 +24,13 @@ dotenv = "0.15.0" tera = "1" regex = "1" -[[bin]] -name = "main" -path = "src/main.rs" \ No newline at end of file +[package.metadata.deb] +depends = "$auto" +extended-description = """\ +peach-dyndns is an http API to create dynamic-dns configurations for bind9.""" +maintainer-scripts="debian" +systemd-units = { unit-name = "peach-dyndns-server" } +assets = [ + ["target/release/peach-dyndns-server", "usr/bin/", "755"], +] + diff --git a/Rocket.toml b/Rocket.toml new file mode 100644 index 0000000..39eb01a --- /dev/null +++ b/Rocket.toml @@ -0,0 +1,3 @@ +[default] +template_dir = "templates/" +port = 3001 diff --git a/debian/peach-dyndns-server.service b/debian/peach-dyndns-server.service new file mode 100644 index 0000000..9086591 --- /dev/null +++ b/debian/peach-dyndns-server.service @@ -0,0 +1,13 @@ +[Unit] +Description=An http API to create dynamic-dns configurations for bind9. + +[Service] +Type=simple +User=peach-dyndns +Group=bind +Environment="RUST_LOG=info" +ExecStart=/usr/bin/peach-dyndns-server +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/src/main.rs b/src/main.rs index 34a8770..17a32bd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,8 @@ extern crate rocket; use crate::routes::{index, register_domain, check_available}; +use rocket::Config; +use rocket::figment::{Figment, Profile, providers::{Format, Toml, Serialized, Env}}; mod cli; mod routes; @@ -15,7 +17,12 @@ mod generate_zone; async fn main() { let _args = cli::args().expect("error parsing args"); - let rocket_result = rocket::build() + // the following config says to use all default rocket configs + // and then override them with any configs specified in Rocket.toml + let config = Figment::from(rocket::Config::default()) + .merge(Toml::file("Rocket.toml").nested()); + + let rocket_result = rocket::custom(config) .mount("/", routes![index, register_domain, check_available]) .launch() .await;