OpenRC script for non systemd Linux OS

Want to write your own code to work with a HDHomeRun or work with the HDHomeRun DVR? We are happy to help with concepts, APIs, best practices.
Post Reply
averyfreeman
Posts: 252
Joined: Sun Apr 09, 2017 11:12 am
Device ID: 1326E235 1313788A
Location: Olympia, WA
Contact:

OpenRC script for non systemd Linux OS

Post by averyfreeman »

Hello everyone,

I've been using Alpine Linux for my hdhomerun_record DVR for the last year, and it just occurred to me that I have an OpenRC script for controlling hdhomerun_record as a service that perhaps I should share with everyone, since I don't think I've seen another one of these around.

It was my first experience writing an OpenRC script so my apologies if it's a little choppy, I find it works fine though. Was pretty similar to the rc script from FreeBSD, just slightly different syntax. If someone with more experience would like to chime in, I'd appreciate it.

/etc/init.d/hdhomerun_record

Code: Select all

#!/sbin/openrc-run
#
name=$SVCNAME
cfgfile="/etc/$SVCNAME.conf"
pidfile="/var/run/$SVCNAME/$SVCNAME.pid"
command=/usr/sbin/$SVCNAME
command_user="daemon"
command_args="start foreground --conf=/etc/hdhomerun_record.conf"
start() $command $command_args
restart() $command "restart"
stop() $command "stop"
status() $command "status"
I originally tried to generate a log file from the binary, but it doesn't create much output. Seems like the real logs are in the recordings folder.

File locations are somewhat arbitrary, but appeared to follow the pattern I see for a common *nix directory structure. You can really put them wherever you want.

Here's a few good references for OpenRC (the first two were my primary source of this script's structure):

https://github.com/OpenRC/openrc/blob/m ... t-guide.md
https://wiki.gentoo.org/wiki/OpenRC
https://wiki.archlinux.org/index.php/OpenRC
https://wiki.gentoo.org/wiki/OpenRC_to_ ... Cheatsheet

Post Reply