Merge pull request #230 from micmac1/baresip

New PR: Baresip suite
This commit is contained in:
Jiri Slachta 2017-12-27 09:44:23 +01:00 committed by GitHub
commit b36dc4abc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 253 additions and 52 deletions

View File

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=re
PKG_VERSION:=0.5.6
PKG_RELEASE:=3
PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.creytiv.com/pub
@ -45,16 +45,21 @@ endef
# LD is changed to TARGET_CC to fix build failures on x86 32bit. Without this
# there's no linking to ssp, which results in undefined references.
# used by 001-extend-ninit-nclose-check.patch
TARGET_CFLAGS+=-DOPENWRT
ifneq ($(CONFIG_USE_GLIBC)$(CONFIG_USE_MUSL),)
TARGET_CFLAGS+=-D_GNU_SOURCE
endif
MAKE_FLAGS+= \
CROSS_COMPILE="$(TARGET_CROSS)" \
EXTRA_LFLAGS="$(TARGET_LDFLAGS)" \
LD="$(TARGET_CC)" \
OS=linux \
RELEASE=1 \
SYSROOT="$(shell $(FIND) $(TOOLCHAIN_DIR) -path '*/include/pthread.h' | sed -ne '1s|/include/pthread.h||p')" \
SYSROOT_ALT="$(STAGING_DIR)/usr" \
RELEASE=1
SYSROOT_ALT="$(STAGING_DIR)/usr"
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/share/re

View File

@ -34,14 +34,16 @@ define Package/librem
endef
MAKE_FLAGS+= \
CROSS_COMPILE="$(TARGET_CROSS)" \
EXTRA_LFLAGS="$(TARGET_LDFLAGS)" \
LD="$(TARGET_CC)" \
LIBRE_MK="$(STAGING_DIR)/usr/share/re/re.mk" \
LIBRE_INC="$(STAGING_DIR)/usr/include/re" \
LIBRE_SO="$(STAGING_DIR)/usr/lib" \
OS=linux \
RELEASE=1 \
SYSROOT="$(shell $(FIND) $(TOOLCHAIN_DIR) -path '*/include/pthread.h' | sed -ne '1s|/include/pthread.h||p')" \
SYSROOT_ALT="$(STAGING_DIR)/usr" \
RELEASE=1
SYSROOT_ALT="$(STAGING_DIR)/usr"
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include

View File

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=baresip
PKG_VERSION:=0.5.6
PKG_RELEASE:=4
PKG_RELEASE:=5
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.creytiv.com/pub
@ -65,6 +65,7 @@ define Package/baresip
$(call Package/baresip/Default)
TITLE:=Portable and modular SIP User-Agent with A/V support
DEPENDS:=+libre +librem
USERID:=$(PKG_NAME)=374:$(PKG_NAME)=374
MENU:=1
endef
@ -96,15 +97,17 @@ BARESIP_MOD_OPTIONS:= \
$(foreach m,$(baresip-mods),$(baresip-mod-$(m))=$(if $(CONFIG_PACKAGE_baresip-mod-$(m)),1))
MAKE_FLAGS+= \
CROSS_COMPILE="$(TARGET_CROSS)" \
EXTRA_LFLAGS="$(TARGET_LDFLAGS)" \
LD="$(TARGET_CC)" \
LIBRE_MK="$(STAGING_DIR)/usr/share/re/re.mk" \
LIBRE_INC="$(STAGING_DIR)/usr/include/re" \
LIBRE_SO="$(STAGING_DIR)/usr/lib" \
LIBREM_PATH="$(STAGING_DIR)/usr" \
OS=linux \
RELEASE=1 \
SYSROOT="$(shell $(FIND) $(TOOLCHAIN_DIR) -path '*/include/pthread.h' | sed -ne '1s|/include/pthread.h||p')" \
SYSROOT_ALT="$(STAGING_DIR)/usr" \
RELEASE=1 \
$(BARESIP_MOD_OPTIONS)
TARGET_CFLAGS+=-D_GNU_SOURCE
@ -118,10 +121,38 @@ define Package/baresip/install
$(1)/usr/lib/baresip/modules
$(INSTALL_DIR) $(1)/usr/share/baresip
$(CP) $(PKG_INSTALL_DIR)/usr/share/baresip/* $(1)/usr/share/baresip
$(INSTALL_DIR) $(1)/etc/baresip
$(INSTALL_CONF) $(PKG_BUILD_DIR)/docs/examples/{accounts,config,contacts} $(1)/etc/baresip
$(INSTALL_DIR) $(1)/etc/default
$(INSTALL_CONF) ./files/baresip.default $(1)/etc/default/baresip
$(INSTALL_DIR) $(1)/etc/init.d
$(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
/etc/init.d/baresip
endef
define Package/baresip/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
chown $(PKG_NAME):$(PKG_NAME) \
/etc/baresip/accounts \
/etc/baresip/config \
/etc/baresip/contacts
# Prevent $(PKG_NAME) from auto-starting after an upgrade. The modules may
# not be upgraded yet and the user configuration may need a revision.
sed -i '/^ENABLE_BARESIP="yes"/s/^/#/' \
/etc/default/$(PKG_NAME)
fi
exit 0
endef
##################
# bareSIP modules
# 1. Name

View File

@ -0,0 +1,10 @@
### bareSIP init configuration ###
# Uncomment once you verified your configuration, otherwise the init script will
# not start bareSIP.
#ENABLE_BARESIP="yes"
# The following is added to the command line when starting bareSIP:
OPTIONS=""
# The configuration for the daemon is done in /etc/baresip!

View File

@ -1,14 +1,91 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2010-2011 OpenWrt.org
# Copyright (C) 2010 Alfred E. Heggestad
#
# Copyright (C) 2017 OpenWrt.org
START=92
start() {
service_start /usr/bin/baresip -d
USE_PROCD=1
#PROCD_DEBUG=1
DAEMON=baresip
DEFAULT=/etc/default/$DAEMON
LOGGER="/usr/bin/logger -p user.err -s -t $DAEMON"
OPTIONS=
PROG=/usr/bin/$DAEMON
TIMEOUT=30
[ -f $DEFAULT ] && . $DEFAULT
start_service() {
local dir=
if [ "$ENABLE_BARESIP" != yes ]; then
$LOGGER User configuration incomplete - not starting $DAEMON
$LOGGER Check ENABLE_BARESIP in $DEFAULT
exit 1
fi
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
}
stop() {
service_stop /usr/bin/baresip
stop_service() {
local retval=
local mypid=
local timeout=$TIMEOUT
pgrep $DAEMON &> /dev/null
[ $? -ne 0 ] && exit 0
[ -f /var/run/${DAEMON}.pid ]
retval=$?
# init script could find itself in a scenario where baresip was started
# very recently, so make it wait a while for a pid file to appear
while [ $retval -ne 0 -a $timeout -gt 0 ]; do
sleep 1
[ -f /var/run/${DAEMON}.pid ]
retval=$?
timeout=$(($timeout-1))
done
[ $retval -eq 0 ] || {
$LOGGER PID file does not exist
exit 1
}
mypid=$(cat /var/run/${DAEMON}.pid)
[ "$mypid" -gt 1 ] 2> /dev/null || {
$LOGGER PID file contains garbage
exit 1
}
timeout=$TIMEOUT
kill $mypid 2>/dev/null
pgrep $DAEMON | grep -w $mypid &>/dev/null
retval=$?
while [ $retval -eq 0 -a $timeout -gt 0 ]; do
sleep 10
pgrep $DAEMON | grep -w $mypid &>/dev/null
retval=$?
[ $retval -eq 0 ] && kill $mypid 2>/dev/null
timeout=$(($timeout-10))
done
[ $retval -ne 1 ] && {
$LOGGER Failed to stop $DAEMON
exit 1
}
}

View File

@ -1,14 +0,0 @@
--- a/Makefile
+++ b/Makefile
@@ -199,9 +199,9 @@ libbaresip.pc:
$(BIN): $(APP_OBJS)
@echo " LD $@"
ifneq ($(GPROF),)
- $(HIDE)$(LD) $(LFLAGS) $(APP_LFLAGS) $^ ../re/libre.a $(LIBS) -o $@
+ $(HIDE)$(LD) $(LFLAGS) $(SH_LFLAGS) $(APP_LFLAGS) $^ ../re/libre.a $(LIBS) -o $@
else
- $(HIDE)$(LD) $(LFLAGS) $(APP_LFLAGS) $^ \
+ $(HIDE)$(LD) $(LFLAGS) $(SH_LFLAGS) $(APP_LFLAGS) $^ \
-L$(LIBRE_SO) -lre $(LIBS) -o $@
endif

View File

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=restund
PKG_VERSION:=0.4.12
PKG_RELEASE:=4
PKG_RELEASE:=5
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.creytiv.com/pub
@ -39,6 +39,7 @@ define Package/restund
$(call Package/restund/Default)
TITLE:=Modular STUN/TURN server
DEPENDS:=+libre
USERID:=$(PKG_NAME)=373:$(PKG_NAME)=373
endef
restund-mod-mysql:=USE_MYSQL
@ -47,14 +48,16 @@ RESTUND_MOD_OPTIONS:= \
$(foreach m,$(restund-mods),$(restund-mod-$(m))=$(if $(CONFIG_PACKAGE_restund-mod-$(m)),1))
MAKE_FLAGS+= \
CROSS_COMPILE="$(TARGET_CROSS)" \
EXTRA_LFLAGS="$(TARGET_LDFLAGS)" \
LD="$(TARGET_CC)" \
LIBRE_MK="$(STAGING_DIR)/usr/share/re/re.mk" \
LIBRE_INC="$(STAGING_DIR)/usr/include/re" \
LIBRE_SO="$(STAGING_DIR)/usr/lib" \
OS=linux \
RELEASE=1 \
SYSROOT="$(shell $(FIND) $(TOOLCHAIN_DIR) -path '*/include/pthread.h' | sed -ne '1s|/include/pthread.h||p')" \
SYSROOT_ALT="$(STAGING_DIR)/usr" \
RELEASE=1 \
$(RESTUND_MOD_OPTIONS)
define Package/restund/install
@ -76,14 +79,31 @@ define Package/restund/install
$(SED) \
's|^\(module_path\)\([ \t]\+\).*$$$$|\1\2/usr/lib/restund/modules|g' \
$(1)/etc/restund.conf
$(INSTALL_DIR) $(1)/etc/default
$(INSTALL_CONF) ./files/restund.default $(1)/etc/default/restund
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/restund.init $(1)/etc/init.d/restund
endef
define Package/restund/conffiles
/etc/default/restund
/etc/init.d/restund
/etc/restund.conf
endef
define Package/restund/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
chown $(PKG_NAME):$(PKG_NAME) /etc/restund.conf
# Prevent $(PKG_NAME) from auto-starting after an upgrade. The modules may
# not be upgraded yet and the user configuration may need a revision.
sed -i '/^ENABLE_RESTUND="yes"/s/^/#/' \
/etc/default/$(PKG_NAME)
fi
exit 0
endef
#
# 1. Name
# 2. Title

