Skip to content

Instantly share code, notes, and snippets.

@tspspi

tspspi/nodered

Created Feb 29, 2020
Embed
What would you like to do?
FreeBSD NodeRED rc.d init script
#!/bin/sh
#
# PROVIDE: nodered
# REQUIRE: LOGIN
# KEYWORD: shutdown
# Configuration variables:
#
# Variable Default Description
# ====================================================================================================
# nodered_enable NO Can be YES or NO to enable or disable automatic launch of nodered on boot.
# nodered_user nodered Specifies the user that should be used to run nodered.
# nodered_args Additional arguments
#
# PID-File: /var/run/nodered.pid
# LOG-File: /var/log/nodered.log (Should be added to /etc/newsyslog.conf)
#
# Usage: Copy to /usr/local/etc/rc.d/nodered
. /etc/rc.subr
# Specify some core information
name="nodered"
program_name="node-red"
title="NodeRED"
load_rc_config ${name}
: ${nodered_enable="NO"}
: ${nodered_user="nodered"}
rcvar=nodered_enable
# Determine HOME directory to be set for daemon
export HOME=$( getent passwd "$nodered_user" | cut -d: -f6 )
# Some other properties for node
exec_path="/usr/local/bin/${program_name}" # Path to the node-red exec, /usr/local/bin/ when installed globally
output_file="/var/log/${program_name}.log" # Path to Node-RED output file
pidfile=/var/run/${program_name}.pid
# We'll use "daemon" to run nodered in background ...
command="/usr/sbin/daemon"
command_args="-r -t ${title} -u ${nodered_user} -o ${output_file} -P ${pidfile} ${exec_path} ${nodered_args}"
# Execute rc.d script commands
load_rc_config ${name}
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.