Compare commits
17 Commits
b0.2.0
...
8c54e0e7d9
Author | SHA1 | Date | |
---|---|---|---|
8c54e0e7d9 | |||
46a2de7bc4 | |||
af38d60982 | |||
25d8ca6920 | |||
52f5597ba9 | |||
9b9806b5c2 | |||
1e455bde02 | |||
8034ac496b | |||
354ee04e73 | |||
84e42a430b | |||
77c7849484 | |||
f2db85aa33 | |||
c942f36e49 | |||
068413c15d | |||
45a5cb303b | |||
7748d49b54 | |||
3cd6baed36 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -42,3 +42,6 @@
|
|||||||
reHDD
|
reHDD
|
||||||
|
|
||||||
reHDD.log
|
reHDD.log
|
||||||
|
|
||||||
|
|
||||||
|
ignoreDrives.conf
|
||||||
|
36
README.md
36
README.md
@ -14,28 +14,24 @@
|
|||||||
* clone repo
|
* clone repo
|
||||||
* make release
|
* make release
|
||||||
|
|
||||||
## Create Standalone with Debian
|
## 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.
|
Instructions how to create a standalone machine that boots directly to reHDD. This is aimed for production use, like several drives a day shredding.
|
||||||
|
|
||||||
### Software requirements
|
### Software requirements
|
||||||
|
|
||||||
* apt-get install hwinfo
|
* apt-get install hwinfo smartmontools curl
|
||||||
* wget http://ftp.de.debian.org/debian/pool/main/s/smartmontools/smartmontools_7.1-1_amd64.deb
|
|
||||||
* dpkg --install smartmontools_7.1-1_amd64.deb
|
|
||||||
|
|
||||||
### Start reHDD after boot without login (as a tty shell)
|
### Start reHDD after boot without login (as a tty shell)
|
||||||
|
|
||||||
nano /etc/systemd/system/reHDD.service
|
nano /lib/systemd/system/getty@.service
|
||||||
```
|
|
||||||
[Unit]
|
|
||||||
Description=Custom user interface on tty1
|
|
||||||
Conflicts=getty@tty1.service
|
|
||||||
Before=getty.target
|
|
||||||
|
|
||||||
|
and replace the [Service] with this:
|
||||||
|
```
|
||||||
[Service]
|
[Service]
|
||||||
WorkingDirectory=/root/reHDD
|
WorkingDirectory=/root/reHDD
|
||||||
ExecStart=/root/reHDD/reHDD
|
ExecStart=
|
||||||
|
ExecStart=-/root/reHDD/reHDD
|
||||||
StandardInput=tty
|
StandardInput=tty
|
||||||
StandardOutput=tty
|
StandardOutput=tty
|
||||||
Restart=always
|
Restart=always
|
||||||
@ -47,10 +43,10 @@ TTYVHangup=yes
|
|||||||
TTYVTDisallocate=yes
|
TTYVTDisallocate=yes
|
||||||
SendSIGHUP=yes
|
SendSIGHUP=yes
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
nano /etc/systemd/system/reHDDSettings.service
|
nano /etc/systemd/system/reHDDSettings.service
|
||||||
```
|
```
|
||||||
[Service]
|
[Service]
|
||||||
@ -66,14 +62,18 @@ nano /root/reHDDSettings.sh
|
|||||||
```
|
```
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
dmesg -n 1 #disable overlay if a drive is attached/detached
|
dmesg -n 1 #disable overlay if a drive is attached/detached
|
||||||
|
# remove comment for the following to activate log telemetie
|
||||||
|
# curl -k -T /root/reHDD/reHDD.log -u "fgggfffgfgfgfg:" -H 'X-Requested-With: XMLHttpRequest' https://schuttercloud.com/public.php/webdav/`echo $(date '+%Y-%m-%d_%H-%M')`_reHDD.log
|
||||||
rm -f /root/reHDD/reHDD.log
|
rm -f /root/reHDD/reHDD.log
|
||||||
```
|
```
|
||||||
Make sure the binary reHDD is in /root/reHDD/
|
chmod +x reHDDSettings.sh
|
||||||
Add your system drive in /root/reHDD/ignoreDrives.conf like:
|
|
||||||
``` /dev/sdX:e102f49d-5ed5-462b-94c5-ef66a4345671```
|
|
||||||
Get your UUID via blkid /dev/sdX
|
|
||||||
|
|
||||||
systemctl enable reHDD.service
|
|
||||||
|
Make sure the binary reHDD is in /root/reHDD/
|
||||||
|
|
||||||
|
Add your system drive in /root/reHDD/ignoreDrives.conf like:
|
||||||
|
```e102f49d-5ed5-462b-94c5-ef66a4345671```
|
||||||
|
Get your UUID via blkid /dev/sdX
|
||||||
|
|
||||||
systemctl enable reHDDSettings.service
|
systemctl enable reHDDSettings.service
|
||||||
|
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
/dev/sdc:4673974d-1af2-44fd-996b-a2d8e4c43d9a
|
4673974d-1af2-44fd-996b-a2d8e4c43d9a
|
||||||
/dev/sda:508ef27d-5039-4e8b-9e2c-22d7528b7149
|
2cb3dea4-9649-4d4a-935c-a0e5c08bad64
|
||||||
/dev/sdb:32b66944-ffa0-40e9-817c-3f0c52eefaf4
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#ifndef REHDD_H_
|
#ifndef REHDD_H_
|
||||||
#define REHDD_H_
|
#define REHDD_H_
|
||||||
|
|
||||||
#define REHDD_VERSION "bV0.2.0"
|
#define REHDD_VERSION "bV0.2.1"
|
||||||
|
|
||||||
// Drive handling Settings
|
// Drive handling Settings
|
||||||
#define WORSE_HOURS 19200 //mark drive if at this limit or beyond
|
#define WORSE_HOURS 19200 //mark drive if at this limit or beyond
|
||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
// Logger Settings
|
// Logger Settings
|
||||||
#define LOG_PATH "./reHDD.log"
|
#define LOG_PATH "./reHDD.log"
|
||||||
#define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2020"
|
#define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2022"
|
||||||
#define DEVICE_ID "generic"
|
#define DEVICE_ID "generic"
|
||||||
#define SOFTWARE_VERSION "alpha"
|
#define SOFTWARE_VERSION "alpha"
|
||||||
#define HARDWARE_VERSION "generic"
|
#define HARDWARE_VERSION "generic"
|
||||||
|
@ -38,5 +38,5 @@ void Delete::deleteDrive(Drive* drive)
|
|||||||
{
|
{
|
||||||
//wipefs running
|
//wipefs running
|
||||||
}
|
}
|
||||||
fclose(deleteCmdOutput);
|
pclose(deleteCmdOutput);
|
||||||
}
|
}
|
||||||
|
@ -48,17 +48,17 @@ uint32_t Drive::getPowerCycles(void)
|
|||||||
|
|
||||||
string Drive::sCapacityToText()
|
string Drive::sCapacityToText()
|
||||||
{
|
{
|
||||||
if(getCapacity() <= (999*1000000000UL))
|
char acBuffer[16];
|
||||||
{
|
double dSize = (double) getCapacity();
|
||||||
// Less or even 999 GB --> GB
|
uint16_t u16UnitIndex = 0;
|
||||||
return to_string(getCapacity() / 1000000000UL) + " GB";
|
const char* units[] = {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
|
||||||
|
while (dSize >= 1000) { //using the marketing capacity
|
||||||
|
dSize /= 1000;
|
||||||
|
u16UnitIndex++;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
sprintf(acBuffer, "%.*f %s", u16UnitIndex-3, dSize, units[u16UnitIndex]);
|
||||||
// More 999 GB --> TB
|
return acBuffer;
|
||||||
return to_string(getCapacity() / 1000000000000UL) + " TB";
|
|
||||||
}
|
|
||||||
return "ERROR";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string Drive::sErrorCountToText()
|
string Drive::sErrorCountToText()
|
||||||
|
@ -289,30 +289,30 @@ void reHDD::filterNewDrives(list <Drive>* plistOldDrives, list <Drive>* plistNew
|
|||||||
*/
|
*/
|
||||||
void reHDD::searchDrives(list <Drive>* plistDrives)
|
void reHDD::searchDrives(list <Drive>* plistDrives)
|
||||||
{
|
{
|
||||||
// cout << "search drives ..." << endl;
|
|
||||||
Logger::logThis()->info("--> search drives <--");
|
Logger::logThis()->info("--> search drives <--");
|
||||||
char * cLine = NULL;
|
char * cLine = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
FILE* outputfileHwinfo = popen("ls -1 /dev/sd*", "r");
|
FILE* outputfileHwinfo = popen("lsblk -I 8 -d -o NAME", "r");
|
||||||
|
|
||||||
if (outputfileHwinfo == NULL)
|
if (outputfileHwinfo == NULL)
|
||||||
{
|
{
|
||||||
Logger::logThis()->error("Unable to scann attached drives");
|
Logger::logThis()->error("Unable to scan attached drives");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((getline(&cLine, &len, outputfileHwinfo)) != -1)
|
while ((getline(&cLine, &len, outputfileHwinfo)) != -1)
|
||||||
{
|
{
|
||||||
if (string(cLine).length() == 9)
|
if (string(cLine).length() == 4)
|
||||||
{
|
{
|
||||||
Drive* tmpDrive = new Drive(string(cLine).substr(0, 8));
|
Drive* tmpDrive = new Drive("/dev/" + string(cLine).substr(0, 3));
|
||||||
tmpDrive->state = Drive::NONE;
|
tmpDrive->state = Drive::NONE;
|
||||||
tmpDrive->bIsOffline = false;
|
tmpDrive->bIsOffline = false;
|
||||||
plistDrives->push_back(*tmpDrive);
|
plistDrives->push_back(*tmpDrive);
|
||||||
|
//Logger::logThis()->info("drive found: " + tmpDrive->getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(outputfileHwinfo);
|
pclose(outputfileHwinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -322,29 +322,13 @@ void reHDD::searchDrives(list <Drive>* plistDrives)
|
|||||||
*/
|
*/
|
||||||
void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
|
void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
|
||||||
{
|
{
|
||||||
string sDelimiter = ":";
|
list<tuple<string>> vtlIgnoredDevices; //store drives from ingnore file
|
||||||
string sIgnoredDrivePath;
|
|
||||||
string sIgnoredDriveUUID;
|
|
||||||
|
|
||||||
list<tuple<string, string>> vtlIgnoredDevices; //store drives from ingnore file
|
|
||||||
|
|
||||||
ifstream input( "ignoreDrives.conf" ); //read ingnore file
|
ifstream input( "ignoreDrives.conf" ); //read ingnore file
|
||||||
|
|
||||||
for(string sLine; getline( input, sLine );)
|
for(string sLine; getline( input, sLine );)
|
||||||
{
|
{
|
||||||
if (string(sLine).find("/dev/sd") != string::npos)
|
Logger::logThis()->info("read uuid: " + sLine);
|
||||||
{
|
vtlIgnoredDevices.emplace_back(sLine); //add found path and uuid from ignore file to vector
|
||||||
size_t pos = 0;
|
|
||||||
string token;
|
|
||||||
while ((pos = sLine.find(sDelimiter)) != string::npos)
|
|
||||||
{
|
|
||||||
token = sLine.substr(0, pos);
|
|
||||||
sIgnoredDrivePath = token;
|
|
||||||
sLine.erase(0, pos + sDelimiter.length());
|
|
||||||
sIgnoredDriveUUID = sLine;
|
|
||||||
} //end while
|
|
||||||
vtlIgnoredDevices.emplace_back(sIgnoredDrivePath, sIgnoredDriveUUID); //add found path and uuid from ingnore file to vector
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//loop through found entries in ingnore file
|
//loop through found entries in ingnore file
|
||||||
for(auto row : vtlIgnoredDevices)
|
for(auto row : vtlIgnoredDevices)
|
||||||
@ -353,8 +337,6 @@ void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
|
|||||||
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
||||||
{
|
{
|
||||||
string sUUID;
|
string sUUID;
|
||||||
if (!get<0>(row).compare(it->getPath())) //find same drive based on path
|
|
||||||
{
|
|
||||||
char * cLine = NULL;
|
char * cLine = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
string sCMD = "blkid ";
|
string sCMD = "blkid ";
|
||||||
@ -377,16 +359,10 @@ void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
|
|||||||
//cout << "blkid uuid:" << sUUID << endl;
|
//cout << "blkid uuid:" << sUUID << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(outputfileBlkid);
|
pclose(outputfileBlkid);
|
||||||
//cout << "blkid uuid:" << sUUID << endl;
|
//cout << "blkid uuid:" << sUUID << endl;
|
||||||
|
|
||||||
if (get<1>(row).compare(sUUID)) //compare uuid from ignore file and uuid from drive
|
if (!get<0>(row).compare(sUUID)) //compare uuid from ignore file and uuid from drive
|
||||||
{
|
|
||||||
cout << "[ERROR] different uuid found than in ignore file:" << it->getPath() << endl;
|
|
||||||
Logger::logThis()->error("[ERROR] different uuid found than in ignore file: " + it->getPath());
|
|
||||||
exit(EXIT_FAILURE); // exit to prevent accidentally shred a system drive
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// same uuid found than in ignore file --> ignore this drive
|
// same uuid found than in ignore file --> ignore this drive
|
||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
@ -398,7 +374,6 @@ void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief print drives with all information
|
* \brief print drives with all information
|
||||||
|
@ -51,7 +51,7 @@ void SMART::readSMARTData(Drive* drive)
|
|||||||
SMART::parsePowerOnHours(sLine);
|
SMART::parsePowerOnHours(sLine);
|
||||||
SMART::parsePowerCycle(sLine);
|
SMART::parsePowerCycle(sLine);
|
||||||
}
|
}
|
||||||
fclose(outputfileSmart);
|
pclose(outputfileSmart);
|
||||||
drive->setDriveSMARTData(modelFamily, modelName, serial, capacity, errorCount, powerOnHours, powerCycle); //wirte data in drive
|
drive->setDriveSMARTData(modelFamily, modelName, serial, capacity, errorCount, powerOnHours, powerCycle); //wirte data in drive
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user