View File

@ -0,0 +1,8 @@
### restund init configuration ###
# Uncomment once you verified your configuration, otherwise the init script will
# not start restund.
#ENABLE_RESTUND="yes"
# The following is added to the command line when starting restund:
OPTIONS=""

View File

@ -1,15 +1,91 @@
#!/bin/sh /etc/rc.common
#
# Copyright (C) 2010-2011 OpenWrt.org
# Copyright (C) 2010 Alfred E. Heggestad
#
# Copyright (C) 2017 OpenWrt.org
START=60
start() {
service_start /usr/sbin/restund
USE_PROCD=1
#PROCD_DEBUG=1
DAEMON=restund
DEFAULT=/etc/default/$DAEMON
LOGGER="/usr/bin/logger -p user.err -s -t $DAEMON"
OPTIONS=
PROG=/usr/sbin/$DAEMON
TIMEOUT=30
[ -f $DEFAULT ] && . $DEFAULT
start_service() {
local dir=
if [ "$ENABLE_RESTUND" != yes ]; then
$LOGGER User configuration incomplete - not starting $DAEMON
$LOGGER Check ENABLE_RESTUND in $DEFAULT
exit 1
fi
procd_open_instance
procd_set_param command $PROG
procd_append_param command \
-n \
$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
}
stop() {
service_stop /usr/sbin/restund
stop_service() {
local retval=
local mypid=
local timeout=$TIMEOUT
pgrep $DAEMON &> /dev/null
[ $? -ne 0 ] && exit 0
[ -f /var/run/${DAEMON}.pid ]
retval=$?
# init script could find itself in a scenario where restund was started
# very recently, so make it wait a while for a pid file to appear
while [ $retval -ne 0 -a $timeout -gt 0 ]; do
sleep 1
[ -f /var/run/${DAEMON}.pid ]
retval=$?
timeout=$(($timeout-1))
done
[ $retval -eq 0 ] || {
$LOGGER PID file does not exist
exit 1
}
mypid=$(cat /var/run/${DAEMON}.pid)
[ "$mypid" -gt 1 ] 2> /dev/null || {
$LOGGER PID file contains garbage
exit 1
}
timeout=$TIMEOUT
kill $mypid 2>/dev/null
pgrep $DAEMON | grep -w $mypid &>/dev/null
retval=$?
while [ $retval -eq 0 -a $timeout -gt 0 ]; do
sleep 10
pgrep $DAEMON | grep -w $mypid &>/dev/null
retval=$?
[ $retval -eq 0 ] && kill $mypid 2>/dev/null
timeout=$(($timeout-10))
done
[ $retval -ne 1 ] && {
$LOGGER Failed to stop $DAEMON
exit 1
}
}

View File

@ -1,14 +0,0 @@
--- a/Makefile
+++ b/Makefile
@@ -99,9 +99,9 @@ all: $(MOD_BINS) $(BIN)
$(BIN): $(OBJS)
@echo " LD $@"
ifneq ($(GPROF),)
- @$(LD) $(LFLAGS) $(APP_LFLAGS) $^ ../re/libre.a $(LIBS) -o $@
+ @$(LD) $(LFLAGS) $(SH_LFLAGS) $(APP_LFLAGS) $^ ../re/libre.a $(LIBS) -o $@
else
- @$(LD) $(LFLAGS) $(APP_LFLAGS) $^ -L$(LIBRE_SO) -lre $(LIBS) -o $@
+ @$(LD) $(LFLAGS) $(SH_LFLAGS) $(APP_LFLAGS) $^ -L$(LIBRE_SO) -lre $(LIBS) -o $@
endif
$(BUILD)/%.o: %.c $(BUILD) Makefile $(APP_MK)