Update process improvements; preparing for v1.1

This commit is contained in:
Nicolas Mailloux 2021-03-27 15:13:37 -04:00
parent f9427488bf
commit 61e83d2596
2 changed files with 40 additions and 5 deletions

View file

@ -86,20 +86,54 @@ MainWindow::MainWindow(QWidget *parent)
stylesheetFile.close(); stylesheetFile.close();
// Running rootfs changes script if it's there // Running rootfs changes script if it's there
// This is a BIG security flaw. Hopefully I'll get an idea later and I'll find out a better way to do that... // This is a BIG security flaw. I'll try to find something that could replace it but in a safer way.
if(checkconfig("/opt/inkbox_genuine") == true) { if(checkconfig("/opt/inkbox_genuine") == true) {
if(checkconfig("/external_root/opt/update/inkbox_updated") == true) { if(checkconfig("/external_root/opt/update/inkbox_updated") == true) {
QFile::copy("/mnt/onboard/onboard/.inkbox/rootfs.sh", "/external_root/rootfs.sh"); // Checking if we need to reboot after running the two scripts
if(checkconfig("/mnt/onboard/onboard/.inkbox/reboot") == true) {
reboot_after_update = true;
QFile::remove("/mnt/onboard/onboard/.inkbox/reboot");
}
else {
reboot_after_update = false;
}
QFile::copy("/mnt/onboard/onboard/.inkbox/rootfs.sh", "/external_root/tmp/rootfs.sh");
QFile::copy("/mnt/onboard/onboard/.inkbox/rootfs-internal.sh", "/tmp/rootfs-internal.sh");
// First script
QString rootfs_prog ("chroot"); QString rootfs_prog ("chroot");
QStringList rootfs_args; QStringList rootfs_args;
rootfs_args << "/external_root" << "/rootfs.sh"; rootfs_args << "/external_root" << "/tmp/rootfs.sh";
// Removing script
QFile::remove("/mnt/onboard/onboard/.inkbox/rootfs.sh");
QProcess *rootfs_proc = new QProcess(); QProcess *rootfs_proc = new QProcess();
rootfs_proc->start(rootfs_prog, rootfs_args); rootfs_proc->start(rootfs_prog, rootfs_args);
rootfs_proc->waitForFinished(); rootfs_proc->waitForFinished();
QFile::remove("/mnt/onboard/onboard/.inkbox/rootfs.sh"); // Second script
QFile::remove("/external_root/rootfs.sh"); QString rootfs_internal_prog ("sh");
QStringList rootfs_internal_args;
rootfs_internal_args << "/tmp/rootfs-internal.sh";
// Removing script
QFile::remove("/mnt/onboard/onboard/.inkbox/rootfs-internal.sh");
QProcess *rootfs_internal_proc = new QProcess();
rootfs_internal_proc->start(rootfs_internal_prog, rootfs_internal_args);
rootfs_internal_proc->waitForFinished();
// Rebooting if needed
if(reboot_after_update == true) {
QString rebootProg("busybox");
QStringList rebootArgs;
rebootArgs << "reboot";
QProcess *rebootProc = new QProcess();
rebootProc->start(rebootProg, rebootArgs);
rebootProc->waitForFinished();
}
else {
// Update process finished.
;
}
} }
} }
else { else {

View file

@ -25,6 +25,7 @@ public:
~MainWindow(); ~MainWindow();
bool checked_box = false; bool checked_box = false;
bool existing_recent_books = false; bool existing_recent_books = false;
bool reboot_after_update = false;
QString checkconfig_str_val; QString checkconfig_str_val;
QString relative_path; QString relative_path;
bool checkconfig(QString file) { bool checkconfig(QString file) {