PirateBox-Dev / PirateBoxScripts_Webserver

PirateBox Scriptcollection for running in Webserver
GNU General Public License v3.0
206 stars 102 forks source link

Fix /tmp/ folder empty #183

Closed sleepdefic1t closed 6 years ago

sleepdefic1t commented 6 years ago

Issue

/opt/piratebox/tmp/ folder is not emptied properly during installation.

Expected result

no errors empyting /opt/piratebox/tmp/ folder.

Error Thrown

rm: cannot remove '/opt/piratebox/tmp/': Is a directory

Reproduction

sudo ./install.sh

Suggested Fix

Change ln94 of piratebox/init.d/piratebox

from: find $PIRATEBOX/tmp/ -exec rm {} \;
to: find $PIRATEBOX/tmp/* -exec rm {} \;

Results after Suggested Fix

no errors emptying /opt/piratebox/tmp/ folder.


MaStr commented 6 years ago

Good catch, but I have a better one. The issue is that you want to exclude the top-level search folder. If you use the wildcard behind the /, you run into other issues because you are already selecting files with find.

the correct option is:

-mindepth 1

Example output without:

[matze@shrimpy www]$ find content/ | head
content/
content/css
content/css/page_style.css
content/css/jquery-ui.min.css
content/css/.page_style.css.swp
content/favicon.ico
content/img
content/img/menu.png
content/img/piratebox-logo-horizontal-white.png
content/img/piratebox-logo-small.png

With

[matze@shrimpy www]$ find content/ -mindepth 1 | head
content/css
content/css/page_style.css
content/css/jquery-ui.min.css
content/css/.page_style.css.swp
content/favicon.ico
content/img
content/img/menu.png
content/img/piratebox-logo-horizontal-white.png
content/img/piratebox-logo-small.png
content/index.html

The corect branch of the pull-request is against hotfix-1.1.4 branch or development. :-)

Will you provide a different patch?

Thank you, best regards Matthias

sleepdefic1t commented 6 years ago

Sorry for the delay replaying back.

I got it to empty using:

find /opt/piratebox/tmp/ -mindepth 1 -delete -exec rm -rf {} \;

But box services would not start after next boot.

Then I tried commenting out the line altogether, and everything ran as expected.

If it's there, I assume it's for a good reason. So I suppose I should start by asking what the reasoning is behind emptying the /temp folder?

Thank you again for your help!

MaStr commented 6 years ago

Sorry for my late respones:

So I suppose I should start by asking what the reasoning is behind emptying the /temp folder?

We want to remove logfiles regularly. We also want to remove traces where you might find an IP address as well.

sleepdefic1t commented 6 years ago

@MaStr No worries! Thank you!

That totally makes sense. I figured asking would be better than just assuming!


PB-Rpi Zero W UART to ESP8266 in mesh-mode 👍

image uploaded from ios

So many awesome things can be done!

Thank you again for the help, and for continuing dev on PB!!

MaStr commented 6 years ago

Fixed with e4fc86c