aboutsummaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
Diffstat (limited to 'tool')
-rw-r--r--tool/Cargo.toml2
-rw-r--r--tool/src/main.rs36
2 files changed, 38 insertions, 0 deletions
diff --git a/tool/Cargo.toml b/tool/Cargo.toml
index a53e1bd..02738ec 100644
--- a/tool/Cargo.toml
+++ b/tool/Cargo.toml
@@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
jellycommon = { path = "../common" }
jellybase = { path = "../base" }
+jellyclient = { path = "../client" }
jellymatroska = { path = "../matroska" }
jellyremuxer = { path = "../remuxer" }
@@ -15,6 +16,7 @@ anyhow = "1.0.75"
clap = { version = "4.4.6", features = ["derive"] }
reqwest = { version = "0.11.20", features = ["blocking", "json"] }
indicatif = "0.17.7"
+tokio = { workspace = true }
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"
diff --git a/tool/src/main.rs b/tool/src/main.rs
index 26865c6..47c9a53 100644
--- a/tool/src/main.rs
+++ b/tool/src/main.rs
@@ -11,6 +11,7 @@ pub mod migrate;
use base64::Engine;
use clap::{Parser, Subcommand, ValueEnum};
use import::import;
+use jellyclient::{Instance, LoginDetails};
use jellycommon::{config::GlobalConfig, Node, NodeKind, NodePrivate, NodePublic};
use log::{info, warn};
use migrate::migrate;
@@ -76,6 +77,16 @@ enum Action {
mode: MigrateMode,
save_location: PathBuf,
},
+ Reimport {
+ /// Path to global jellything config
+ config: PathBuf,
+ /// Custom hostname, the config's is used by default
+ #[arg(long)]
+ hostname: Option<String>,
+ /// Disable TLS. Dont use this.
+ #[arg(long)]
+ no_tls: bool,
+ },
}
#[derive(Debug, Clone, Copy, PartialEq, ValueEnum)]
@@ -147,6 +158,31 @@ fn main() -> anyhow::Result<()> {
}
a @ Action::New { .. } => import(a, args.dry),
a @ Action::Migrate { .. } => migrate(a),
+ Action::Reimport {
+ config,
+ hostname,
+ no_tls,
+ } => tokio::runtime::Builder::new_multi_thread()
+ .enable_all()
+ .build()
+ .unwrap()
+ .block_on(async move {
+ let config = serde_yaml::from_reader::<_, GlobalConfig>(File::open(config)?)?;
+
+ let inst = Instance::new(hostname.unwrap_or(config.hostname.clone()), !no_tls);
+ info!("login");
+ let session = inst
+ .login(LoginDetails {
+ drop_permissions: None,
+ expire: None,
+ password: config.admin_password,
+ username: config.admin_username,
+ })
+ .await?;
+
+ session.reimport().await?;
+ Ok(())
+ }),
}
}