Seeking advice to contribute an uptime-kuma port

Hi everyone,

I'm seeking advice on creating an uptime-kuma port, hopefully for the eventual submission to the official ports tree, given its NodeJS nature and the fact that its installation process basically consists of the downloading of a collection of npm dependencies. If I'm not mistaken, this could present the official ports tree and/or poudriere builders with problems.

Additionally, uptime-kuma claims it doesn't support FreeBSD, but I did manage to get it working without much fuss, both its older 1.x and its current 2.0 releases, inside of a 13.5 jail via the rc script below.

Thank you in advance for any tips on how to approach this, most appreciated! And, needless to say, please feel free to critique my rc script.

sh:
#!/bin/sh

# uptime-kuma FreeBSD Service Script

# PROVIDE: uptime_kuma
# REQUIRE: NETWORKING
# KEYWORD: shutdown
#
# Optional settings:
# uptime_kuma_user (system user): User who will run the service.
# uptime_kuma_group (system group): Service user's main group.
# uptime_kuma_home (path): Uptime Kuma installation directory.
# uptime_kuma_data_path (path): Uptime Kuma data directory.
# uptime_kuma_browsers_path (path): Microsoft Playwright's browsers path (https://playwright.dev/docs/browsers#managing-browser-binaries).
# uptime_kuma_host (IP address): Service host.
# uptime_kuma_port (TCP port): Service port.

. /etc/rc.subr

name=uptime_kuma
rcvar=${name}_enable

load_rc_config $name

: ${uptime_kuma_enable:=NO}
: ${uptime_kuma_user:=www}
: ${uptime_kuma_group:=www}
: ${uptime_kuma_home:=/usr/local/www/uptime-kuma}
: ${uptime_kuma_data_path:=${uptime_kuma_home}/data}
: ${uptime_kuma_browsers_path:=/nonexistent}
: ${uptime_kuma_host:=0.0.0.0}
: ${uptime_kuma_port:=3001}

eval ${name}_chdir=${uptime_kuma_home}
eval ${name}_env="\"HOME=${uptime_kuma_home} PLAYWRIGHT_BROWSERS_PATH=${uptime_kuma_browsers_path}\""

dashname=$(echo ${name} | tr _ -)
pidfile=/var/run/${dashname}/${dashname}.pid
command=/usr/sbin/daemon
command_args="-r -f -o /var/log/${dashname}/${dashname}.log -H -P ${pidfile} /usr/local/bin/node ${uptime_kuma_home}/server/server.js -- --name ${dashname} --host=${uptime_kuma_host} --port=${uptime_kuma_port}"
start_precmd=start_precmd

start_precmd()
{
    [ -d /var/log/${dashname} ] || install -d -o ${uptime_kuma_user} -g ${uptime_kuma_group} /var/log/${dashname}
    [ -d /var/run/${dashname} ] || install -d -o ${uptime_kuma_user} -g ${uptime_kuma_group} /var/run/${dashname}
}

run_rc_command "$1"
 
Some small corrections and refinements to Uptime Kuma's rc script:

sh:
#!/bin/sh

# PROVIDE: uptime_kuma
# REQUIRE: NETWORKING DAEMON
# KEYWORD: shutdown
#
# Optional settings:
# uptime_kuma_user (system user): User who will run the service.
# uptime_kuma_group (system group): Service user's main group.
# uptime_kuma_deployment_path (path): Uptime Kuma installation directory.
# uptime_kuma_data_path (path): Uptime Kuma data directory.
# uptime_kuma_browsers_path (path): Microsoft Playwright's browsers path (https://playwright.dev/docs/browsers#managing-browser-binaries).
# uptime_kuma_host (IP address): Service host.
# uptime_kuma_port (TCP port): Service port.

. /etc/rc.subr

name="uptime_kuma"
rcvar="${name}_enable"

load_rc_config $name

: ${uptime_kuma_enable:="NO"}
: ${uptime_kuma_user:="www"}
: ${uptime_kuma_group:="www"}
: ${uptime_kuma_deployment_path:="/usr/local/www/$(echo ${name} | tr _ -)"}
: ${uptime_kuma_data_path:="${uptime_kuma_deployment_path}/data"}
: ${uptime_kuma_browsers_path:="/nonexistent"}
: ${uptime_kuma_host:="0.0.0.0"}
: ${uptime_kuma_port:="3001"}

pidfile="/var/run/${name}/${name}.pid"
command="/usr/sbin/daemon"
uptime_kuma_flags="-t ${name} -P ${pidfile} -r -f -o /var/log/${name}/${name}.log -H"
command_args="/usr/local/bin/node ${uptime_kuma_deployment_path}/server/server.js -- --host=${uptime_kuma_host} --port=${uptime_kuma_port}"

eval uptime_kuma_chdir="${uptime_kuma_deployment_path}"
eval uptime_kuma_env="\"HOME=${uptime_kuma_deployment_path} PLAYWRIGHT_BROWSERS_PATH=${uptime_kuma_browsers_path}\""

start_precmd="${name}_start_precmd"

uptime_kuma_start_precmd()
{
    [ -d "/var/log/${name}" ] || install -d -o "${uptime_kuma_user}" -g "${uptime_kuma_group}" "/var/log/${name}"
    [ -d "/var/run/${name}" ] || install -d -o "${uptime_kuma_user}" -g "${uptime_kuma_group}" "/var/run/${name}"
}

run_rc_command "$1"
 
Some small corrections and refinements to Uptime Kuma's rc script:

sh:
#!/bin/sh

