Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asterisk: improve init.d script and fix #681 #701

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions net/asterisk/files/asterisk.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

config asterisk 'general'
option enabled '0'
option interface 'wan'
option log_stderr '1'
option log_stdout '1'
option options ''
31 changes: 27 additions & 4 deletions net/asterisk/files/asterisk.init
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
START=99

USE_PROCD=1

#PROCD_DEBUG=1

NAME=asterisk
COMMAND=/usr/sbin/$NAME

LOGGER="/usr/bin/logger -p user.err -s -t $NAME --"
log() {
level=$1
shift
/usr/bin/logger -p daemon.$level -s -t $NAME "$@"
}

start_service() {

dbdir=/var/lib/asterisk/astdb
logdir=/var/log/asterisk
cdrcsvdir=$logdir/cdr-csv
Expand All @@ -25,7 +27,7 @@ start_service() {

config_get_bool enabled general enabled 0
if [ $enabled -eq 0 ]; then
$LOGGER service not enabled in /etc/config/$NAME
log err "service not enabled in /etc/config/$NAME"
exit 1
fi

Expand Down Expand Up @@ -59,5 +61,26 @@ start_service() {
# same for stdout
procd_set_param stdout $log_stdout
procd_close_instance
}

reload_service() {
procd_send_signal $NAME
}

extra_command "reregister" "Re-register all outbound registrations"
reregister() {
MODULES=`$COMMAND -x 'module show'` || exit 1

echo "$MODULES" | grep -q -s '^res_pjsip.so' && {
log info "re-registering all outbound pjsip registrations"
$COMMAND -x 'pjsip send unregister *all' -x 'pjsip send register *all'
}
}

service_triggers() {
config_load $NAME
config_get_bool enabled general enabled 0
config_get interface general interface ""

[ $enabled -eq 1 -a -n "$interface" ] && procd_add_interface_trigger "interface.*.up" "$interface" /etc/init.d/$NAME reregister
}