Request a file explorer via web

Suggestions for features and software you would like to see in DietPi, goes here.
Post Reply
xgrogx
Posts: 4
Joined: Mon Mar 01, 2021 11:58 am

Request a file explorer via web

Post by xgrogx »

I have dietpi into a x86 pc and its awesome!
I have three hdd connected in SATA and a posibility to copy files is through ssh with Midnight Commander (mc) I think that this is more quickly than make it thrugh in samba., another posibility is make it with a web broser like https://filebrowser.org or another similar.
The installation is curl -fsSL https://filebrowser.org/get.sh | bash and it run with filebrowser -r /path/to/your/files and making some configurations like the port or the ip with filebrowser config set [flags]but I don´t know how to do it like a service in dietpi.
User avatar
WarHawk
Posts: 773
Joined: Thu Jul 20, 2017 8:55 am

Re: Request a file explorer via web

Post by WarHawk »

Ok...got it working...but it was a booger!

daemonize wouldn't work (it would start the program but wouldn't pass on the arguments from the config file I had created)...so I had to build a simple systemctl service file
using this https://www.howtogeek.com/687970/how-to ... h-systemd/
I created a file in /etc/systemd/system called filebrowser.service

Code: Select all

[Unit]
Description=filebrowser service start

Wants=network.target
After=syslog.target network-online.target

[Service]
Type=simple
Environment="SCRIPT_ARGS= -a 192.168.0.100 -p 8888 -r /mnt/dietpi_userdata"
ExecStart=/usr/local/bin/filebrowser $SCRIPT_ARGS
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target
I had to create the Environment line to pass the correct script arguments to the filebrower command
then followed the howto in the above howtogeek link to test and ensure the service was working

Now seeing

Code: Select all

root@M-340C:/etc/systemd/system# service filebrowser status
● filebrowser.service - filebrowser service start
   Loaded: loaded (/etc/systemd/system/filebrowser.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2021-03-02 02:05:32 CST; 4min 46s ago
 Main PID: 30416 (filebrowser)
    Tasks: 10 (limit: 4915)
   Memory: 10.0M
   CGroup: /system.slice/filebrowser.service
           └─30416 /usr/local/bin/filebrowser -a 192.168.0.100 -p 8888 -r /mnt/dietpi_userdata

Mar 02 02:05:32 M-340C systemd[1]: filebrowser.service: Main process exited, code=exited, status=1/FAILURE
Mar 02 02:05:32 M-340C systemd[1]: filebrowser.service: Failed with result 'exit-code'.
Mar 02 02:05:32 M-340C systemd[1]: Stopped filebrowser service start.
Mar 02 02:05:32 M-340C systemd[1]: Started filebrowser service start.
Mar 02 02:05:32 M-340C filebrowser[30416]: 2021/03/02 02:05:32 No config file used
Mar 02 02:05:32 M-340C filebrowser[30416]: 2021/03/02 02:05:32 Listening on 192.168.0.100:8888
Mar 02 02:05:47 M-340C filebrowser[30416]: 2021/03/02 02:05:47 /api/renew: 403 192.168.0.10 <nil>
And I get access to the filebrowser website on port 8888, default username/password is admin
User avatar
WarHawk
Posts: 773
Joined: Thu Jul 20, 2017 8:55 am

Re: Request a file explorer via web

Post by WarHawk »

I did find a webgui MC commander called cloud commander that might be useful

I had to play around with it some to get it working
https://www.tecmint.com/cloud-commander ... for-linux/

I installed the version 14 of nodesource (don't use lower versions, they are outdated and depreciated)

Code: Select all

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Then installed cloudcmd as sudo

Code: Select all

sudo npm i cloudcmd -g --force
Then ran the program

Code: Select all

$ cloudcmd
Came up on port 8000

Edited for brevity of course
cloudcommander.jpg
xgrogx
Posts: 4
Joined: Mon Mar 01, 2021 11:58 am

Re: Request a file explorer via web

Post by xgrogx »

Hi!

The first solution work well but when I reboot it doesn´t work (it´s a security feature :lol: ) I need to restart the service with

Code: Select all

 systemctl restart filebrowser
and the second solution with cloud commander I have this error

Code: Select all

root@DietPi:~# cloudcmd
/usr/local/lib/node_modules/cloudcmd/bin/cloudcmd.mjs:5
import {createRequire} from 'module';
       ^

SyntaxError: Unexpected token {
    at Module._compile (internal/modules/cjs/loader.js:760:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
    at internal/main/run_main_module.js:21:11
User avatar
Joulinar
Posts: 5619
Joined: Sat Nov 16, 2019 12:49 am

Re: Request a file explorer via web

Post by Joulinar »

did you set systemctl enable filebrowser to have the service started during boot?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
xgrogx
Posts: 4
Joined: Mon Mar 01, 2021 11:58 am

Re: Request a file explorer via web

Post by xgrogx »

No, because I'm a bit noob with linux.

Now it works, thanks a lot
User avatar
WarHawk
Posts: 773
Joined: Thu Jul 20, 2017 8:55 am

Re: Request a file explorer via web

Post by WarHawk »

xgrogx wrote: Tue Mar 02, 2021 1:00 pm Hi!

The first solution work well but when I reboot it doesn´t work (it´s a security feature :lol: ) I need to restart the service with

Code: Select all

 systemctl restart filebrowser
and the second solution with cloud commander I have this error

Code: Select all

root@DietPi:~# cloudcmd
/usr/local/lib/node_modules/cloudcmd/bin/cloudcmd.mjs:5
import {createRequire} from 'module';
       ^

SyntaxError: Unexpected token {
    at Module._compile (internal/modules/cjs/loader.js:760:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
    at internal/main/run_main_module.js:21:11
I got the same error on mine...I did a bit of fiddling with it to get it to work...
I also ran cloudcmd as a user rather than root...not sure if that helps
Post Reply