Jail vs Virtualisation which is better

gwaitsi

Patron
Joined
May 18, 2020
Messages
243
Which is better, a Jail or Virtualisation.

I want to install WeeWX (weather station) but there seem no pre-built jail (plugin) for it. I see someone runs it in a virtual machine.
Same for ZoneMinder. No ones seems to be updating the Jail.

I was thinking the alternative was to use a virtual linux machine, where there are pre-built builds for these tools.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,702
Generally speaking, it's better to use jails when you can as they require less resources from the host (or only as many as actually used, rather than a reserved amount for the whole VM even if under-utilised).

It's also simpler to share/mount your storage into the jail than it is to do NFS to a VM.

The Zoneminder plugin is maintained and this thread is an ongoing discussion about the best way to use it and keep it up to date:

I don't know anything about WeeWX, but if it can be made to run in a jail, that would be a better thing. If that's not possible (technically or in terms of your own skills), then a VM is an option.

A quick look here: https://github.com/weewx/weewx indicates that it may well be OK to run in a jail. (hint: there's a startup script for FreeBSD: https://github.com/weewx/weewx/blob/master/util/init.d/weewx.bsd)
 
Last edited:

gwaitsi

Patron
Joined
May 18, 2020
Messages
243
zoneminder is already 1.34.22
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,464
no pre-built jail (plugin) for it.
There's a whole lot of software that runs on FreeBSD, and doesn't have a FreeNAS/TrueNAS plugin for it.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,702
zoneminder is already 1.34.22
Did you even look at the thread I linked you to? the last post there describes the process to update to 1.34.21 (and probably .22 by now if the pkg is updated)
 

gwaitsi

Patron
Joined
May 18, 2020
Messages
243
Did you even look at the thread I linked you to? the last post there describes the process to update to 1.34.21 (and probably .22 by now if the pkg is updated)
i need indeed and it did upgrade to 21 thanks. still would like someone to create a plugin for weewx, i have no idea where to begin
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,464

drinking12many

Contributor
Joined
Apr 8, 2012
Messages
148
Its also possible that there isn't a FreeBSD port of WeeWX, depending on what it needs it may not be hard to move over or it could be a complete pain..just depends.

I know for me at least depending on the use case and whats already out there I have a CENTOS VM running on my freenas that runs rancher/docker not always the best use of resources but for a lot of things docker is just better supported and can take minutes to get up and running vs a jail. For example I never could get zoneminder to run quite right in a jail so I put it in a docker container never had a major issue since getting it running/updated and then used an NFS mount on my Freenas that Zonemineder uses for its storage.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,464
Its also possible that there isn't a FreeBSD port of WeeWX
I'm not aware of a port, but it's pure Python--it should be straightforward enough. Though it looks like some of the Python modules would need to be built from ports--they don't seem to be available as binary packages.

Looks like there's a four-year-old ticket to add a new port for weewx, though:
 
Last edited:

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,702

gwaitsi

Patron
Joined
May 18, 2020
Messages
243
i got it working in the jail and the startup script works if i run service weewx start, the problem i have;
- weewx doens't start on boot (i have to run it from a shell)
- ntpd / ntpdate don't run on boot (same as weewx) even though they are standard components
oddly enough nginx does start at boot and was installed as a package
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
i got it working in the jail and the startup script works if i run service weewx start, the problem i have;
- weewx doens't start on boot (i have to run it from a shell)
- ntpd / ntpdate don't run on boot (same as weewx) even though they are standard components
oddly enough nginx does start at boot and was installed as a package

You have to look at the service script for weewx inside the jail in /usr/local/etc/rc.d. It's probably looking for an rc option like weewx_enable="YES" in /etc/rc.conf.local. (The jail inherits time from the host, so ntpd/ntpdate don't need to run.) Once the rc option exists, the service will start on boot.
 

gwaitsi

Patron
Joined
May 18, 2020
Messages
243
here are the settings in /etc/rc.conf
weewx_enable="YES"
nginx_enable="YES"

both nginx and weewx exist in /usr/local/etc/rc.d/ (nginx works)
the script is weewx - maybe you can see something wrong with it? it does work manually though

thanks

Code:
#!/bin/sh
# Start script for FreeBSD, contributed by user Fabian Abplanalp
# Put this script in /usr/local/etc/rc.d then adjust WEEWX_BIN and
# WEEWX_CFG values in /etc/defaults/weewx

