Plugin Request: Uptime Kuma

Davvo

MVP
Joined
Jul 12, 2022
Messages
3,222
Likely a suggestion on the bug reporting site, but it's unlikely it will get approved.

Edit: yeah I'm blind, didn't read the community part; kindly ask and start seeing how to put in a jail.
 
Last edited:

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Community plugins are created and maintained by the community, hence the name. But plugins as a whole are a dead end, "all but deprecated," and "a path to sadness," and thus iX has said they're going to be going away in due course. See:
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,700
OK, so the plugin ecosystem is a little broken and unlikely to get fixed, which means that you're unlikely to get support for such a request.

What I can help you with is how to set it up in a jail on your own:

Copy this to a script file on your TrueNAS host:
ee install_uptimekuma.sh
Code:
#! /bin/sh
echo '{"pkgs":["npm-node18","git"]}' > /tmp/pkg.json
iocage create -n "uptimekuma" -p /tmp/pkg.json -r 13.1-RELEASE dhcp="on" vnet="on" boot="on"
rm /tmp/pkg.json
iocage exec uptimekuma "pw user add uptimekuma -c uptimekuma -u 1001 -d /nonexistent -s /usr/bin/nologin"

ESC to exit and save it.

Give it permission to run:
chmod +x install_uptimekuma.sh

Then Run it:
./install_uptimekuma.sh

That will create you a jail called uptimekuma with the right pkgs in it with a user called uptimekuma and will start the jail.

Then, you'll need to add/edit a couple of files, we'll start by creating the rc.d startup file
iocage exec uptimekuma ee /usr/local/etc/rc.d/uptimekuma

Paste this content into that file:
Code:
#!/bin/sh

# $FreeBSD: 340872 2014-01-24 00:14:07Z mat $
#
# PROVIDE: uptimekuma
# REQUIRE: NETWORKING
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable uptimekuma:
#
# uptimekuma_enable="YES"
#

. /etc/rc.subr                                                                                      
                                                                                                   
name="uptimekuma"                                                                                  
rcvar=uptimekuma_enable                                                                            
pidfile=${uptimekuma_pidfile:-"/var/run/uptimekuma.pid"}
uptimekuma_chdir="/usr/local/uptime-kuma"                                                           
HOME=/usr/local/uptime-kuma
command="/usr/sbin/daemon"
PATH=${PATH}:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin                
export LC_CTYPE="en_US.UTF-8"                                                                      
command_args="-r -u uptimekuma -P /var/run/uptimekuma.pid /usr/local/bin/node /usr/local/uptime-kuma/server/server.js --name uptime-kuma -- --port=3001 --host=0.0.0.0"
                                                                                                   
load_rc_config $name                                                                                
: ${uptimekuma_enable:="NO"}                                                                        

run_rc_command "$1"

ESC to exit and Save

Then we give that file permission to run
iocage exec uptimekuma chmod u+x /usr/local/etc/rc.d/uptimekuma

Then we'll actually install uptime-kuma:
iocage exec uptimekuma "npm install npm -g"

iocage exec uptimekuma "cd /usr/local && git clone https://github.com/louislam/uptime-kuma.git && cd uptime-kuma && npm run setup"

And edit one of the installed files:
iocage exec uptimekuma ee /usr/local/uptime-kuma/server/server.js

Paste this line as the first line of code above the line that says "console.log("Welcome to Uptime Kuma");"
process.chdir('/usr/local/uptime-kuma');

ESC to exit and Save

We'll give the uptimekuma user permissions to the directory:
iocage exec uptimekuma "chown -R uptimekuma:uptimekuma /usr/local/uptime-kuma"

Then we enable the service to start with the jail:
iocage exec uptimekuma sysrc uptimekuma_enable="YES"

You can then either restart the jail or just run this command to start uptimekuma right away:
iocage exec uptimekuma service uptimekuma start

You then connect to the jail's IP on port 3001:
 
Last edited:

danb35

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

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,700
Learning rc.d scripting and I’m wondering what the purpose is of adding that one line (process.chdir) to the server.js file?
The default is to work in a directory which doesn't contain the expected files, so needs to be set in the .js file (otherwise you can launch it from the CLI interactive, but the daemon won't run it).
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
Cool.

I also see you have “cjayho: restart if crashed” at the end of the commented command_args line.
Is that necessary?

Do rc.d scripts not automatically restart if they crash, or does that need to be specified in the file somehow?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,700
I also see you have “cjayho: restart if crashed” at the end of the commented command_args line.
Is that necessary?

Do rc.d scripts not automatically restart if they crash, or does that need to be specified in the file somehow?
That was from the original I had picked up from somewhere.

You may not have noticed (maybe I didn't either) that I removed the -r switch, which doesn't enable the auto-restart feature of daemon (https://man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&format=html).

That could easily be added back. (EDIT: which I have now done... and removed the confusing commented line)

But in general, no, rc.d doesn't do that.
 
Last edited:

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776

victort

Guru
Joined
Dec 31, 2021
Messages
973
That was from the original I had picked up from somewhere.

You may not have noticed (maybe I didn't either) that I removed the -r switch, which doesn't enable the auto-restart feature of daemon (https://man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&format=html).

That could easily be added back. (EDIT: which I have now done... and removed the confusing commented line)

But in general, no, rc.d doesn't do that.
Ah yes, I read that in the daemon manual. Was just going to ask about that.

Thank you.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,700
I gave it a look, seems OK, so I undeleted the resource.
 
Top