bugfix/dry-run-tui-freeze (#88)
Fixes #87 Reviewed-on: #88 Co-authored-by: localhorst <localhorst@mosad.xyz> Co-committed-by: localhorst <localhorst@mosad.xyz>
This commit is contained in:
16
README.md
16
README.md
@ -16,9 +16,9 @@ Use [Etcher](https://www.balena.io/etcher/#download) or `dd` to create an bootab
|
|||||||
## Screenshot
|
## Screenshot
|
||||||

|

|
||||||
|
|
||||||
## Debian Build Notes
|
## openSUSE Build Notes
|
||||||
|
|
||||||
* `apt-get install ncurses-dev git make g++`
|
* `zypper install ncurses-devel git make gcc-c++`
|
||||||
* `git submodule init`
|
* `git submodule init`
|
||||||
* `git submodule update`
|
* `git submodule update`
|
||||||
* `make release`
|
* `make release`
|
||||||
@ -28,16 +28,8 @@ Use [Etcher](https://www.balena.io/etcher/#download) or `dd` to create an bootab
|
|||||||
Just install [reHDDPrinter](https://git.mosad.xyz/localhorst/reHDDPrinter).
|
Just install [reHDDPrinter](https://git.mosad.xyz/localhorst/reHDDPrinter).
|
||||||
No further settings needed.
|
No further settings needed.
|
||||||
|
|
||||||
## Create Standalone with Debian 11
|
|
||||||
|
|
||||||
Instructions how to create a standalone machine that boots directly to reHDD. This is aimed for production use, like several drives a day shredding.
|
|
||||||
* Start reHDD after boot without login (as a tty1 shell)
|
|
||||||
* Start dmesg after boot without login (as a tty2 shell)
|
|
||||||
* Start htop after boot without login (as a tty3 shell)
|
|
||||||
* Upload reHDD log every 12h if wanted
|
|
||||||
|
|
||||||
### Software requirements
|
### Software requirements
|
||||||
* `apt-get install hwinfo smartmontools curl htop sudo`
|
* `zypper install hwinfo smartmontools curl htop sudo`
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
@ -56,7 +48,7 @@ git submodule update
|
|||||||
|
|
||||||
If you want to upload the logs, edit `scripts/reHDDLogUploader.bash` with your nextcloud token
|
If you want to upload the logs, edit `scripts/reHDDLogUploader.bash` with your nextcloud token
|
||||||
|
|
||||||
Add your system drive in `/root/reHDD/ignoreDrives.conf` like:
|
Add ignored drives in `/root/reHDD/ignoreDrives.conf` like:
|
||||||
```e102f49d```
|
```e102f49d```
|
||||||
Get the first 8 Bytes from your UUID via `blkid /dev/sdX`
|
Get the first 8 Bytes from your UUID via `blkid /dev/sdX`
|
||||||
|
|
||||||
|
|||||||
@ -226,10 +226,10 @@ void reHDD::ThreadShred(Drive *const pDrive)
|
|||||||
{
|
{
|
||||||
if (pDrive != nullptr)
|
if (pDrive != nullptr)
|
||||||
{
|
{
|
||||||
pDrive->setActionStartTimestamp(); // save timestamp at start of shredding
|
pDrive->setActionStartTimestamp(); // save timestamp at start of shredding
|
||||||
Shred *pShredTask = new Shred(); // create new shred task
|
Shred *pShredInstance = new Shred(); // create new shred task
|
||||||
pShredTask->shredDrive(pDrive, &fdShredInformPipe[1]); // start new shred task
|
pShredInstance->shredDrive(pDrive, &fdShredInformPipe[1]); // start new shred task
|
||||||
delete pShredTask; // delete shred task
|
delete pShredInstance; // delete shred task
|
||||||
ui->updateTUI(&listDrives, u16SelectedEntry);
|
ui->updateTUI(&listDrives, u16SelectedEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -382,7 +382,13 @@ void reHDD::filterIgnoredDrives(list<Drive> *plistDrives)
|
|||||||
list<Drive>::iterator it;
|
list<Drive>::iterator it;
|
||||||
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
||||||
{
|
{
|
||||||
if (it->getPath().find(systemDrivePath) != std::string::npos) // compare found system drive and current drive
|
string driveName = it->getPath();
|
||||||
|
// Remove /dev/ prefix
|
||||||
|
if (driveName.find("/dev/") == 0)
|
||||||
|
{
|
||||||
|
driveName = driveName.substr(5); // Skip "/dev/"
|
||||||
|
}
|
||||||
|
if (systemDrivePath.find(driveName) != std::string::npos) // compare found system drive and current drive
|
||||||
{
|
{
|
||||||
// system drive found --> ignore this drive
|
// system drive found --> ignore this drive
|
||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
@ -709,14 +715,23 @@ bool reHDD::getSystemDrive(string &systemDrive)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logger::logThis()->info(currentLine);
|
// Extract drive name from line (removing tree characters)
|
||||||
|
|
||||||
if ((cLine[0U] != '|') && (cLine[0U] != '`'))
|
if ((cLine[0U] != '|') && (cLine[0U] != '`'))
|
||||||
{
|
{
|
||||||
systemDrive = currentLine;
|
systemDrive = currentLine;
|
||||||
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '\n'), systemDrive.end()); // remove newline
|
|
||||||
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), ' '), systemDrive.end()); // remove spaces
|
// Find the actual drive name (after tree characters like └─, ├─)
|
||||||
// Logger::logThis()->info("Drive found: " + systemDrive);
|
size_t lastAlpha = 0;
|
||||||
|
for (size_t i = 0; i < systemDrive.length(); i++)
|
||||||
|
{
|
||||||
|
if (isalpha(systemDrive[i]))
|
||||||
|
{
|
||||||
|
lastAlpha = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
systemDrive = systemDrive.substr(lastAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentLine.ends_with(" /boot/efi\n"s))
|
if (currentLine.ends_with(" /boot/efi\n"s))
|
||||||
@ -739,5 +754,17 @@ bool reHDD::getSystemDrive(string &systemDrive)
|
|||||||
}
|
}
|
||||||
pclose(outputfileHwinfo);
|
pclose(outputfileHwinfo);
|
||||||
|
|
||||||
|
// Remove mountpoint (everything after first space)
|
||||||
|
size_t spacePos = systemDrive.find(' ');
|
||||||
|
if (spacePos != std::string::npos)
|
||||||
|
{
|
||||||
|
systemDrive = systemDrive.substr(0, spacePos);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove all unwanted characters
|
||||||
|
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '\n'), systemDrive.end());
|
||||||
|
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '/'), systemDrive.end());
|
||||||
|
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '\r'), systemDrive.end());
|
||||||
|
|
||||||
return systemDriveFound;
|
return systemDriveFound;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,12 +40,8 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
|||||||
drive->bWasShredStarted = true; // Mark drive as partly shredded
|
drive->bWasShredStarted = true; // Mark drive as partly shredded
|
||||||
|
|
||||||
#ifdef DRYRUN
|
#ifdef DRYRUN
|
||||||
for (int i = 0; i <= 500; i++)
|
for (int i = 0; i <= 100; i++)
|
||||||
{
|
{
|
||||||
if (drive->state.load() != Drive::TaskState::SHRED_ACTIVE)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
drive->setTaskPercentage(i + 0.05);
|
drive->setTaskPercentage(i + 0.05);
|
||||||
write(*ipSignalFd, "A", 1);
|
write(*ipSignalFd, "A", 1);
|
||||||
usleep(20000);
|
usleep(20000);
|
||||||
@ -204,9 +200,8 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
|||||||
Logger::logThis()->info("Shred-Task: Checksum zero: " + to_string(drive->u32DriveChecksumAfterShredding) + " - Drive: " + drive->getSerial());
|
Logger::logThis()->info("Shred-Task: Checksum zero: " + to_string(drive->u32DriveChecksumAfterShredding) + " - Drive: " + drive->getSerial());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((drive->state.load() == Drive::TaskState::SHRED_ACTIVE) || (drive->state.load() == Drive::TaskState::CHECK_SUCCESSFUL) || (drive->state == Drive::TaskState::CHECK_FAILED))
|
if ((drive->state.load() == Drive::TaskState::SHRED_ACTIVE) || (drive->state.load() == Drive::TaskState::CHECK_SUCCESSFUL) || (drive->state == Drive::TaskState::CHECK_FAILED))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user