WEEWX_BIN="/usr/local/share/weewx/bin/weewxd"
WEEWX_CFG="/usr/local/share/weewx/weewx.conf"
WEEWX_PID="/var/run/weewx.pid"

# Read configuration variable file if it is present
# [ -r /etc/defaults/weewx ] && . /etc/defaults/weewx

case "$1" in
  "start")
    echo "Starting weewx..."
    ${WEEWX_BIN} ${WEEWX_CFG} --daemon &
    echo $! > ${WEEWX_PID}
    echo "done"
  ;;

  "stop")
    echo "Stopping weewx..."
    if [ -f ${WEEWX_PID} ] ; then
      kill `cat ${WEEWX_PID}`
      rm ${WEEWX_PID}
      echo "done"
    else
      echo "not running?"
    fi
  ;;

  "restart")
    echo "Restarting weewx..."
    $0 stop
    sleep 2
    $0 start
  ;;

  *)
    echo "$0 [start|stop|restart]"
  ;;

esac
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Is the weewx script executable? What does ls -l /usr/local/etc/rc.d/weewx show?
 

gwaitsi

Patron
Joined
May 18, 2020
Messages
243
Is the weewx script executable? What does ls -l /usr/local/etc/rc.d/weewx show?


root@weewx:~ # ls -l /usr/local/etc/rc.d/weewx-rwxr-xr-x 1 root wheel 888 Jan 29 23:30 /usr/local/etc/rc.d/weewx
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
I had to look at several start scripts on my system, but that weewx script is for Linux, not FreeBSD. Try something like this instead:

Code:
#!/bin/sh
#
# PROVIDE: weewx
# KEYWORD: shutdown
#
# Add the following to /etc/rc.conf[.local] to enable this service
#
# weewx_enable="YES"
#

. /etc/rc.subr

: ${weewx_enable="NO"}

name=weewx
rcvar="weewx_enable"

weewx_bin=/usr/local/share/weewx/bin/weewxd
weewx_cfg=/usr/local/share/weewx/weewx.conf
weewx_pid=/var/run/weewx.pid
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
start_cmd="weewx_start"
stop_cmd=weewx_stop

weewx_start()
{
        if ! checkyesno weewx_enable ; then
                return 0
        fi

        echo "Starting ${name}..."

        ${weewx_bin} ${weewx_cfg} --daemon &
    echo $! > ${weewx_pid}
}

weewx_stop()
{
    if [ -f ${weewx_pid} ] ; then
        echo "Stopping ${name}..."
        kill `cat ${weewx_pid}`
        rm ${weewx_pid}
    fi
}

load_rc_config ${name}
run_rc_command "$1"


And set weewx_enable="YES" in /etc/rc.conf.local in the jail.
 

gwaitsi

Patron
Joined
May 18, 2020
Messages
243
I had to look at several start scripts on my system, but that weewx script is for Linux, not FreeBSD. Try something like this instead:

Code:
#!/bin/sh
#
# PROVIDE: weewx
# KEYWORD: shutdown
#
# Add the following to /etc/rc.conf[.local] to enable this service
#
# weewx_enable="YES"
#

. /etc/rc.subr

: ${weewx_enable="NO"}

name=weewx
rcvar="weewx_enable"

weewx_bin=/usr/local/share/weewx/bin/weewxd
weewx_cfg=/usr/local/share/weewx/weewx.conf
weewx_pid=/var/run/weewx.pid
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
start_cmd="weewx_start"
stop_cmd=weewx_stop

weewx_start()
{
        if ! checkyesno weewx_enable ; then
                return 0
        fi

        echo "Starting ${name}..."

        ${weewx_bin} ${weewx_cfg} --daemon &
    echo $! > ${weewx_pid}
}

weewx_stop()
{
    if [ -f ${weewx_pid} ] ; then
        echo "Stopping ${name}..."
        kill `cat ${weewx_pid}`
        rm ${weewx_pid}
    fi
}

load_rc_config ${name}
run_rc_command "$1"


And set weewx_enable="YES" in /etc/rc.conf.local in the jail.

i suspected something like that. thanks for taking the time for me.
The script works to start and stop the service from the shell, but same thing...not from boot.
The rc.d debug shows, but i don't see it picking up weewx. i tried in both rc.conf and rc.conf.local (but NGINX works)
I also tried your script with # REQUIRE: networking because weewx is a tcp listener

