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

baresip: Use UCI for basic service configuration #889

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions net/baresip/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ define Package/baresip/install
$(1)/usr/lib/baresip/modules \
$(1)/usr/share/baresip \
$(1)/etc/baresip \
$(1)/etc/init.d \
$(1)/etc/default
$(1)/etc/uci-defaults \
$(1)/etc/init.d
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/baresip $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/libbaresip.so* $(1)/usr/lib
$(INSTALL_DATA) \
Expand All @@ -137,15 +137,14 @@ define Package/baresip/install
$(SED) '/^#/!s/^/#/' $(PKG_BUILD_DIR)/docs/examples/accounts
$(SED) '/^#module_path/s|^#||;s|/local||' $(PKG_BUILD_DIR)/docs/examples/config
$(INSTALL_DATA) $(PKG_BUILD_DIR)/docs/examples/{accounts,config,contacts} $(1)/etc/baresip
$(INSTALL_CONF) ./files/baresip.default $(1)/etc/default/baresip
$(INSTALL_DATA) ./files/baresip.defaults $(1)/etc/uci-defaults/90-baresip
$(INSTALL_BIN) ./files/baresip.init $(1)/etc/init.d/baresip
endef

define Package/baresip/conffiles
/etc/baresip/accounts
/etc/baresip/config
/etc/baresip/contacts
/etc/default/baresip
endef

##################
Expand Down
10 changes: 0 additions & 10 deletions net/baresip/files/baresip.default

This file was deleted.

12 changes: 12 additions & 0 deletions net/baresip/files/baresip.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CFGFILE=/etc/config/baresip

if [ ! -f "$CFGFILE" ]; then
cat >$CFGFILE <<EOF
config baresip main
option enable 0
option options ''
EOF
fi

chown -R baresip:baresip /etc/baresip

45 changes: 17 additions & 28 deletions net/baresip/files/baresip.init
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,27 @@
# Copyright (C) 2017 OpenWrt.org

START=92

USE_PROCD=1
PROG=/usr/bin/baresip

#PROCD_DEBUG=1

DAEMON=baresip
DEFAULT=/etc/default/$DAEMON
LOGGER="/usr/bin/logger -p user.err -s -t $DAEMON"
OPTIONS=
PROG=/usr/bin/$DAEMON
start_service()
{
local enable options

[ -f $DEFAULT ] && . $DEFAULT
uci_validate_section baresip baresip main \
'enable:bool:0' \
'options:string'

start_service() {
local dir=
[ "$enable" = "0" ] && return

if [ "$ENABLE_BARESIP" != yes ]; then
$LOGGER User configuration incomplete - not starting $DAEMON
$LOGGER Check ENABLE_BARESIP in $DEFAULT
return 1
fi
procd_open_instance
procd_set_param command $PROG -f /etc/baresip $options
procd_set_param user baresip
procd_set_param respawn
procd_close_instance
}

procd_open_instance
procd_set_param command $PROG
procd_append_param command \
-f /etc/$DAEMON \
$OPTIONS
procd_set_param pidfile /var/run/${DAEMON}.pid
# forward stderr to logd
procd_set_param stderr 1
# forward stdout to logd
#procd_set_param stdout 1
procd_set_param user $DAEMON
procd_close_instance
service_triggers()
{
procd_add_reload_trigger baresip
}
Loading