diff --git a/Cargo.lock b/Cargo.lock index 17f7fa137b..9b413b60bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -181,9 +181,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "arrayref" @@ -327,18 +327,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -549,9 +549,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "bitvec" @@ -673,9 +673,9 @@ dependencies = [ [[package]] name = "bs58" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ "tinyvec", ] @@ -705,9 +705,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.14.3" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" +checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" [[package]] name = "byteorder" @@ -881,9 +881,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.2" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" +checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" dependencies = [ "clap_builder", "clap_derive", @@ -903,14 +903,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.0" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -930,9 +930,9 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "color-eyre" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" +checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" dependencies = [ "backtrace", "color-spantrace", @@ -1114,7 +1114,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.5.2", + "clap 4.5.3", "criterion-plot", "is-terminal", "itertools 0.10.5", @@ -1226,7 +1226,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1405,7 +1405,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1481,7 +1481,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1735,9 +1735,9 @@ checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" +checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ "futures-core", "pin-project-lite", @@ -1751,7 +1751,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1879,7 +1879,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "ignore", "walkdir", ] @@ -1911,9 +1911,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" dependencies = [ "bytes", "fnv", @@ -1946,9 +1946,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e57fa0ae458eb99874f54c09f4f9174f8b45fb87e854536a4e608696247f0c23" dependencies = [ "ahash", "allocator-api2", @@ -1993,6 +1993,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -2267,7 +2273,7 @@ dependencies = [ "ipnet", "log", "rtnetlink", - "system-configuration 0.5.1", + "system-configuration", "tokio", "windows", ] @@ -2330,7 +2336,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.4", ] [[package]] @@ -2827,7 +2833,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2941,7 +2947,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", "redox_syscall", ] @@ -2989,7 +2995,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.4", ] [[package]] @@ -3291,7 +3297,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if", "libc", ] @@ -3721,7 +3727,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -3943,9 +3949,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -3970,7 +3976,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -3981,7 +3987,7 @@ checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.4.2", + "bitflags 2.5.0", "lazy_static", "num-traits", "rand", @@ -4326,9 +4332,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.25" +version = "0.11.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eea5a9eb898d3783f17c6407670e3592fd174cb81a10e51d4c37f49450b9946" +checksum = "78bf93c4af7a8bb7d879d51cebe797356ff10ae8516ace542b5182d9dcac10b2" dependencies = [ "base64 0.21.7", "bytes", @@ -4353,7 +4359,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper", - "system-configuration 0.6.0", + "system-configuration", "tokio", "tokio-rustls 0.24.1", "tower-service", @@ -4487,7 +4493,7 @@ version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -4721,7 +4727,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4758,9 +4764,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.32" +version = "0.9.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd075d994154d4a774f95b51fb96bdc2832b0ea48425c92546073816cda1f2f" +checksum = "a0623d197252096520c6f2a5e1171ee436e5af99a5d7caa2891e55e61950e6d9" dependencies = [ "indexmap 2.2.5", "itoa", @@ -4873,7 +4879,7 @@ dependencies = [ "assert_fs", "assert_matches", "async-trait", - "clap 4.5.2", + "clap 4.5.3", "color-eyre", "colored", "dirs-next", @@ -4904,9 +4910,9 @@ dependencies = [ [[package]] name = "sn-releases" -version = "0.1.7" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fd09c844c16b72f6a34a090f642a9685d48f86345f67d607586900a93c0fd47" +checksum = "e6a96b5beffe1eb01d46e3270c0b25723ed556cc96d75301c31aacc492057a64" dependencies = [ "async-trait", "chrono", @@ -4914,6 +4920,7 @@ dependencies = [ "lazy_static", "regex", "reqwest", + "semver", "serde_json", "tar", "thiserror", @@ -4937,7 +4944,7 @@ dependencies = [ "blsttc", "bytes", "chrono", - "clap 4.5.2", + "clap 4.5.3", "color-eyre", "criterion 0.5.1", "custom_debug", @@ -5022,7 +5029,7 @@ dependencies = [ "base64 0.21.7", "bitcoin", "blsttc", - "clap 4.5.2", + "clap 4.5.3", "color-eyre", "dirs-next", "hex", @@ -5070,7 +5077,7 @@ dependencies = [ name = "sn_metrics" version = "0.1.3-alpha.0" dependencies = [ - "clap 4.5.2", + "clap 4.5.3", "color-eyre", "dirs-next", "regex", @@ -5129,7 +5136,7 @@ dependencies = [ "blsttc", "bytes", "chrono", - "clap 4.5.2", + "clap 4.5.3", "color-eyre", "crdts", "custom_debug", @@ -5182,7 +5189,7 @@ dependencies = [ "assert_fs", "async-trait", "blsttc", - "clap 4.5.2", + "clap 4.5.3", "color-eyre", "hex", "libp2p", @@ -5206,7 +5213,7 @@ dependencies = [ name = "sn_peers_acquisition" version = "0.2.8" dependencies = [ - "clap 4.5.2", + "clap 4.5.3", "libp2p", "rand", "reqwest", @@ -5418,7 +5425,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -5463,9 +5470,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" dependencies = [ "proc-macro2", "quote", @@ -5513,18 +5520,7 @@ checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", "core-foundation", - "system-configuration-sys 0.5.0", -] - -[[package]] -name = "system-configuration" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bc6ee10a9b4fcf576e9b0819d95ec16f4d2c02d39fd83ac1c8789785c4a42" -dependencies = [ - "bitflags 2.4.2", - "core-foundation", - "system-configuration-sys 0.6.0", + "system-configuration-sys", ] [[package]] @@ -5537,16 +5533,6 @@ dependencies = [ "libc", ] -[[package]] -name = "system-configuration-sys" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tap" version = "1.0.1" @@ -5601,22 +5587,22 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -5769,7 +5755,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -5795,9 +5781,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", @@ -5980,7 +5966,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -6225,9 +6211,9 @@ dependencies = [ [[package]] name = "unsafe-libyaml" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" [[package]] name = "unsigned-varint" @@ -6294,9 +6280,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ "getrandom", ] @@ -6417,7 +6403,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", "wasm-bindgen-shared", ] @@ -6451,7 +6437,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6866,7 +6852,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -6886,7 +6872,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] diff --git a/sn_node_manager/Cargo.toml b/sn_node_manager/Cargo.toml index e6cab5a8fb..eeed976687 100644 --- a/sn_node_manager/Cargo.toml +++ b/sn_node_manager/Cargo.toml @@ -44,7 +44,7 @@ service-manager = "0.6.0" sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.2.8" } sn_protocol = { path = "../sn_protocol", version = "0.15.4" } sn_service_management = { path = "../sn_service_management", version = "0.1.1" } -sn-releases = "0.1.7" +sn-releases = "0.2.0" sn_transfers = { path = "../sn_transfers", version = "0.16.4" } sysinfo = "0.29.10" tokio = { version = "1.26", features = ["full"] } diff --git a/sn_node_manager/src/add_services/config.rs b/sn_node_manager/src/add_services/config.rs index 805f0a9b66..bebf8a7cc5 100644 --- a/sn_node_manager/src/add_services/config.rs +++ b/sn_node_manager/src/add_services/config.rs @@ -108,11 +108,10 @@ pub struct AddNodeServiceOptions { pub local: bool, pub node_port: Option, pub rpc_address: Option, - pub safenode_bin_path: PathBuf, + pub safenode_src_path: PathBuf, pub safenode_dir_path: PathBuf, pub service_data_dir_path: PathBuf, pub service_log_dir_path: PathBuf, - pub url: Option, pub user: String, pub version: String, } @@ -163,20 +162,21 @@ impl InstallFaucetServiceCtxBuilder { pub struct AddFaucetServiceOptions { pub bootstrap_peers: Vec, pub env_variables: Option>, - pub faucet_download_bin_path: PathBuf, pub faucet_install_bin_path: PathBuf, + pub faucet_src_bin_path: PathBuf, pub local: bool, pub service_data_dir_path: PathBuf, pub service_log_dir_path: PathBuf, - pub url: Option, pub user: String, pub version: String, } pub struct AddDaemonServiceOptions { pub address: Ipv4Addr, - pub port: u16, - pub daemon_download_bin_path: PathBuf, + pub env_variables: Option>, pub daemon_install_bin_path: PathBuf, + pub daemon_src_bin_path: PathBuf, + pub port: u16, + pub user: String, pub version: String, } diff --git a/sn_node_manager/src/add_services/mod.rs b/sn_node_manager/src/add_services/mod.rs index 0efc0e5618..7bbb241ec6 100644 --- a/sn_node_manager/src/add_services/mod.rs +++ b/sn_node_manager/src/add_services/mod.rs @@ -74,7 +74,7 @@ pub async fn add_node( } let safenode_file_name = options - .safenode_bin_path + .safenode_src_path .file_name() .ok_or_else(|| eyre!("Could not get filename from the safenode download path"))? .to_string_lossy() @@ -138,7 +138,7 @@ pub async fn add_node( create_owned_dir(service_log_dir_path.clone(), &options.user)?; std::fs::copy( - options.safenode_bin_path.clone(), + options.safenode_src_path.clone(), service_safenode_path.clone(), )?; let install_ctx = InstallNodeServiceCtxBuilder { @@ -201,7 +201,7 @@ pub async fn add_node( }; } - std::fs::remove_file(options.safenode_bin_path)?; + std::fs::remove_file(options.safenode_src_path)?; if !added_service_data.is_empty() { println!("Services Added:"); @@ -242,13 +242,11 @@ pub fn add_daemon( } std::fs::copy( - options.daemon_download_bin_path.clone(), + options.daemon_src_bin_path.clone(), options.daemon_install_bin_path.clone(), )?; let install_ctx = ServiceInstallCtx { - label: DAEMON_SERVICE_NAME.parse()?, - program: options.daemon_install_bin_path.clone(), args: vec![ OsString::from("--port"), OsString::from(options.port.to_string()), @@ -256,9 +254,11 @@ pub fn add_daemon( OsString::from(options.address.to_string()), ], contents: None, - username: None, + environment: options.env_variables, + label: DAEMON_SERVICE_NAME.parse()?, + program: options.daemon_install_bin_path.clone(), + username: Some(options.user), working_directory: None, - environment: None, }; match service_control.install(install_ctx) { @@ -275,7 +275,7 @@ pub fn add_daemon( println!("Daemon service added {}", "✓".green()); println!("[!] Note: the service has not been started"); node_registry.save()?; - std::fs::remove_file(options.daemon_download_bin_path)?; + std::fs::remove_file(options.daemon_src_bin_path)?; Ok(()) } Err(e) => { @@ -307,7 +307,7 @@ pub fn add_faucet( )?; std::fs::copy( - install_options.faucet_download_bin_path.clone(), + install_options.faucet_src_bin_path.clone(), install_options.faucet_install_bin_path.clone(), )?; @@ -350,7 +350,7 @@ pub fn add_faucet( ); } println!("[!] Note: the service has not been started"); - std::fs::remove_file(install_options.faucet_download_bin_path)?; + std::fs::remove_file(install_options.faucet_src_bin_path)?; node_registry.save()?; Ok(()) } diff --git a/sn_node_manager/src/add_services/tests.rs b/sn_node_manager/src/add_services/tests.rs index c2db11af99..33b6959d89 100644 --- a/sn_node_manager/src/add_services/tests.rs +++ b/sn_node_manager/src/add_services/tests.rs @@ -133,14 +133,13 @@ async fn add_genesis_node_should_use_latest_version_and_add_one_service() -> Res local: true, genesis: true, count: None, - safenode_bin_path: safenode_download_path.to_path_buf(), + safenode_src_path: safenode_download_path.to_path_buf(), safenode_dir_path: temp_dir.to_path_buf(), service_data_dir_path: node_data_dir.to_path_buf(), service_log_dir_path: node_logs_dir.to_path_buf(), node_port: None, bootstrap_peers: vec![], rpc_address: None, - url: None, user: get_username(), version: latest_version.to_string(), env_variables: None, @@ -228,14 +227,13 @@ async fn add_genesis_node_should_return_an_error_if_there_is_already_a_genesis_n local: true, genesis: true, count: None, - safenode_bin_path: safenode_download_path.to_path_buf(), + safenode_src_path: safenode_download_path.to_path_buf(), safenode_dir_path: temp_dir.to_path_buf(), service_data_dir_path: node_data_dir.to_path_buf(), service_log_dir_path: node_logs_dir.to_path_buf(), node_port: None, bootstrap_peers: vec![], rpc_address: Some(custom_rpc_address), - url: None, user: get_username(), version: latest_version.to_string(), env_variables: None, @@ -286,14 +284,13 @@ async fn add_genesis_node_should_return_an_error_if_count_is_greater_than_1() -> local: true, genesis: true, count: Some(3), - safenode_bin_path: safenode_download_path.to_path_buf(), + safenode_src_path: safenode_download_path.to_path_buf(), safenode_dir_path: temp_dir.to_path_buf(), service_data_dir_path: node_data_dir.to_path_buf(), service_log_dir_path: node_logs_dir.to_path_buf(), node_port: None, bootstrap_peers: vec![], rpc_address: Some(custom_rpc_address), - url: None, user: get_username(), version: latest_version.to_string(), env_variables: None, @@ -441,11 +438,10 @@ async fn add_node_should_use_latest_version_and_add_three_services() -> Result<( bootstrap_peers: vec![], node_port: None, rpc_address: None, - safenode_bin_path: safenode_download_path.to_path_buf(), + safenode_src_path: safenode_download_path.to_path_buf(), safenode_dir_path: temp_dir.to_path_buf(), service_data_dir_path: node_data_dir.to_path_buf(), service_log_dir_path: node_logs_dir.to_path_buf(), - url: None, user: get_username(), version: latest_version.to_string(), env_variables: None, @@ -576,14 +572,13 @@ async fn add_node_should_update_the_bootstrap_peers_inside_node_registry() -> Re local: false, genesis: false, count: None, - safenode_bin_path: safenode_download_path.to_path_buf(), + safenode_src_path: safenode_download_path.to_path_buf(), safenode_dir_path: temp_dir.to_path_buf(), service_data_dir_path: node_data_dir.to_path_buf(), service_log_dir_path: node_logs_dir.to_path_buf(), bootstrap_peers: new_peers.clone(), node_port: None, rpc_address: Some(Ipv4Addr::new(127, 0, 0, 1)), - url: None, user: get_username(), version: latest_version.to_string(), env_variables: None, @@ -688,14 +683,13 @@ async fn add_node_should_update_the_environment_variables_inside_node_registry() local: false, genesis: false, count: None, - safenode_bin_path: safenode_download_path.to_path_buf(), + safenode_src_path: safenode_download_path.to_path_buf(), safenode_dir_path: temp_dir.to_path_buf(), service_data_dir_path: node_data_dir.to_path_buf(), service_log_dir_path: node_logs_dir.to_path_buf(), bootstrap_peers: vec![], node_port: None, rpc_address: Some(Ipv4Addr::new(127, 0, 0, 1)), - url: None, user: get_username(), version: latest_version.to_string(), env_variables: env_variables.clone(), @@ -813,11 +807,10 @@ async fn add_new_node_should_add_another_service() -> Result<()> { bootstrap_peers: vec![], node_port: None, rpc_address: None, - safenode_bin_path: safenode_download_path.to_path_buf(), + safenode_src_path: safenode_download_path.to_path_buf(), safenode_dir_path: temp_dir.to_path_buf(), service_data_dir_path: node_data_dir.to_path_buf(), service_log_dir_path: node_logs_dir.to_path_buf(), - url: None, user: get_username(), version: latest_version.to_string(), env_variables: None, @@ -913,14 +906,13 @@ async fn add_node_should_use_custom_ports_for_one_service() -> Result<()> { local: false, genesis: false, count: None, - safenode_bin_path: safenode_download_path.to_path_buf(), + safenode_src_path: safenode_download_path.to_path_buf(), safenode_dir_path: temp_dir.to_path_buf(), service_data_dir_path: node_data_dir.to_path_buf(), service_log_dir_path: node_logs_dir.to_path_buf(), bootstrap_peers: vec![], node_port: Some(PortRange::Single(custom_port)), rpc_address: Some(Ipv4Addr::new(127, 0, 0, 1)), - url: None, user: get_username(), version: latest_version.to_string(), env_variables: None, @@ -1123,14 +1115,13 @@ async fn add_node_should_use_a_custom_port_range() -> Result<()> { local: false, genesis: false, count: Some(3), - safenode_bin_path: safenode_download_path.to_path_buf(), + safenode_src_path: safenode_download_path.to_path_buf(), safenode_dir_path: temp_dir.to_path_buf(), service_data_dir_path: node_data_dir.to_path_buf(), service_log_dir_path: node_logs_dir.to_path_buf(), bootstrap_peers: vec![], node_port: Some(PortRange::Range(12000, 12002)), rpc_address: Some(Ipv4Addr::new(127, 0, 0, 1)), - url: None, user: get_username(), version: latest_version.to_string(), env_variables: None, @@ -1176,14 +1167,13 @@ async fn add_node_should_return_an_error_if_port_and_node_count_do_not_match() - local: false, genesis: false, count: Some(2), - safenode_bin_path: safenode_download_path.to_path_buf(), + safenode_src_path: safenode_download_path.to_path_buf(), safenode_dir_path: temp_dir.to_path_buf(), service_data_dir_path: node_data_dir.to_path_buf(), service_log_dir_path: node_logs_dir.to_path_buf(), bootstrap_peers: vec![], node_port: Some(PortRange::Range(12000, 12002)), rpc_address: Some(Ipv4Addr::new(127, 0, 0, 1)), - url: None, user: get_username(), version: latest_version.to_string(), env_variables: None, @@ -1235,14 +1225,13 @@ async fn add_node_should_return_an_error_if_multiple_services_are_specified_with local: false, genesis: false, count: Some(2), - safenode_bin_path: safenode_download_path.to_path_buf(), + safenode_src_path: safenode_download_path.to_path_buf(), safenode_dir_path: temp_dir.to_path_buf(), service_data_dir_path: node_data_dir.to_path_buf(), service_log_dir_path: node_logs_dir.to_path_buf(), bootstrap_peers: vec![], node_port: Some(PortRange::Single(12000)), rpc_address: Some(Ipv4Addr::new(127, 0, 0, 1)), - url: None, user: get_username(), version: latest_version.to_string(), env_variables: None, @@ -1316,12 +1305,11 @@ async fn add_faucet_should_add_a_faucet_service() -> Result<()> { AddFaucetServiceOptions { bootstrap_peers: vec![], env_variables: Some(vec![("SN_LOG".to_string(), "all".to_string())]), - faucet_download_bin_path: faucet_download_path.to_path_buf(), + faucet_src_bin_path: faucet_download_path.to_path_buf(), faucet_install_bin_path: faucet_install_path.to_path_buf(), local: false, service_data_dir_path: faucet_data_dir.to_path_buf(), service_log_dir_path: faucet_logs_dir.to_path_buf(), - url: None, user: get_username(), version: latest_version.to_string(), }, @@ -1387,12 +1375,11 @@ async fn add_faucet_should_return_an_error_if_a_faucet_service_was_already_creat AddFaucetServiceOptions { bootstrap_peers: vec![], env_variables: Some(vec![("SN_LOG".to_string(), "all".to_string())]), - faucet_download_bin_path: faucet_download_path.to_path_buf(), + faucet_src_bin_path: faucet_download_path.to_path_buf(), faucet_install_bin_path: faucet_install_path.to_path_buf(), local: false, service_data_dir_path: faucet_data_dir.to_path_buf(), service_log_dir_path: faucet_logs_dir.to_path_buf(), - url: None, user: get_username(), version: latest_version.to_string(), }, @@ -1449,10 +1436,10 @@ async fn add_daemon_should_add_a_daemon_service() -> Result<()> { OsString::from("127.0.0.1"), ], contents: None, - environment: None, + environment: Some(vec![("SN_LOG".to_string(), "ALL".to_string())]), label: "safenodemand".parse()?, program: daemon_install_path.to_path_buf(), - username: None, + username: Some(get_username()), working_directory: None, })) .returning(|_| Ok(())); @@ -1460,9 +1447,11 @@ async fn add_daemon_should_add_a_daemon_service() -> Result<()> { add_daemon( AddDaemonServiceOptions { address: Ipv4Addr::new(127, 0, 0, 1), - port: 8080, - daemon_download_bin_path: daemon_download_path.to_path_buf(), daemon_install_bin_path: daemon_install_path.to_path_buf(), + daemon_src_bin_path: daemon_download_path.to_path_buf(), + env_variables: Some(vec![("SN_LOG".to_string(), "ALL".to_string())]), + port: 8080, + user: get_username(), version: latest_version.to_string(), }, &mut node_registry, @@ -1519,9 +1508,11 @@ async fn add_daemon_should_return_an_error_if_a_daemon_service_was_already_creat let result = add_daemon( AddDaemonServiceOptions { address: Ipv4Addr::new(127, 0, 0, 1), - port: 8080, - daemon_download_bin_path: daemon_download_path.to_path_buf(), daemon_install_bin_path: daemon_install_path.to_path_buf(), + daemon_src_bin_path: daemon_download_path.to_path_buf(), + env_variables: Some(Vec::new()), + port: 8080, + user: get_username(), version: latest_version.to_string(), }, &mut node_registry, diff --git a/sn_node_manager/src/bin/cli/main.rs b/sn_node_manager/src/bin/cli/main.rs index d8560f2ed6..ead39795d7 100644 --- a/sn_node_manager/src/bin/cli/main.rs +++ b/sn_node_manager/src/bin/cli/main.rs @@ -30,7 +30,10 @@ pub(crate) struct Cmd { #[derive(Subcommand, Debug)] pub enum SubCmd { - /// Add one or more new safenode services. + /// Add one or more safenode services. + /// + /// By default, the latest safenode binary will be downloaded; however, it is possible to + /// provide a binary either by specifying a URL, a local path, or a specific version number. /// /// This command must run as the root/administrative user. #[clap(name = "add")] @@ -51,6 +54,13 @@ pub enum SubCmd { /// - Windows: C:\ProgramData\safenode\services #[clap(long, verbatim_doc_comment)] data_dir_path: Option, + /// Provide environment variables for the safenode service. + /// + /// Useful to set log levels. Variables should be comma separated without spaces. + /// + /// Example: --env SN_LOG=all,RUST_LOG=libp2p=debug + #[clap(name = "env", long, use_value_delimiter = true, value_parser = parse_environment_variables)] + env_variables: Option>, /// Set this flag to launch safenode with the --local flag. /// /// This is useful for building a service-based local network. @@ -66,6 +76,11 @@ pub enum SubCmd { /// - Windows: C:\ProgramData\safenode\logs #[clap(long, verbatim_doc_comment)] log_dir_path: Option, + /// Provide a path for the safenode binary to be used by the service. + /// + /// Useful for creating the service using a custom built binary. + #[clap(long)] + path: Option, #[command(flatten)] peers: PeersArgs, /// Specify a port for the safenode service(s). @@ -84,14 +99,6 @@ pub enum SubCmd { /// /// If not set, the RPC server is run locally. rpc_address: Option, - /// Provide environment variables for the safenode service. - /// - /// Useful to set safenode's log levels. Variables should be comma separated without - /// spaces. - /// - /// Example: --env SN_LOG=all,RUST_LOG=libp2p=debug - #[clap(name = "env", long, use_value_delimiter = true, value_parser = parse_environment_variables)] - env_variables: Option>, /// Provide a safenode binary using a URL. /// /// The binary must be inside a zip or gzipped tar archive. @@ -108,7 +115,9 @@ pub enum SubCmd { /// On Windows this argument will have no effect. #[clap(long)] user: Option, - /// The version of safenode + /// Provide a specific version of safenode to be installed. + /// + /// The binary will be downloaded. #[clap(long)] version: Option, }, @@ -333,6 +342,9 @@ pub enum SubCmd { pub enum DaemonSubCmd { /// Add a daemon service for issuing commands via RPC. /// + /// By default, the latest safenodemand binary will be downloaded; however, it is possible to + /// provide a binary either by specifying a URL, a local path, or a specific version number. + /// /// This command must run as the root/administrative user. #[clap(name = "add")] Add { @@ -343,12 +355,35 @@ pub enum DaemonSubCmd { /// If not set, the daemon listens locally. #[clap(long, default_value_t = Ipv4Addr::new(127, 0, 0, 1))] address: Ipv4Addr, + /// Provide environment variables for the daemon service. + /// + /// Useful to set log levels. Variables should be comma separated without spaces. + /// + /// Example: --env SN_LOG=all,RUST_LOG=libp2p=debug + #[clap(name = "env", long, use_value_delimiter = true, value_parser = parse_environment_variables)] + env_variables: Option>, /// Specify a port for the daemon to listen on. #[clap(long, default_value_t = 12500)] port: u16, - /// The path of the safenodemand binary + /// Provide a path for the daemon binary to be used by the service. + /// + /// Useful for creating the daemon service using a custom built binary. + #[clap(long)] + path: Option, + /// Provide a faucet binary using a URL. + /// + /// The binary must be inside a zip or gzipped tar archive. + /// + /// This option can be used to test a faucet binary that has been built from a forked + /// branch and uploaded somewhere. A typical use case would be for a developer who launches + /// a testnet to test some changes they have on a fork. + #[clap(long, conflicts_with = "version")] + url: Option, + /// Provide a specific version of the daemon to be installed. + /// + /// The binary will be downloaded. #[clap(long)] - path: PathBuf, + version: Option, }, /// Start the daemon service. /// @@ -368,6 +403,9 @@ pub enum DaemonSubCmd { pub enum FaucetSubCmd { /// Add a faucet service. /// + /// By default, the latest faucet binary will be downloaded; however, it is possible to provide + /// a binary either by specifying a URL, a local path, or a specific version number. + /// /// This command must run as the root/administrative user. /// /// Windows is not supported for running a faucet. @@ -375,8 +413,7 @@ pub enum FaucetSubCmd { Add { /// Provide environment variables for the faucet service. /// - /// Useful for setting log levels. Each variable should be comma separated without any - /// space. + /// Useful to set log levels. Variables should be comma separated without spaces. /// /// Example: --env SN_LOG=all,RUST_LOG=libp2p=debug #[clap(name = "env", long, use_value_delimiter = true, value_parser = parse_environment_variables)] @@ -386,6 +423,11 @@ pub enum FaucetSubCmd { /// If not provided, the default location /var/log/faucet. #[clap(long, verbatim_doc_comment)] log_dir_path: Option, + /// Provide a path for the faucet binary to be used by the service. + /// + /// Useful for creating the faucet service using a custom built binary. + #[clap(long)] + path: Option, #[command(flatten)] peers: PeersArgs, /// Provide a faucet binary using a URL. @@ -397,7 +439,9 @@ pub enum FaucetSubCmd { /// a testnet to test some changes they have on a fork. #[clap(long, conflicts_with = "version")] url: Option, - /// The version of the faucet + /// Provide a specific version of the faucet to be installed. + /// + /// The binary will be downloaded. #[clap(long)] version: Option, }, @@ -434,8 +478,7 @@ pub enum FaucetSubCmd { /// /// Values set when the service was added will be overridden. /// - /// Useful to set safenode's log levels. Variables should be comma separated without - /// spaces. + /// Useful to set log levels. Variables should be comma separated without spaces. /// /// Example: --env SN_LOG=all,RUST_LOG=libp2p=debug #[clap(name = "env", long, use_value_delimiter = true, value_parser = parse_environment_variables)] @@ -466,6 +509,7 @@ async fn main() -> Result<()> { env_variables, local, log_dir_path, + path, peers, port, rpc_address, @@ -482,6 +526,7 @@ async fn main() -> Result<()> { peers, port, rpc_address, + path, url, user, version, @@ -491,20 +536,33 @@ async fn main() -> Result<()> { } SubCmd::Daemon(DaemonSubCmd::Add { address, + env_variables, port, path, - }) => cmd::daemon::add(address, port, path, verbosity).await, + url, + version, + }) => cmd::daemon::add(address, env_variables, port, path, url, version, verbosity).await, SubCmd::Daemon(DaemonSubCmd::Start {}) => cmd::daemon::start(verbosity).await, SubCmd::Daemon(DaemonSubCmd::Stop {}) => cmd::daemon::stop(verbosity).await, SubCmd::Faucet(faucet_command) => match faucet_command { FaucetSubCmd::Add { env_variables, log_dir_path, + path, peers, url, version, } => { - cmd::faucet::add(env_variables, log_dir_path, peers, url, version, verbosity).await + cmd::faucet::add( + env_variables, + log_dir_path, + peers, + path, + url, + version, + verbosity, + ) + .await } FaucetSubCmd::Start {} => cmd::faucet::start(verbosity).await, FaucetSubCmd::Stop {} => cmd::faucet::stop(verbosity).await, diff --git a/sn_node_manager/src/cmd/daemon.rs b/sn_node_manager/src/cmd/daemon.rs index c2b06f4b11..f660f9d720 100644 --- a/sn_node_manager/src/cmd/daemon.rs +++ b/sn_node_manager/src/cmd/daemon.rs @@ -10,17 +10,21 @@ use super::is_running_as_root; use crate::{ add_services::{add_daemon, config::AddDaemonServiceOptions}, config, - helpers::get_bin_version, + helpers::{download_and_extract_release, get_bin_version}, ServiceManager, VerbosityLevel, }; use color_eyre::{eyre::eyre, Result}; +use sn_releases::{ReleaseType, SafeReleaseRepoActions}; use sn_service_management::{control::ServiceController, DaemonService, NodeRegistry}; use std::{net::Ipv4Addr, path::PathBuf}; pub async fn add( address: Ipv4Addr, + env_variables: Option>, port: u16, - path: PathBuf, + src_path: Option, + url: Option, + version: Option, verbosity: VerbosityLevel, ) -> Result<()> { if !is_running_as_root() { @@ -34,14 +38,34 @@ pub async fn add( } let mut node_registry = NodeRegistry::load(&config::get_node_registry_path()?)?; + let release_repo = ::default_config(); + + let (daemon_src_bin_path, version) = if let Some(path) = src_path { + let version = get_bin_version(&path)?; + (path, version) + } else { + download_and_extract_release( + ReleaseType::SafenodeManagerDaemon, + url.clone(), + version, + &*release_repo, + ) + .await? + }; + + // At the moment we don't have the option to provide a user for running the service. Since + // `safenodemand` requires manipulation of services, the user running it must either be root or + // have root access. For now we will just use the `root` user. The user option gets ignored on + // Windows anyway, so there shouldn't be a cross-platform issue here. add_daemon( AddDaemonServiceOptions { address, + env_variables, + daemon_install_bin_path: config::get_daemon_install_path(), + daemon_src_bin_path, port, - daemon_download_bin_path: path.clone(), - // TODO: make this cross platform - daemon_install_bin_path: PathBuf::from("/usr/local/bin/safenodemand"), - version: get_bin_version(&path)?, + user: "root".to_string(), + version, }, &mut node_registry, &ServiceController {}, diff --git a/sn_node_manager/src/cmd/faucet.rs b/sn_node_manager/src/cmd/faucet.rs index b700f1402a..abdb21cc04 100644 --- a/sn_node_manager/src/cmd/faucet.rs +++ b/sn_node_manager/src/cmd/faucet.rs @@ -10,14 +10,14 @@ use super::{download_and_get_upgrade_bin_path, is_running_as_root, print_upgrade use crate::{ add_services::{add_faucet, config::AddFaucetServiceOptions}, config, - helpers::download_and_extract_release, + helpers::{download_and_extract_release, get_bin_version}, ServiceManager, VerbosityLevel, }; use color_eyre::{eyre::eyre, Result}; use colored::Colorize; use semver::Version; use sn_peers_acquisition::{get_peers_from_args, PeersArgs}; -use sn_releases::{ReleaseType, SafeReleaseRepositoryInterface}; +use sn_releases::{ReleaseType, SafeReleaseRepoActions}; use sn_service_management::{ control::{ServiceControl, ServiceController}, FaucetService, NodeRegistry, UpgradeOptions, @@ -29,6 +29,7 @@ pub async fn add( env_variables: Option>, log_dir_path: Option, peers: PeersArgs, + src_path: Option, url: Option, version: Option, verbosity: VerbosityLevel, @@ -51,22 +52,25 @@ pub async fn add( config::get_service_log_dir_path(ReleaseType::Faucet, log_dir_path, service_user)?; let mut node_registry = NodeRegistry::load(&config::get_node_registry_path()?)?; - let release_repo = ::default_config(); + let release_repo = ::default_config(); - let (faucet_download_path, version) = + let (faucet_src_bin_path, version) = if let Some(path) = src_path { + let version = get_bin_version(&path)?; + (path, version) + } else { download_and_extract_release(ReleaseType::Faucet, url.clone(), version, &*release_repo) - .await?; + .await? + }; add_faucet( AddFaucetServiceOptions { bootstrap_peers: get_peers_from_args(peers).await?, env_variables, - faucet_download_bin_path: faucet_download_path, + faucet_src_bin_path, faucet_install_bin_path: PathBuf::from("/usr/local/bin/faucet"), local: false, service_data_dir_path: get_faucet_data_dir(), service_log_dir_path, - url, user: service_user.to_string(), version, }, diff --git a/sn_node_manager/src/cmd/local.rs b/sn_node_manager/src/cmd/local.rs index bddf02a485..3e211c6ae7 100644 --- a/sn_node_manager/src/cmd/local.rs +++ b/sn_node_manager/src/cmd/local.rs @@ -15,7 +15,7 @@ use crate::{ }; use color_eyre::{eyre::eyre, Help, Report, Result}; use sn_peers_acquisition::{get_peers_from_args, PeersArgs}; -use sn_releases::{ReleaseType, SafeReleaseRepositoryInterface}; +use sn_releases::{ReleaseType, SafeReleaseRepoActions}; use sn_service_management::{ control::ServiceController, get_local_node_registry_path, NodeRegistry, }; @@ -39,7 +39,7 @@ pub async fn join( let local_node_reg_path = &get_local_node_registry_path()?; let mut local_node_registry = NodeRegistry::load(local_node_reg_path)?; - let release_repo = ::default_config(); + let release_repo = ::default_config(); let faucet_path = get_bin_path( build, faucet_path, @@ -136,7 +136,7 @@ pub async fn run( println!("================================================="); } - let release_repo = ::default_config(); + let release_repo = ::default_config(); let faucet_path = get_bin_path( build, faucet_path, diff --git a/sn_node_manager/src/cmd/mod.rs b/sn_node_manager/src/cmd/mod.rs index 3eaa0b570e..27f5436c6e 100644 --- a/sn_node_manager/src/cmd/mod.rs +++ b/sn_node_manager/src/cmd/mod.rs @@ -15,7 +15,7 @@ use crate::helpers::download_and_extract_release; use color_eyre::{eyre::eyre, Result}; use colored::Colorize; use semver::Version; -use sn_releases::{ReleaseType, SafeReleaseRepositoryInterface}; +use sn_releases::{ReleaseType, SafeReleaseRepoActions}; use sn_service_management::UpgradeResult; use std::{ path::PathBuf, @@ -37,7 +37,7 @@ pub async fn download_and_get_upgrade_bin_path( url: Option, version: Option, ) -> Result<(PathBuf, Version)> { - let release_repo = ::default_config(); + let release_repo = ::default_config(); if let Some(version) = version { let (upgrade_bin_path, version) = download_and_extract_release(release_type, None, Some(version), &*release_repo).await?; @@ -51,7 +51,6 @@ pub async fn download_and_get_upgrade_bin_path( let latest_version = release_repo .get_latest_version(&ReleaseType::Safenode) .await?; - let latest_version = Version::parse(&latest_version)?; println!("Latest version is {latest_version}"); let (upgrade_bin_path, _) = download_and_extract_release( ReleaseType::Safenode, @@ -97,7 +96,7 @@ pub async fn get_bin_path( path: Option, release_type: ReleaseType, version: Option, - release_repo: &dyn SafeReleaseRepositoryInterface, + release_repo: &dyn SafeReleaseRepoActions, ) -> Result { if build { build_binary(&release_type)?; diff --git a/sn_node_manager/src/cmd/node.rs b/sn_node_manager/src/cmd/node.rs index 7dcbc16d37..321b6613d3 100644 --- a/sn_node_manager/src/cmd/node.rs +++ b/sn_node_manager/src/cmd/node.rs @@ -15,7 +15,7 @@ use crate::{ config::{AddNodeServiceOptions, PortRange}, }, config, - helpers::download_and_extract_release, + helpers::{download_and_extract_release, get_bin_version}, status_report, ServiceManager, VerbosityLevel, }; use color_eyre::{eyre::eyre, Help, Result}; @@ -23,7 +23,7 @@ use colored::Colorize; use libp2p_identity::PeerId; use semver::Version; use sn_peers_acquisition::{get_peers_from_args, PeersArgs}; -use sn_releases::{ReleaseType, SafeReleaseRepositoryInterface}; +use sn_releases::{ReleaseType, SafeReleaseRepoActions}; use sn_service_management::{ control::{ServiceControl, ServiceController}, get_local_node_registry_path, @@ -41,6 +41,7 @@ pub async fn add( peers: PeersArgs, port: Option, rpc_address: Option, + src_path: Option, url: Option, user: Option, version: Option, @@ -66,11 +67,16 @@ pub async fn add( config::get_service_log_dir_path(ReleaseType::Safenode, log_dir_path, &service_user)?; let mut node_registry = NodeRegistry::load(&config::get_node_registry_path()?)?; - let release_repo = ::default_config(); + let release_repo = ::default_config(); - let (safenode_download_path, version) = + let (safenode_src_path, version) = if let Some(path) = src_path { + let version = get_bin_version(&path)?; + (path, version) + } else { download_and_extract_release(ReleaseType::Safenode, url.clone(), version, &*release_repo) - .await?; + .await? + }; + let options = AddNodeServiceOptions { local, genesis: peers.first, @@ -78,11 +84,10 @@ pub async fn add( bootstrap_peers: get_peers_from_args(peers).await?, node_port: port, rpc_address, - safenode_bin_path: safenode_download_path, + safenode_src_path, safenode_dir_path: service_data_dir_path.clone(), service_data_dir_path, service_log_dir_path, - url, user: service_user, version, env_variables, diff --git a/sn_node_manager/src/config.rs b/sn_node_manager/src/config.rs index fbcc5fe2e8..06f0b540cb 100644 --- a/sn_node_manager/src/config.rs +++ b/sn_node_manager/src/config.rs @@ -10,6 +10,16 @@ use color_eyre::Result; use sn_releases::ReleaseType; use std::path::{Path, PathBuf}; +#[cfg(unix)] +pub fn get_daemon_install_path() -> PathBuf { + PathBuf::from("/usr/local/bin/safenodemand") +} + +#[cfg(windows)] +pub fn get_daemon_install_path() -> PathBuf { + PathBuf::from("C:\\ProgramData\\safenodemand\\safenodemand.exe") +} + #[cfg(unix)] pub fn get_node_manager_path() -> Result { // This needs to be a system-wide location rather than a user directory because the `install` diff --git a/sn_node_manager/src/helpers.rs b/sn_node_manager/src/helpers.rs index a625dad53f..92917e14f7 100644 --- a/sn_node_manager/src/helpers.rs +++ b/sn_node_manager/src/helpers.rs @@ -11,7 +11,8 @@ use color_eyre::{ Result, }; use indicatif::{ProgressBar, ProgressStyle}; -use sn_releases::{get_running_platform, ArchiveType, ReleaseType, SafeReleaseRepositoryInterface}; +use semver::Version; +use sn_releases::{get_running_platform, ArchiveType, ReleaseType, SafeReleaseRepoActions}; use std::{ io::Read, path::PathBuf, @@ -22,11 +23,15 @@ use std::{ const MAX_DOWNLOAD_RETRIES: u8 = 3; /// Downloads and extracts a release binary to a temporary location. +/// +/// If the URL is supplied, that will be downloaded and extracted, and the binary inside the +/// archive will be used; if the version is supplied, a specific version will be downloaded and +/// used; otherwise the latest version will be downloaded and used. pub async fn download_and_extract_release( release_type: ReleaseType, url: Option, version: Option, - release_repo: &dyn SafeReleaseRepositoryInterface, + release_repo: &dyn SafeReleaseRepoActions, ) -> Result<(PathBuf, String)> { let pb = Arc::new(ProgressBar::new(0)); pb.set_style(ProgressStyle::default_bar() @@ -61,7 +66,7 @@ pub async fn download_and_extract_release( } } else { let version = if let Some(version) = version.clone() { - version + Version::parse(&version)? } else { println!("Retrieving latest version for {release_type}..."); release_repo.get_latest_version(&release_type).await? diff --git a/sn_node_manager/tests/upgrades.rs b/sn_node_manager/tests/upgrades.rs index dff4a2dbf9..5691c0b5fc 100644 --- a/sn_node_manager/tests/upgrades.rs +++ b/sn_node_manager/tests/upgrades.rs @@ -10,7 +10,7 @@ mod utils; use assert_cmd::Command; use color_eyre::Result; -use sn_releases::{ReleaseType, SafeReleaseRepositoryInterface}; +use sn_releases::{ReleaseType, SafeReleaseRepoActions}; use utils::get_service_status; const CI_USER: &str = "runner"; @@ -45,7 +45,7 @@ async fn upgrade_to_latest_version() -> Result<()> { "Services were not correctly initialised" ); - let release_repo = ::default_config(); + let release_repo = ::default_config(); let latest_version = release_repo .get_latest_version(&ReleaseType::Safenode) .await?; @@ -65,7 +65,10 @@ async fn upgrade_to_latest_version() -> Result<()> { let status = get_service_status().await?; assert!( - status.nodes.iter().all(|n| n.version == latest_version), + status + .nodes + .iter() + .all(|n| n.version == latest_version.to_string()), "Not all services were updated to the latest version" );