diff options
Diffstat (limited to 'tool/src')
-rw-r--r-- | tool/src/main.rs | 36 |
1 files changed, 36 insertions, 0 deletions
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(()) + }), } } |