- 
                                            1.
                                            #!/bin/sh
 - 
                                            2.
                                            
 - 
                                            3.
                                            # PROVIDE: sillytavern
 - 
                                            4.
                                            # REQUIRE: NETWORKING DAEMON
 - 
                                            5.
                                            # KEYWORD: shutdown
 - 
                                            6.
                                            #
 - 
                                            7.
                                            # Add the following lines to /etc/rc.conf.local or /etc/rc.conf
 - 
                                            8.
                                            # to enable this service:
 - 
                                            9.
                                            #
 - 
                                            10.
                                            # sillytavern_enable (bool): Set it to YES to enable sillytavern.
 - 
                                            11.
                                            # Default is "NO".
 - 
                                            12.
                                            # sillytavern_dir (str): Set the path to use for the node directory.
 - 
                                            13.
                                            # Default is "/usr/local/etc/sillytavern"
 - 
                                            14.
                                            # sillytavern_port (number): Set the port to listen on.
 - 
                                            15.
                                            # Default is "8000".
 - 
                                            16.
                                            # sillytavern_args (str): Additional args to pass to sillytavern.
 - 
                                            17.
                                            # Default is "".
 - 
                                            18.
                                            # sillytavern_syslog_output_priority (str): Set syslog priority if syslog enabled.
 - 
                                            19.
                                            # Default is "info". See daemon(8).
 - 
                                            20.
                                            # sillytavern_syslog_output_facility (str): Set syslog facility if syslog enabled.
 - 
                                            21.
                                            # Default is "daemon". See daemon(8).
 - 
                                            22.
                                            
 - 
                                            23.
                                            # What a mess...
 - 
                                            24.
                                            # 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
 - 
                                            25.
                                            # you'll need to run the installer .sh once, but from then on you shouldn't need to unless you update
 - 
                                            26.
                                            
 - 
                                            27.
                                            . /etc/rc.subr
 - 
                                            28.
                                            
 - 
                                            29.
                                            name="sillytavern"
 - 
                                            30.
                                            
 - 
                                            31.
                                            load_rc_config $name
 - 
                                            32.
                                            : ${sillytavern_enable:="NO"}
 - 
                                            33.
                                            : ${sillytavern_dir:="/usr/local/etc/sillytavern"}
 - 
                                            34.
                                            : ${sillytavern_port:="8000"}
 - 
                                            35.
                                            : ${sillytavern_args:=""}
 - 
                                            36.
                                            : ${sillytavern_user:="sillytavern"}
 - 
                                            37.
                                            : ${sillytavern_group:="sillytavern"}
 - 
                                            38.
                                            
 - 
                                            39.
                                            rcvar=sillytavern_enable
 - 
                                            40.
                                            pidfile=/var/run/sillytavern/${name}.pid
 - 
                                            41.
                                            
 - 
                                            42.
                                            # If daemon syslog functionality supported, concatenate syslog flags for passing to daemon.
 - 
                                            43.
                                            DAEMON=$(/usr/sbin/daemon 2>&1 | grep -q syslog ; echo $?)
 - 
                                            44.
                                            if [ ${DAEMON} -eq 0 ]; then
 - 
                                            45.
                                            : ${sillytavern_syslog_output_enable:="NO"}
 - 
                                            46.
                                            : ${sillytavern_syslog_output_priority:="info"}
 - 
                                            47.
                                            : ${sillytavern_syslog_output_facility:="daemon"}
 - 
                                            48.
                                            if checkyesno sillytavern_syslog_output_enable; then
 - 
                                            49.
                                            sillytavern_syslog_output_flags="-t ${name} -T ${name}"
 - 
                                            50.
                                            
 - 
                                            51.
                                            if [ -n "${sillytavern_syslog_output_priority}" ]; then
 - 
                                            52.
                                            sillytavern_syslog_output_flags="${sillytavern_syslog_output_flags} -s ${sillytavern_syslog_output_priority}"
 - 
                                            53.
                                            fi
 - 
                                            54.
                                            
 - 
                                            55.
                                            if [ -n "${sillytavern_syslog_output_facility}" ]; then
 - 
                                            56.
                                            sillytavern_syslog_output_flags="${sillytavern_syslog_output_flags} -l ${sillytavern_syslog_output_facility}"
 - 
                                            57.
                                            fi
 - 
                                            58.
                                            fi
 - 
                                            59.
                                            else
 - 
                                            60.
                                            sillytavern_syslog_output_enable="NO"
 - 
                                            61.
                                            sillytavern_syslog_output_flags=""
 - 
                                            62.
                                            fi
 - 
                                            63.
                                            
 - 
                                            64.
                                            # Env Setup
 - 
                                            65.
                                            export HOME=$( getent passwd "$sillytavern_runas" | cut -d: -f6 ) # Gets the home directory of the runAs user
 - 
                                            66.
                                            
 - 
                                            67.
                                            exec_path="/usr/local/bin/node"
 - 
                                            68.
                                            procname=${exec_path}
 - 
                                            69.
                                            
 - 
                                            70.
                                            sillytavern_chdir=${sillytavern_dir}
 - 
                                            71.
                                            
 - 
                                            72.
                                            command_interpreter="daemon"
 - 
                                            73.
                                            command="/usr/sbin/daemon"
 - 
                                            74.
                                            command_args="-f -r -P ${pidfile} ${sillytavern_syslog_output_flags} ${exec_path} ${sillytavern_dir}/server.js ${sillytavern_args}"
 - 
                                            75.
                                            
 - 
                                            76.
                                            run_rc_command "$1"
 
                         by Guest
                         by Guest
                         by Guest
                         by Guest
                         by Guest