Code:
Jan 30 07:32:27 weewx newsyslog[44851]: logfile first created
Jan 30 07:32:27 weewx syslogd: kernel boot file is /boot/kernel/kernel
Jan 30 07:32:27 weewx root[44865]: /etc/rc: DEBUG: checkyesno: rpcbind_enable is set to NO.
Jan 30 07:32:27 weewx root[44867]: /etc/rc: DEBUG: checkyesno: ipmon_enable is set to NO.
Jan 30 07:32:27 weewx root[44869]: /etc/rc: DEBUG: set_rcvar_obsolete: $kerberos5_server_enable(old) -> $kdc_enable(new) is defined
Jan 30 07:32:27 weewx root[44870]: /etc/rc: DEBUG: set_rcvar_obsolete: $kerberos5_server(old) -> $kdc_program(new) is defined
Jan 30 07:32:27 weewx root[44871]: /etc/rc: DEBUG: set_rcvar_obsolete: $kerberos5_server_flags(old) -> $kdc_flags(new) is defined
Jan 30 07:32:27 weewx root[44872]: /etc/rc: DEBUG: checkyesno: kdc_enable is set to NO.
Jan 30 07:32:27 weewx root[44879]: /etc/rc: DEBUG: run_rc_command: start_precmd: [ -n "${_mdconfig2_list}" ]
Jan 30 07:32:27 weewx root[44882]: /etc/rc: DEBUG: run_rc_command: doit: nisdomain_start
Jan 30 07:32:27 weewx root[44884]: /etc/rc: DEBUG: checkyesno: nis_server_enable is set to NO.
Jan 30 07:32:27 weewx root[44886]: /etc/rc: DEBUG: checkyesno: nis_client_enable is set to NO.
Jan 30 07:32:27 weewx root[44888]: /etc/rc: DEBUG: checkyesno: nis_ypset_enable is set to NO.
Jan 30 07:32:27 weewx root[44893]: /etc/rc: DEBUG: run_rc_command: doit: cleartmp_start
Jan 30 07:32:27 weewx root[44894]: /etc/rc: DEBUG: checkyesno: clear_tmp_enable is set to NO.
Jan 30 07:32:27 weewx root[44895]: /etc/rc: DEBUG: checkyesno: clear_tmp_X is set to YES.
Jan 30 07:32:27 weewx root[44896]: /etc/rc: DEBUG: checkyesno: rc_startmsgs is set to YES.
Jan 30 07:32:27 weewx root[44898]: /etc/rc: DEBUG: checkyesno: clear_tmp_X is set to YES.
Jan 30 07:32:27 weewx root[44901]: /etc/rc: DEBUG: checkyesno: keyserv_enable is set to NO.
Jan 30 07:32:27 weewx root[44903]: /etc/rc: DEBUG: run_rc_command: doit: pwcheck_start
Jan 30 07:32:27 weewx root[44905]: /etc/rc: DEBUG: checkyesno: virecover_enable is set to YES.
Jan 30 07:32:27 weewx root[44906]: /etc/rc: DEBUG: run_rc_command: doit: virecover_start
Jan 30 07:32:27 weewx root[44909]: /etc/rc: DEBUG: checkyesno: nis_ypldap_enable is set to NO.
Jan 30 07:32:27 weewx root[44912]: /etc/rc: DEBUG: run_rc_command: doit: local_start
Jan 30 07:32:27 weewx root[44914]: /etc/rc: DEBUG: checkyesno: lpd_enable is set to NO.
Jan 30 07:32:27 weewx root[44916]: /etc/rc: DEBUG: checkyesno: update_motd is set to YES.
Jan 30 07:32:27 weewx root[44917]: /etc/rc: DEBUG: run_rc_command: doit: motd_start
Jan 30 07:32:27 weewx root[44918]: /etc/rc: DEBUG: checkyesno: rc_startmsgs is set to YES.
Jan 30 07:32:27 weewx root[44925]: /etc/rc: DEBUG: checkyesno: rc_startmsgs is set to YES.
Jan 30 07:32:27 weewx root[44933]: /etc/rc: DEBUG: checkyesno: nscd_enable is set to NO.
Jan 30 07:32:27 weewx root[44935]: /etc/rc: DEBUG: run_rc_command: doit: osrelease_start
Jan 30 07:32:27 weewx root[44936]: /etc/rc: DEBUG: checkyesno: rc_startmsgs is set to YES.
Jan 30 07:32:27 weewx root[44942]: /etc/rc: DEBUG: checkyesno: rc_startmsgs is set to YES.
Jan 30 07:32:27 weewx root[44944]: /etc/rc: DEBUG: checkyesno: rarpd_enable is set to NO.
Jan 30 07:32:27 weewx root[44946]: /etc/rc: DEBUG: checkyesno: rtadvd_enable is set to NO.
Jan 30 07:32:27 weewx root[44948]: /etc/rc: DEBUG: checkyesno: rwhod_enable is set to NO.
Jan 30 07:32:27 weewx root[44950]: /etc/rc: DEBUG: run_rc_command: doit: utx boot
Jan 30 07:32:27 weewx root[44953]: /etc/rc: DEBUG: checkyesno: nis_yppasswdd_enable is set to NO.
Jan 30 07:32:28 weewx root[44956]: /etc/rc: DEBUG: checkyesno: nginx_enable is set to YES.
Jan 30 07:32:28 weewx root[44957]: /etc/rc: DEBUG: run_rc_command: start_precmd: nginx_precmd
Jan 30 07:32:28 weewx root[44958]: /etc/rc: DEBUG: checkyesno: nginx_http_accept_enable is set to NO.
Jan 30 07:32:28 weewx root[44959]: /etc/rc: DEBUG: checkyesno: nginx_reload_quiet is set to NO.
Jan 30 07:32:28 weewx root[44961]: /etc/rc: DEBUG: checkyesno: nginxlimits_enable is set to NO.
Jan 30 07:32:28 weewx root[44962]: /etc/rc: DEBUG: checkyesno: rc_startmsgs is set to YES.
Jan 30 07:32:28 weewx root[44963]: /etc/rc: DEBUG: run_rc_command: doit:  limits -C daemon  /usr/local/sbin/nginx 
Jan 30 07:32:28 weewx root[44968]: /etc/rc: DEBUG: checkyesno: nis_ypxfrd_enable is set to NO.
Jan 30 07:32:28 weewx root[44970]: /etc/rc: DEBUG: checkyesno: rpc_ypupdated_enable is set to NO.
Jan 30 07:32:28 weewx root[44972]: /etc/rc: DEBUG: checkyesno: sshd_enable is set to NO.
Jan 30 07:32:28 weewx root[44974]: /etc/rc: DEBUG: checkyesno: sendmail_enable is set to NO.
Jan 30 07:32:28 weewx root[44975]: /etc/rc: DEBUG: checkyesno: sendmail_submit_enable is set to NO.
Jan 30 07:32:28 weewx root[44976]: /etc/rc: DEBUG: checkyesno: sendmail_enable is set to NO.
Jan 30 07:32:28 weewx root[44977]: /etc/rc: DEBUG: checkyesno: sendmail_submit_enable is set to NO.
Jan 30 07:32:28 weewx root[44978]: /etc/rc: DEBUG: checkyesno: sendmail_outbound_enable is set to NO.
Jan 30 07:32:28 weewx root[44979]: /etc/rc: DEBUG: checkyesno: sendmail_msp_queue_enable is set to NO.
Jan 30 07:32:28 weewx root[44981]: /etc/rc: DEBUG: checkyesno: cron_dst is set to YES.
Jan 30 07:32:28 weewx root[44982]: /etc/rc: DEBUG: checkyesno: cron_enable is set to YES.
Jan 30 07:32:28 weewx root[44983]: /etc/rc: DEBUG: checkyesno: rc_startmsgs is set to YES.
Jan 30 07:32:28 weewx root[44984]: /etc/rc: DEBUG: run_rc_command: doit:  limits -C daemon  /usr/sbin/cron  -m -J 15 -s
Jan 30 07:32:28 weewx root[44988]: /etc/rc: DEBUG: run_rc_command: doit: pkg_start
Jan 30 07:32:28 weewx root[44997]: /etc/rc.d/sysctl: DEBUG: run_rc_command: doit: sysctl_start last
Jan 30 07:32:28 weewx root[44999]: /etc/rc: DEBUG: checkyesno: kern_securelevel_enable is set to NO.
Jan 30 07:32:28 weewx root[45002]: /etc/rc: DEBUG: run_rc_command: doit: msgs_start
Jan 30 07:32:28 weewx root[45004]: /etc/rc: DEBUG: set_rcvar_obsolete: $kpasswdd_server_enable(old) -> $kpasswdd_enable(new) is defined
Jan 30 07:32:28 weewx root[45005]: /etc/rc: DEBUG: set_rcvar_obsolete: $kpasswdd_server(old) -> $kpasswdd_program(new) is defined
Jan 30 07:32:28 weewx root[45006]: /etc/rc: DEBUG: set_rcvar_obsolete: $kerberos5_server_enable(old) -> $kdc_enable(new) is defined
Jan 30 07:32:28 weewx root[45007]: /etc/rc: DEBUG: checkyesno: kpasswdd_enable is set to NO.
Jan 30 07:32:28 weewx root[45009]: /etc/rc: DEBUG: checkyesno: kfd_enable is set to NO.
Jan 30 07:32:28 weewx root[45011]: /etc/rc: DEBUG: set_rcvar_obsolete: $kadmind5_server_enable(old) -> $kadmind_enable(new) is defined
Jan 30 07:32:28 weewx root[45012]: /etc/rc: DEBUG: set_rcvar_obsolete: $kadmind5_server(old) -> $kadmind_program(new) is defined
Jan 30 07:32:28 weewx root[45013]: /etc/rc: DEBUG: set_rcvar_obsolete: $kerberos5_server_enable(old) -> $kdc_enable(new) is defined
Jan 30 07:32:28 weewx root[45014]: /etc/rc: DEBUG: checkyesno: kadmind_enable is set to NO.
Jan 30 07:32:28 weewx root[45016]: /etc/rc: DEBUG: checkyesno: ipropd_slave_enable is set to NO.
Jan 30 07:32:28 weewx root[45018]: /etc/rc: DEBUG: checkyesno: ipropd_master_enable is set to NO.
Jan 30 07:32:28 weewx root[45020]: /etc/rc: DEBUG: checkyesno: ipfw_netflow_enable is set to NO.
Jan 30 07:32:28 weewx root[45022]: /etc/rc: DEBUG: checkyesno: inetd_enable is set to NO.
Jan 30 07:32:28 weewx root[45024]: /etc/rc: DEBUG: checkyesno: ftpd_enable is set to NO.
Jan 30 07:32:28 weewx root[45026]: /etc/rc: DEBUG: checkyesno: ftpproxy_enable is set to NO.
Jan 30 07:32:28 weewx root[45028]: /etc/rc: DEBUG: checkyesno: bsnmpd_enable is set to NO.
Jan 30 07:32:28 weewx root[45030]: /etc/rc: DEBUG: checkyesno: blacklistd_enable is set to NO.
 

