Skip to content

Commit

Permalink
More reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
erinharrington-12 committed Jun 14, 2024
1 parent 3900976 commit b38127e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/HomeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,30 +150,40 @@ void HomeWidget::reboot()
msgBox->setText(""); // Hide the default text to avoid duplication
msgBox->show();

// Debug information
qDebug() << "Message box displayed, starting reboot sequence...";

// Use a QTimer to delay the reboot process
QTimer::singleShot(2000, [this, msgBox]() {
QTimer::singleShot(2000, this, [this, msgBox]() {
qDebug() << "Stopping create3_server.service...";
// Stop create3_server.service
QProcess create3ServerStop;
create3ServerStop.start("sudo", QStringList() << "systemctl" << "stop" << "create3_server.service");
bool create3StopRet = create3ServerStop.waitForFinished();
qDebug() << "Create 3 server stop return value: " << create3StopRet;
qDebug() << "Create 3 server exit code: " << create3ServerStop.exitCode();
if (!create3StopRet || create3ServerStop.exitCode() != 0)
{
QMessageBox::information(this, "Failed", "Create 3 server could not be stopped.");
msgBox->close();
return;
}

qDebug() << "Rebooting the system...";
// Reboot the system
QProcess rebootProcess;
rebootProcess.start("sudo", QStringList() << "reboot");
bool rebootRet = rebootProcess.waitForFinished();
qDebug() << "Reboot process return value: " << rebootRet;
qDebug() << "Reboot process exit code: " << rebootProcess.exitCode();
if (!rebootRet || rebootProcess.exitCode() != 0)
{
QMessageBox::information(this, "Failed", "Reboot failed.");
}

msgBox->close();
});

#else
QMessageBox::information(this, "Not Available", "Reboot is only available on the kovan.");
#endif
Expand Down

0 comments on commit b38127e

Please sign in to comment.