miniserve

Hello, I want to share in a very easy way, files on my local network by using http. I have installed miniserve, but I can not find any documentation of how to use it.
 
What a neat little find. Only minor issued fixed from 0.20->0.21->0.22 so the 0.20 should work ok till it's brought current by port maintainer.

Looks to be a quick way to pull things around the house/lab from computer to computer on an ad-hock basis. Point it a a directory on the "server", pull the file, Ctrl-C and it's off.
 
It works awesome but its there any way to make it permanent? I mean to auto start when computer starts? Like in rc.conf or something like that?
 
You can create an rc.d script which daemonizes any executable. This would allow for the service to be auto-started as well as being automatically being restarted if it crashes.

I left a few notes regarding that in my blog a while ago: https://blog.insane.engineer/post/freebsd_daemonize

Code:
#!/bin/sh
# PROVIDE: miniserver
# REQUIRE: networking
# KEYWORD:

. /etc/rc.subr

name="miniserve"
rcvar="miniserve_enable"
miniserve_user="miniserve"
miniserve_command="/usr/local/bin/miniserve"
pidfile="/var/run/miniserve/${name}.pid"
command="/usr/sbin/miniserve"
command_args="-P ${pidfile} -r -f ${miniserve_command}"

load_rc_config $name
: ${miniserve_enable:=no}

run_rc_command "$1"

I just made it like this, its ok or it needs some corrections?
 
Also, could it be set in crontab? As for example:
Sure, that might work too.
Usually, rc.d would be the preferred option here as the OS then "knows" about the service. You can ask it to start it, to stop it, you can query the status, PID and so on.
Furthermore, you get control over when the service is being started. For example, you can ensure that your miniserve service is not started before networking is up & running etc.
 
Sure, that might work too.
Usually, rc.d would be the preferred option here as the OS then "knows" about the service. You can ask it to start it, to stop it, you can query the status, PID and so on.
Furthermore, you get control over when the service is being started. For example, you can ensure that your miniserve service is not started before networking is up & running etc.
Thanks but I do not know if I wrote the script ok or not
 
And I have another question, can I set for example the .exe files to direct execute from the server instead of download it? Because if I click on it right now it download the file only.
 
Thanks but I do not know if I wrote the script ok or not
I'm no rc.d expert. I'd argue, if this is your first rodeo, the question would be: does it do what you want?

And I have another question, can I set for example the .exe files to direct execute from the server instead of download it? Because if I click on it right now it download the file only.
I haven't really looked at miniserve but as far as I can tell it's a simple HTTP server. Therefore, any file being served is just that: A file being served over an HTTP response.
Executing a binary on the host would require something like CGI or RPC. That's a whole different beast/story. At that point you might be better of using something like www/nginx or similar. But neither CGI nor RPC will just magically work. In case of CGI, your binary needs to have a CGI interface.
As far as I can tell, miniserve's purpose is to share files. Nothing more, nothing less.
 
Top