#!/bin/sh # PROVIDE: sillytavern # REQUIRE: NETWORKING DAEMON # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf.local or /etc/rc.conf # to enable this service: # # sillytavern_enable (bool): Set it to YES to enable sillytavern. # Default is "NO". # sillytavern_dir (str): Set the path to use for the node directory. # Default is "/usr/local/etc/sillytavern" # sillytavern_port (number): Set the port to listen on. # Default is "8000". # sillytavern_args (str): Additional args to pass to sillytavern. # Default is "". # sillytavern_syslog_output_priority (str): Set syslog priority if syslog enabled. # Default is "info". See daemon(8). # sillytavern_syslog_output_facility (str): Set syslog facility if syslog enabled. # Default is "daemon". See daemon(8). # What a mess... # add and chown a sillytavern directory in the pid folder so the altered user can edit it, and pull down the git repo to a similarly chown'd folder in /usr/local/etc/sillytavern # you'll need to run the installer .sh once, but from then on you shouldn't need to unless you update . /etc/rc.subr name="sillytavern" load_rc_config $name : ${sillytavern_enable:="NO"} : ${sillytavern_dir:="/usr/local/etc/sillytavern"} : ${sillytavern_port:="8000"} : ${sillytavern_args:=""} : ${sillytavern_user:="sillytavern"} : ${sillytavern_group:="sillytavern"} rcvar=sillytavern_enable pidfile=/var/run/sillytavern/${name}.pid # If daemon syslog functionality supported, concatenate syslog flags for passing to daemon. DAEMON=$(/usr/sbin/daemon 2>&1 | grep -q syslog ; echo $?) if [ ${DAEMON} -eq 0 ]; then : ${sillytavern_syslog_output_enable:="NO"} : ${sillytavern_syslog_output_priority:="info"} : ${sillytavern_syslog_output_facility:="daemon"} if checkyesno sillytavern_syslog_output_enable; then sillytavern_syslog_output_flags="-t ${name} -T ${name}" if [ -n "${sillytavern_syslog_output_priority}" ]; then sillytavern_syslog_output_flags="${sillytavern_syslog_output_flags} -s ${sillytavern_syslog_output_priority}" fi if [ -n "${sillytavern_syslog_output_facility}" ]; then sillytavern_syslog_output_flags="${sillytavern_syslog_output_flags} -l ${sillytavern_syslog_output_facility}" fi fi else sillytavern_syslog_output_enable="NO" sillytavern_syslog_output_flags="" fi # Env Setup export HOME=$( getent passwd "$sillytavern_runas" | cut -d: -f6 ) # Gets the home directory of the runAs user exec_path="/usr/local/bin/node" procname=${exec_path} sillytavern_chdir=${sillytavern_dir} command_interpreter="daemon" command="/usr/sbin/daemon" command_args="-f -r -P ${pidfile} ${sillytavern_syslog_output_flags} ${exec_path} ${sillytavern_dir}/server.js ${sillytavern_args}" run_rc_command "$1"