parent
cef887def6
commit
a8b37ba452
|
|
@ -1,27 +1,65 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# PROVIDE: FusionPBX
|
# PROVIDE: event_guard
|
||||||
# REQUIRE: LOGIN cleanvar
|
# REQUIRE: DAEMON
|
||||||
# KEYWORD: shutdown
|
# KEYWORD: shutdown
|
||||||
#
|
#
|
||||||
# Add the following lines to /etc/rc.conf to enable freeswitch:
|
# Add the following lines to /etc/rc.conf to enable event_guard:
|
||||||
# event_guard_enable: Set it to "YES" to enable freeswitch.
|
# event_guard_enable: Set it to "YES" to enable event_guard.
|
||||||
# Default is "NO".
|
# Default is "NO".
|
||||||
#
|
#
|
||||||
|
|
||||||
. /etc/rc.subr
|
. /etc/rc.subr
|
||||||
name="event_guard"
|
name="event_guard"
|
||||||
|
|
||||||
rcvar=${name}_enable
|
rcvar=${name}_enable
|
||||||
load_rc_config $name
|
load_rc_config $name
|
||||||
|
|
||||||
|
# Set defaults
|
||||||
: ${event_guard_enable="NO"}
|
: ${event_guard_enable="NO"}
|
||||||
: ${event_guard_pidfile="/var/run/event_guard.pid"}
|
: ${event_guard_pidfile="/var/run/event_guard.pid"}
|
||||||
|
|
||||||
|
# Prepare the variables
|
||||||
start_cmd=${name}_start
|
start_cmd=${name}_start
|
||||||
stop_cmd=${name}_stop
|
stop_cmd=${name}_stop
|
||||||
status_cmd=${name}_status
|
status_cmd=${name}_status
|
||||||
pidfile=${event_guard_pidfile}
|
pidfile=${event_guard_pidfile}
|
||||||
|
|
||||||
|
# Path to the PHP script
|
||||||
|
script="/usr/local/www/fusionpbx/app/event_guard/resources/service/event_guard.php"
|
||||||
|
|
||||||
|
# Command to run the script
|
||||||
|
command="/usr/local/bin/php"
|
||||||
|
command_args="$script > /dev/null 2>&1"
|
||||||
|
|
||||||
event_guard_start() {
|
event_guard_start() {
|
||||||
/usr/local/bin/php /usr/local/www/fusionpbx/app/event_guard/resources/service/event_guard.php &
|
echo "Starting $name..."
|
||||||
|
if [ -f "$pidfile" ] && kill -0 "$(cat $pidfile)" 2>/dev/null; then
|
||||||
|
echo "$name is already running."
|
||||||
|
else
|
||||||
|
$command $command_args &
|
||||||
|
echo $! > "$pidfile"
|
||||||
|
echo "$name started."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
event_guard_stop() {
|
event_guard_stop() {
|
||||||
/usr/local/bin/php /usr/local/www/fusionpbx/app/event_guard/resources/service/event_guard.php -stop
|
echo "Stopping $name..."
|
||||||
|
if [ -f "$pidfile" ] && kill -0 "$(cat $pidfile)" 2>/dev/null; then
|
||||||
|
kill "$(cat $pidfile)"
|
||||||
|
rm -f "$pidfile"
|
||||||
|
echo "$name stopped."
|
||||||
|
else
|
||||||
|
echo "$name is not running."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event_guard_status() {
|
||||||
|
if [ -f "$pidfile" ] && kill -0 "$(cat $pidfile)" 2>/dev/null; then
|
||||||
|
echo "$name is running with PID $(cat $pidfile)."
|
||||||
|
else
|
||||||
|
echo "$name is not running."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
run_rc_command "$1"
|
run_rc_command "$1"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue