restund: add procd init script
[feed/telephony.git] / net / restund / Makefile
index 28537e923f74500e5351de3d8d16bf25b7d229da..fa53d2e2fc70105fd7f7c9208248cb8c0bf20d34 100644 (file)
@@ -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
@@ -78,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