Skip to main content
Topic: uptimed package (Read 395 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

uptimed package

Hi,

I usually install uptimed on my machine, so i can keep tracks of the uptime, reboots and kernel
Unfortunately, the package uptimed does not exist on artix, only in arch/extra
Do you think it could be added to artix repos ?

Also, for this to work, it needs a daemon to be started, which records the boot time and kernel
So i wrote the service file, for runit and openrc. tested and working :)

1/ runit
file: /etc/runit/sv/uptimed/run

Code: [Select]
#!/bin/sh
install -d -m775 -o daemon -g daemon /run/uptimed
install -d -m775 -o daemon -g daemon /var/spool/uptimed
exec chpst -u daemon -U daemon  /usr/bin/uptimed -f

2/ openrc
file: /etc/init.d/uptimed

Code: [Select]
#!/usr/bin/openrc-run

UPTIMED_OPTS="-p /run/uptimed/uptimed.pid"

depend()
{
need localmount
}

start_pre()
{
install -d -m 755 -o daemon -g daemon /run/uptimed
install -d -m 755 -o daemon -g daemon /var/spool/uptimed
uptimed -b
}

start()
{
ebegin "Starting uptimed"
start-stop-daemon --start --quiet -u daemon:daemon --exec /usr/bin/uptimed -- ${UPTIMED_OPTS}
eend $?
}

stop()
{
ebegin "Stopping uptimed"
start-stop-daemon --stop --quiet --exec /usr/bin/uptimed
eend $?
}

enjoy  8)

Re: uptimed package

Reply #1
May I interject in favour of supervise-daemon:
Code: [Select]
#!/usr/bin/openrc-run

command_user=daemon:daemon
command=/usr/bin/uptimed
command_args="-p /run/uptimed/uptimed.pid -f"
supervisor="supervise-daemon"

depend() {
need localmount
}

start_pre() {
install -d -m 755 -o daemon -g daemon /run/uptimed
install -d -m 755 -o daemon -g daemon /var/spool/uptimed
uptimed -b
}

Re: uptimed package

Reply #2
hey nous,
i admit i wasn't sure what was the best way to write it for openrc  :)
so i took an exemple out of an other script in init.d with a start/stop function, while other are written with command, command_args and supervisor
thanks for you correction ;)

Re: uptimed package

Reply #3
The start() and stop() functions are unnecessary in OpenRC unless the daemon does sneaky stuff; strike them out. Many other aspects, as daemon user/group ownership, chroot, respawn attributes etc may be defined without resorting to command-line options. For supervised execution, one only needs to add the stay-in-foreground daemon's argument (almost universally -f).
We've tested OpenRC supervision so extensively (in our infrastructure no less, not some cowardly VM or containers), that we feel confident to have it as standard to most our scripts. Also, uptimed and \1-openrc are now in [galaxy].

 

Re: uptimed package

Reply #4
awesome ! thanks