# PROVIDE: uptime_kuma
# REQUIRE: NETWORKING DAEMON
# KEYWORD: shutdown
#
# Optional settings:
# uptime_kuma_user (system user): User who will run the service.
# uptime_kuma_group (system group): Service user's main group.
# uptime_kuma_deployment_path (path): Uptime Kuma installation directory.
# uptime_kuma_data_path (path): Uptime Kuma data directory.
# uptime_kuma_browsers_path (path): Microsoft Playwright's browsers path (https://playwright.dev/docs/browsers#managing-browser-binaries).
# uptime_kuma_host (IP address): Service host.
# uptime_kuma_port (TCP port): Service port.

. /etc/rc.subr

name="uptime_kuma"
rcvar="${name}_enable"

load_rc_config $name

: ${uptime_kuma_enable:="NO"}
: ${uptime_kuma_user:="www"}
: ${uptime_kuma_group:="www"}
: ${uptime_kuma_deployment_path:="/usr/local/www/$(echo ${name} | tr _ -)"}
: ${uptime_kuma_data_path:="${uptime_kuma_deployment_path}/data"}
: ${uptime_kuma_browsers_path:="/nonexistent"}
: ${uptime_kuma_host:="0.0.0.0"}
: ${uptime_kuma_port:="3001"}

pidfile="/var/run/${name}/${name}.pid"
command="/usr/sbin/daemon"
uptime_kuma_flags="-t ${name} -P ${pidfile} -r -f -o /var/log/${name}/${name}.log -H"
command_args="/usr/local/bin/node ${uptime_kuma_deployment_path}/server/server.js -- --host=${uptime_kuma_host} --port=${uptime_kuma_port}"

eval uptime_kuma_chdir="${uptime_kuma_deployment_path}"
eval uptime_kuma_env="\"HOME=${uptime_kuma_deployment_path} PLAYWRIGHT_BROWSERS_PATH=${uptime_kuma_browsers_path}\""

start_precmd="${name}_start_precmd"

uptime_kuma_start_precmd()
{
    [ -d "/var/log/${name}" ] || install -d -o "${uptime_kuma_user}" -g "${uptime_kuma_group}" "/var/log/${name}"
    [ -d "/var/run/${name}" ] || install -d -o "${uptime_kuma_user}" -g "${uptime_kuma_group}" "/var/run/${name}"
}

run_rc_command "$1"
Happy to help port this.
 
  • Thanks
Reactions: dch
I can also confirm that Uptime Kuma worths perfectly in FreeBSD, but I’m too lazy to work on a port, so I just use an install script.


My rc script is slightly different than yours, but everything works, including the 2.x versions.
Maybe you can make the repo public? It 404s here. Having a working script to start will be helpful.
 
Maybe you can make the repo public? It 404s here. Having a working script to start will be helpful.
I just clicked it and it’s working. It is public.

I did have to edit the post a couple minutes after I posted to correct the link, but it’s been working since then.
 
Happy to help port this.
Lovely!

I've been using Uptime Kuma for a long while already on FreeBSD, both through iocage and now through BastilleBSD, and it's become an integral part of my infrastructure.

Below is my most recent version of the rc(8) script, simplified from previous versions I've posted here to remove unnecessary abstractions on things that will hardly change, and to better adhere to rc(8) best practices. Please feel free to critique as appropriate!

sh:
#!/bin/sh

# PROVIDE: uptime_kuma
# REQUIRE: NETWORKING DAEMON
# KEYWORD: shutdown
#
# Mandatory settings:
# uptime_kuma_enable: Service enable knob.
#
# Optional settings:
# uptime_kuma_host (IP address): Service host.
# uptime_kuma_port (TCP port): Service port.


. /etc/rc.subr

name="uptime_kuma"
rcvar="${name}_enable"

load_rc_config $name

: ${uptime_kuma_enable:="NO"}
: ${uptime_kuma_host:="0.0.0.0"}
: ${uptime_kuma_port:="3001"}

pidfile="/var/run/${name}/${name}.pid"
command="/usr/sbin/daemon"
uptime_kuma_flags="-t ${name} -P ${pidfile} -r -f -o /var/log/${name}/${name}.log -H"
uptime_kuma_deployment_path="/usr/local/www/$(echo ${name} | tr _ -)"
command_args="/usr/local/bin/node ${uptime_kuma_deployment_path}/server/server.js -- --host=${uptime_kuma_host} --port=${uptime_kuma_port}"
uptime_kuma_user="www"
uptime_kuma_group="www"

eval uptime_kuma_chdir="${uptime_kuma_deployment_path}"
# Microsoft Playwright's browsers path (https://playwright.dev/docs/browsers#managing-browser-binaries).
eval uptime_kuma_env="\"HOME=${uptime_kuma_deployment_path} PLAYWRIGHT_BROWSERS_PATH=/nonexistent\""

start_precmd="uptime_kuma_start_precmd"

uptime_kuma_start_precmd()
{
    [ -d "/var/log/${name}" ] || install -d -o "${uptime_kuma_user}" -g "${uptime_kuma_group}" "/var/log/${name}"
    [ -d "/var/run/${name}" ] || install -d -o "${uptime_kuma_user}" -g "${uptime_kuma_group}" "/var/run/${name}"
}

run_rc_command "$1"

If anyone's interested in how I deploy this service via Bastille, I'd be open to discussing sharing of that code.
 
I can also confirm that Uptime Kuma worths perfectly in FreeBSD, but I’m too lazy to work on a port, so I just use an install script.


My rc script is slightly different than yours, but everything works, including the 2.x versions.
Just upgraded to 2.3.2 a few minutes ago on a 14.4-RELEASE-p5 Bastille jail, all working like a charm!
 
Back
Top