Skip to content

Create new FreeBSD rc file #537

@davidnewhall

Description

@davidnewhall

Model a new rc for FreeBSD from this Radarr file. The notable parts are in the comments at the top, and how the variables (specifically user) can be overridden in /etc/rc.conf.

#!/bin/sh

# PROVIDE: radarr
# REQUIRE: LOGIN network
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf or use sysrc to enable radarr
# ${radarr_enable="YES"}
# Optionaly there are some other parameters
# ${radarr_user="radarr"}
# ${radarr_group="radarr"}
# This stores radarr data (e.g., databases, configs, logs)
# ${radarr_data_dir="/usr/local/radarr"}
# This stores the PID files that daemon will use
# ${radarr_pid_dir:="/var/run/radarr"}

. /etc/rc.subr
name=radarr
rcvar=radarr_enable
load_rc_config $name

: ${radarr_enable:=NO}
: ${radarr_user:="radarr"}
: ${radarr_group:="radarr"}
: ${radarr_exec_dir:="/usr/local/share/radarr/bin"}
: ${radarr_data_dir:="/usr/local/radarr"}
: ${radarr_pid_dir:="/var/run/radarr"}

pidfile="${radarr_pid_dir}/${name}_daemon.pid"
pidfile_child="${radarr_pid_dir}/${name}_child.pid"
command="/usr/sbin/daemon"


start_precmd=${name}_precmd
radarr_precmd() {
    if [ ! -d ${radarr_data_dir} ]; then
        install -d -o ${radarr_user} -g ${radarr_group} ${radarr_data_dir}
    fi
    if [ ! -d ${radarr_pid_dir} ]; then
        install -d -o ${radarr_user} -g ${radarr_group} ${radarr_pid_dir}
    fi

    # .NET 6+ use dual mode sockets to avoid the separate AF handling.
    # disable .NET use of V6 if no ipv6 is configured.
    # See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=259194#c17
    ifconfig -a -u -G lo | grep -q inet6
    if [ $? == 1 ]; then
        export DOTNET_SYSTEM_NET_DISABLEIPV6=1
    fi

    if [ `uname -K` -ge 1400092 ]; then
        export CLR_OPENSSL_VERSION_OVERRIDE=30
    fi

    # Set path so pre and post import scripts work with 3rd party binaries
    export PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"

    rc_flags="-r -f -p ${pidfile_child} -P ${pidfile} ${radarr_exec_dir}/Radarr --data=${radarr_data_dir} --nobrowser >> /dev/null 2>&1 ${rc_flags}"
}

run_rc_command "$1"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions