From: Andreas Thienemann <[email protected]>

Offer better SMS integration for the gnokii package:

gnokii-sendsms is a ncurses/dialog based frontend to interactively send a SMS message through a supported modem. gnoki-smsd is a SMS spooling service based on gnokii. Messages dropped into a spooldir are sent automatically while incoming messages are sent to a handler script to flexibly deal with the message.

Signed-off-by: Andreas Thienemann <[email protected]>

---
utils/gnokii/Makefile | 83 +++++++++++++++++++++++++++++++++++++++++++++++-- utils/gnokii/files/sms-handler.sh | 32 ++++++++++++++++++++++++
 utils/gnokii/files/smsd.config                 |    5 +++
utils/gnokii/files/smsd.init | 31 +++++++++++++++++++++++
 utils/gnokii/patches/001-smsd-modules.patch    |   14 ++++++++++
 utils/gnokii/patches/002-libtool-destdir.patch |   12 +++++++++
 6 files changed, 174 insertions(+), 3 deletions(-)
 create mode 100644 utils/gnokii/files/sms-handler.sh
 create mode 100644 utils/gnokii/files/smsd.config
 create mode 100644 utils/gnokii/files/smsd.init
 create mode 100644 utils/gnokii/patches/001-smsd-modules.patch
 create mode 100644 utils/gnokii/patches/002-libtool-destdir.patch

diff --git a/utils/gnokii/Makefile b/utils/gnokii/Makefile
index 45f8f91..e06b418 100644
--- a/utils/gnokii/Makefile
+++ b/utils/gnokii/Makefile
@@ -21,14 +21,18 @@ PKG_BUILD_PARALLEL:=0

 include $(INCLUDE_DIR)/package.mk

-define Package/gnokii
+define Package/gnokii/Default
   SECTION:=utils
   CATEGORY:=Utilities
-  DEPENDS:=+libusb-compat
-  TITLE:=Gnokii - Datasuite for the mobile phones
   URL:=http://www.gnokii.org/
 endef

+define Package/gnokii
+  $(call Package/gnokii/Default)
+  TITLE:=Gnokii - Datasuite for the mobile phones
+  DEPENDS:=+libusb-compat
+endef
+
 define Package/gnokii/description
        Gnokii is a suite of programs linked against a backend
        library that allows communication with the phones. It
@@ -36,6 +40,28 @@ define Package/gnokii/description
        capable mobiles as well as Symbian phones.
 endef

+define Package/gnokii-sendsms
+  $(call Package/gnokii/Default)
+  TITLE:=Gnokii - Dialog based frontend for sending short messages
+  DEPENDS:=+gnokii +bash +dialog
+endef
+
+define Package/gnokii/description
+       Ncurses frontend to easily send short messages via gnokii
+endef
+
+define Package/gnokii-smsd
+  $(call Package/gnokii/Default)
+  DEPENDS:=+gnokii +glib2
+  TITLE:=Gnokii SMS Server
+endef
+
+define Package/gnokii-smsd/description
+       SMS Spooling server based on gnokii
+       Only the file backend is supported for now.
+endef
+
+
 define Build/Configure
        $(call Build/Configure/Default, \
                --without-libiconv-prefix \
@@ -53,6 +79,27 @@ define Build/Configure
                )
 endef

+define Build/Compile
+       $(call Build/Compile/gnokii)
+       $(call Build/Compile/gnokii-smsd)
+endef
+
+define Build/Compile/gnokii-smsd
+       $(MAKE) -C $(PKG_BUILD_DIR)/smsd
+endef
+
+
+define Build/Install
+       $(call Build/Install/Default)
+       $(call Build/Install/gnokii-smsd)
+endef
+
+define Build/Install/gnokii-smsd
+       $(MAKE) -C $(PKG_BUILD_DIR)/smsd \
+               DESTDIR="$(PKG_INSTALL_DIR)" \
+               install
+endef
+
 define Package/gnokii/install
        $(INSTALL_DIR) $(1)/usr/bin
        $(INSTALL_DIR) $(1)/usr/sbin
@@ -65,4 +112,34 @@ define Package/gnokii/install
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/libgnokii.so $(1)/usr/lib
 endef

+define Package/gnokii-sendsms/install
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/sendsms $(1)/usr/bin
+endef
+
+define Package/gnokii-smsd/install
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/smsd $(1)/usr/sbin
+       $(INSTALL_BIN) ./files/sms-handler.sh $(1)/usr/sbin
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/smsd.init $(1)/etc/init.d/smsd
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_CONF) ./files/smsd.config $(1)/etc/config/smsd
+       $(INSTALL_DIR) $(1)/usr/lib/smsd
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/smsd/libfile.so $(1)/usr/lib/smsd
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/smsd/libfile.la $(1)/usr/lib/smsd
+endef
+
+define Package/mrelay/prerm
+       #!/bin/sh
+       # check if we are on real system
+       if [ -z "$${IPKG_INSTROOT}" ]; then
+               echo "Removing rc.d symlink for smsd"
+               /etc/init.d/smsd disable
+       fi
+       exit 0
+endef
+
 $(eval $(call BuildPackage,gnokii))
+$(eval $(call BuildPackage,gnokii-sendsms))
+$(eval $(call BuildPackage,gnokii-smsd))
diff --git a/utils/gnokii/files/sms-handler.sh b/utils/gnokii/files/sms-handler.sh
new file mode 100644
index 0000000..d7b4359
--- /dev/null
+++ b/utils/gnokii/files/sms-handler.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Very simple SMS handler for smsd.
+# All it does is spool received messages into the incoming directory.
+#
+# This script should be adapted to local needs.
+#
+# The script will be called by smsd as
+# action number date < sms
+# where action is the scriptname, number is the sending phone number,
+# date is the sending(?) date and the text of the SMS is passed via
+# STDIN.
+#
+
+DIR=$(uci get smsd.@smsd[0].incoming)
+
+ACTION=$0
+NUMBER=$1
+DATE=$2
+CONTENT=$(cat)
+
+if [ ! -d $DIR ]; then
+       mkdir $DIR
+fi
+
+cat > ${DIR}/$(date +%s) << EOF
+Action: $ACTION
+From: $NUMBER
+Date: $DATE
+
+$CONTENT
+EOF
diff --git a/utils/gnokii/files/smsd.config b/utils/gnokii/files/smsd.config
new file mode 100644
index 0000000..1fe9fcc
--- /dev/null
+++ b/utils/gnokii/files/smsd.config
@@ -0,0 +1,5 @@
+config smsd
+       option handler '/usr/sbin/sms-handler.sh'
+       option spooldir '/tmp/sms/outgoing/'
+       option incoming '/tmp/sms/incoming/'
+       option interval 10
diff --git a/utils/gnokii/files/smsd.init b/utils/gnokii/files/smsd.init
new file mode 100644
index 0000000..08da391
--- /dev/null
+++ b/utils/gnokii/files/smsd.init
@@ -0,0 +1,31 @@
+#!/bin/sh /etc/rc.common
+
+START=98
+
+USE_PROCD=1
+NAME=smsd
+PROG=/usr/sbin/smsd
+
+start_instance() {
+       local cfg="$1"
+       local handler incoming outgoing interval
+
+       config_get handler "$cfg" handler
+       config_get incoming "$cfg" incoming
+       config_get outgoing "$cfg" outgoing
+
+       mkdir -p $incoming $outgoing
+
+       procd_open_instance
+       procd_set_param command "$PROG" -m file -u "$handler" -c "$outgoing"
+       procd_close_instance
+}
+
+start_service() {
+       config_load smsd
+       config_foreach start_instance smsd
+}
+
+stop() {
+        service_stop $PROG
+}
diff --git a/utils/gnokii/patches/001-smsd-modules.patch b/utils/gnokii/patches/001-smsd-modules.patch
new file mode 100644
index 0000000..36a3a97
--- /dev/null
+++ b/utils/gnokii/patches/001-smsd-modules.patch
@@ -0,0 +1,14 @@
+diff -up gnokii-0.6.21/smsd/Makefile.orig gnokii-0.6.21/smsd/Makefile
+--- gnokii-0.6.21/smsd/Makefile.orig 2014-03-17 15:36:42.761040741 +0100
++++ gnokii-0.6.21/smsd/Makefile        2014-03-17 15:37:21.311020495 +0100
+@@ -39,8 +39,8 @@ DB_OBJS = pq.lo mysql.lo file.lo
+
+ # A list of database modules to build.
+ # FIXME: detect which ones to build in configure
+-DB_LIBS = libfile.la libpq.la libmysql.la
+-#DB_LIBS := libfile.la
++#DB_LIBS = libfile.la libpq.la libmysql.la
++DB_LIBS := libfile.la
+
+ all: smsd
+
diff --git a/utils/gnokii/patches/002-libtool-destdir.patch b/utils/gnokii/patches/002-libtool-destdir.patch
new file mode 100644
index 0000000..bf54387
--- /dev/null
+++ b/utils/gnokii/patches/002-libtool-destdir.patch
@@ -0,0 +1,12 @@
+diff -up gnokii-0.6.21/smsd/Makefile.orig gnokii-0.6.21/smsd/Makefile
+--- gnokii-0.6.21/smsd/Makefile.orig 2014-03-18 14:48:56.235953280 +0100
++++ gnokii-0.6.21/smsd/Makefile        2014-03-18 14:49:11.072950815 +0100
+@@ -105,7 +105,7 @@ install: all
+       for f in $(DB_LIBS) ; do \
+       $(LIBTOOL) --mode=install $(INSTALL) $$f $(DESTDIR)${pkglibdir} ; \
+       done
+-      $(LIBTOOL) --mode=finish ${pkglibdir}
++      $(LIBTOOL) --mode=finish $(DESTDIR)${pkglibdir}
+       $(INSTALL) -d $(DESTDIR)$(man8dir)
+       $(INSTALL_DATA) $(SMSD_MAN) $(DESTDIR)$(man8dir)
+
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to