Skip to content

Commit 60c6b5e

Browse files
committed
Restart machine
Add an action to reboot the machine without setting next boot Useful for pulling an updated version of uefi executable
1 parent 4c64893 commit 60c6b5e

4 files changed

Lines changed: 24 additions & 8 deletions

File tree

pixie-server/src/state/units.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ impl State {
137137
action
138138
} else {
139139
match unit.next_action {
140-
Action::Store | Action::Flash | Action::Register => {
140+
Action::Restart | Action::Store | Action::Flash | Action::Register => {
141141
unit.curr_action = Some(unit.next_action);
142142
unit.next_action = Action::Wait;
143143
modified = true;
144144
}
145-
Action::Reboot | Action::Wait | Action::Shutdown => {
145+
Action::Boot | Action::Wait | Action::Shutdown => {
146146
modified = false;
147147
}
148148
}

pixie-shared/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ pub const UDP_BODY_LEN: usize = 1472;
118118
#[serde(rename_all = "lowercase")]
119119
pub enum Action {
120120
/// Reboot into the OS.
121-
Reboot,
121+
Boot,
122+
/// Restart the machine.
123+
Restart,
122124
/// Shutdown the machine.
123125
Shutdown,
124126
/// Register the machine.
@@ -134,7 +136,8 @@ pub enum Action {
134136
impl Display for Action {
135137
fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
136138
match self {
137-
Action::Reboot => write!(fmt, "reboot"),
139+
Action::Boot => write!(fmt, "reboot"),
140+
Action::Restart => write!(fmt, "restart"),
138141
Action::Shutdown => write!(fmt, "shutdown"),
139142
Action::Register => write!(fmt, "register"),
140143
Action::Store => write!(fmt, "store"),

pixie-uefi/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ async fn run(os: UefiOS) -> Result<()> {
144144
log::info!("Command: {command:?}");
145145
match command {
146146
Action::Wait => unreachable!(),
147-
Action::Reboot => reboot_to_os(os).await,
147+
Action::Boot => reboot_to_os(os).await,
148+
Action::Restart => {}
148149
Action::Shutdown => shutdown(os).await,
149150
Action::Register => register(os, server).await?,
150151
Action::Store => store(os, server).await?,
@@ -155,6 +156,10 @@ async fn run(os: UefiOS) -> Result<()> {
155156
complete_action(&tcp).await?;
156157
tcp.close_send().await;
157158
tcp.force_close().await;
159+
160+
if command == Action::Restart {
161+
os.reset();
162+
}
158163
}
159164
}
160165
}

pixie-web/src/main.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ fn Group(
148148
let mac = move || unit.get().mac.to_string();
149149
let url_flash = move || format!("admin/action/{}/flash", mac());
150150
let url_store = move || format!("admin/action/{}/store", mac());
151-
let url_boot = move || format!("admin/action/{}/reboot", mac());
151+
let url_boot = move || format!("admin/action/{}/boot", mac());
152+
let url_restart = move || format!("admin/action/{}/restart", mac());
152153
let url_cancel = move || format!("admin/action/{}/wait", mac());
153154
let url_register = move || format!("admin/action/{}/register", mac());
154155
let url_shutdown = move || format!("admin/action/{}/shutdown", mac());
@@ -206,7 +207,10 @@ fn Group(
206207
"store"
207208
</Button>
208209
<Button color=ButtonColor::Success on_click=move |_| send_req(url_boot())>
209-
"reboot"
210+
"boot"
211+
</Button>
212+
<Button color=ButtonColor::Success on_click=move |_| send_req(url_restart())>
213+
"restart"
210214
</Button>
211215
<Button color=ButtonColor::Primary on_click=move |_| send_req(url_cancel())>
212216
"wait"
@@ -237,7 +241,8 @@ fn Group(
237241
};
238242

239243
let url_flash = move || format!("admin/action/{}/flash", group_name.get());
240-
let url_boot = move || format!("admin/action/{}/reboot", group_name.get());
244+
let url_boot = move || format!("admin/action/{}/boot", group_name.get());
245+
let url_restart = move || format!("admin/action/{}/restart", group_name.get());
241246
let url_cancel = move || format!("admin/action/{}/wait", group_name.get());
242247

243248
let image_button = move |image: String| {
@@ -260,6 +265,9 @@ fn Group(
260265
<Button color=ButtonColor::Success on_click=move |_| send_req(url_boot())>
261266
"Set all machines to boot into the OS"
262267
</Button>
268+
<Button color=ButtonColor::Success on_click=move |_| send_req(url_restart())>
269+
"Restart all machines"
270+
</Button>
263271
<Button color=ButtonColor::Primary on_click=move |_| send_req(url_cancel())>
264272
"Set all machines to wait for next command"
265273
</Button>

0 commit comments

Comments
 (0)