gwaitsi

Patron
Joined
May 18, 2020
Messages
243
I had to look at several start scripts on my system, but that weewx script is for Linux, not FreeBSD. Try something like this instead:

Code:
#!/bin/sh
#
# PROVIDE: weewx
# KEYWORD: shutdown
#
# Add the following to /etc/rc.conf[.local] to enable this service
#
# weewx_enable="YES"
#

. /etc/rc.subr

: ${weewx_enable="NO"}

name=weewx
rcvar="weewx_enable"

weewx_bin=/usr/local/share/weewx/bin/weewxd
weewx_cfg=/usr/local/share/weewx/weewx.conf
weewx_pid=/var/run/weewx.pid
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
start_cmd="weewx_start"
stop_cmd=weewx_stop

weewx_start()
{
        if ! checkyesno weewx_enable ; then
                return 0
        fi

        echo "Starting ${name}..."

        ${weewx_bin} ${weewx_cfg} --daemon &
    echo $! > ${weewx_pid}
}

weewx_stop()
{
    if [ -f ${weewx_pid} ] ; then
        echo "Stopping ${name}..."
        kill `cat ${weewx_pid}`
        rm ${weewx_pid}
    fi
}

load_rc_config ${name}
run_rc_command "$1"


And set weewx_enable="YES" in /etc/rc.conf.local in the jail.

Thanks again for you help Samuel, I appreciate it.

I got your script working by adding the NGINX requirements + networking.
# REQUIRE: LOGIN cleanvar netif
 
Last edited:

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Glad you were able to find a simple modification that got it working.
 
Top