diff --git a/files/dinit.service b/files/dinit.service index 9cec8de..368ca53 100644 --- a/files/dinit.service +++ b/files/dinit.service @@ -1,6 +1,5 @@ type = process command = /usr/bin/hive-up daemon -stop-command = /usr/bin/hive-up cli --upgrade depends-on = network.target logfile = /var/log/dinit/hive-up.log log-type = file diff --git a/files/hive-up.toml b/files/hive-up.toml index cf4d035..befc3eb 100644 --- a/files/hive-up.toml +++ b/files/hive-up.toml @@ -4,8 +4,6 @@ check_interval = 58 # Tells hive-up to automatically download updates when awailable. download_updates = true -# Tells hive-up to automatically perform updates during system reboot -auto_update = false # In [kernel] section user may specify kernel cmd # [kernel] diff --git a/src/daemon.rs b/src/daemon.rs index ce3dc09..b161761 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -106,24 +106,6 @@ fn process_remoute( println!("Error while ansvering cli request: {}", ex); } } - // we should apply updates if any on reboot - BzzReq::ScheduleUpdate => { - // but only if we have actually any updates - if bzz_db.updates_available > 0 { - bzz_db.update_on_reboot = true; - // keep it simple Kira - // lets just return err from the loop if something wrong with db - hive_db::write_db(&bzz_db)?; - // signal remoute that evertyhing go OK - if let Err(ex) = hive_intercom::socket_send( - &listening_socket, - &client_addr, - BzzResp::Finish, - ) { - println!("Error while ansvering cli request: {}", ex); - } - } - } BzzReq::CheckForUpdates => { let resp = BzzResp::Working(1); if let Err(ex) = diff --git a/src/hive_db.rs b/src/hive_db.rs index b6fcfdf..2a2dd92 100644 --- a/src/hive_db.rs +++ b/src/hive_db.rs @@ -62,22 +62,12 @@ pub struct HiveDb { pub update_check_timestamp: u64, /// non zero if there is updates that can bee applied, showing numbers of packages that can be updated pub updates_available: u32, - /// true if last update was successful - /// if it is false - nyanit need to roll back snapshots - pub update_status: bool, - /// datetime of last snapshot in format "%Y-%m-%dT%H:%M:%S" - pub last_snapshot_time: String, - /// set to true if we want to apply available updates on reboot - pub update_on_reboot: bool, } fn init_db() -> Result { let bzz_db = HiveDb{ update_check_timestamp: 0, updates_available: 0, - update_status: false, - last_snapshot_time: "".into(), - update_on_reboot: false, }; write_db(&bzz_db)?; Ok(bzz_db) diff --git a/src/hive_intercom.rs b/src/hive_intercom.rs index 4f9d800..990b7f0 100644 --- a/src/hive_intercom.rs +++ b/src/hive_intercom.rs @@ -96,7 +96,6 @@ pub enum BzzResp { pub enum BzzReq { UpdatesAvailable, CheckForUpdates, - ScheduleUpdate, } pub fn socket_bind(read_timeout_sec: u64) -> Result { @@ -194,12 +193,3 @@ pub fn client_check_for_updates() -> Result { _ => Err(IntercomError::UnexpectedResponse), } } - -pub fn client_schedule_update() -> Result<(), IntercomError> { - let resp = send_and_recv(BzzReq::ScheduleUpdate)?; - match resp { - BzzResp::Finish => Ok(()), - BzzResp::Error(ex) => Err(IntercomError::ServerError(ex)), - _ => Err(IntercomError::UnexpectedResponse), - } -} diff --git a/src/main.rs b/src/main.rs index 12dd0d6..3f81af9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,9 +24,6 @@ mod hive_system; mod hive_config; -use crate::hive_config::HiveConfig; -use crate::hive_system::SysUpgradeError; - mod daemon; mod hive_db; mod hive_intercom; @@ -118,18 +115,11 @@ struct RemoteArgs { /// Ask daemon if there is any updates available #[arg(long)] updates_avail: bool, - - /// Ask daemon to perform system update on next reboot - #[arg(long)] - schedule_update: bool, } #[derive(Args, Debug)] #[group(required = true, multiple = false)] struct CliArgs { - /// Perform system upgrade - #[arg(long)] - upgrade: bool, /// Install new kernel into boot partition #[arg(long)] update_boot: bool, @@ -161,33 +151,6 @@ struct Cli { mode: HiveUpMode, } -fn cli_upgrade(bzz_config: HiveConfig) -> Result<(), HiveUpError> { - let mut bzz_db = hive_db::read_db()?; - - if (bzz_db.updates_available !=0) && (bzz_db.update_on_reboot || bzz_config.update.auto_update) { - println!("Starting full system upgrade"); - bzz_db.update_status = false; - hive_db::write_db(&bzz_db)?; - match hive_system::sys_upgrade() { - Ok(snap_time) => { - bzz_db.update_status = true; - bzz_db.update_on_reboot = false; - bzz_db.last_snapshot_time = snap_time; - hive_db::write_db(&bzz_db)?; - } - Err(SysUpgradeError::PkgUpgradeErr((snap_time, ex))) => { - bzz_db.update_status = false; - bzz_db.update_on_reboot = false; - bzz_db.last_snapshot_time = snap_time; - hive_db::write_db(&bzz_db)?; - return Err(ex.into()); - } - Err(ex) => return Err(ex.to_string().into()), - } - } - Ok(()) -} - fn main() -> Result<(), HiveUpError> { // registering signals handling let term_flag: Arc = Arc::new(AtomicBool::new(false)); @@ -208,9 +171,7 @@ fn main() -> Result<(), HiveUpError> { match args.mode { HiveUpMode::Daemon => daemon::run(bzz_config, term_flag.clone(), reload_flag.clone())?, HiveUpMode::Cli(cli_args) => { - if cli_args.upgrade { - cli_upgrade(bzz_config)?; - } else if cli_args.update_boot { + if cli_args.update_boot { println!("Updating boot..."); hive_system::boot_update()?; } else if cli_args.init_boot_menu { @@ -233,10 +194,6 @@ fn main() -> Result<(), HiveUpError> { } else if remote_args.updates_avail { let up_num = hive_intercom::client_updates_available()?; println!("Updates awailable: {}", up_num); - } else if remote_args.schedule_update { - println!("Scheduling system update..."); - hive_intercom::client_schedule_update()?; - print!("Done!") } } }