aboutsummaryrefslogtreecommitdiff
path: root/tools/sendsms/src/config.rs
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-09-05 16:59:20 -0700
committerFranck Cuny <franck@fcuny.net>2022-09-07 19:12:12 -0700
commitc853a5078b0a8dee22bb69b971b8315f66033f49 (patch)
tree3c05da1eb7c9d39e936de21108f42a59765ab4ef /tools/sendsms/src/config.rs
parentmeta: ignore build for rust projects (diff)
downloadinfra-c853a5078b0a8dee22bb69b971b8315f66033f49.tar.gz
feat(tool/sendsms): a CLI to send SMS
This is a new tool to send SMS via Twilio's API. For now it supports a single subcommand: reboot. Using that subcommand, a SMS will be send with the name of the host and the IP address for the defined network interface. This is useful to be notified when one of my machine reboot, and what's the IP for the main interface (this is useful since my ISP does not provide a static IP). Change-Id: I5886a2c77ebd344ab3befa51a6bdd3d65bcc85d4
Diffstat (limited to 'tools/sendsms/src/config.rs')
-rw-r--r--tools/sendsms/src/config.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/sendsms/src/config.rs b/tools/sendsms/src/config.rs
new file mode 100644
index 0000000..da9435a
--- /dev/null
+++ b/tools/sendsms/src/config.rs
@@ -0,0 +1,23 @@
+use serde::Deserialize;
+use std::path::PathBuf;
+
+#[derive(Deserialize, Debug)]
+pub struct Config {
+ pub to: String,
+ pub from: String,
+ pub account_sid: String,
+ pub auth_token: String,
+ pub reboot: RebootConfig,
+}
+
+#[derive(Deserialize, Debug)]
+pub struct RebootConfig {
+ pub ifname: String,
+}
+
+impl Config {
+ pub fn load_from_file(filename: &PathBuf) -> std::io::Result<Config> {
+ let content = std::fs::read_to_string(filename)?;
+ Ok(toml::from_str(&content)?)
+ }
+}