Browse Source

Merge pull request #694 from erdoukki/master

smstools3 : ADD smstools3 package
Steven Barth 10 years ago
parent
commit
916c7377a0

+ 74
- 0
utils/smstools3/Makefile View File

@@ -0,0 +1,74 @@
1
+#
2
+# Copyright (C) 2014 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=smstools3
11
+PKG_VERSION:=3.1.15
12
+PKG_RELEASE:=1
13
+
14
+PKG_MAINTAINER:=Gérald Kerma <dreagle@doukki.net>
15
+PKG_LICENSE:=GPL-2.0
16
+PKG_LICENSE_FILES:=LICENSE
17
+
18
+PKG_BUILD_PARALLEL:=0
19
+
20
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
21
+PKG_SOURCE_URL:=http://smstools3.kekekasvi.com/packages/
22
+PKG_MD5SUM:=0241ef60e646fac1a06254a848e61ed7
23
+
24
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
25
+PKG_BUILD_DEPENDS:=libiconv-full iconv socket nsl
26
+
27
+include $(INCLUDE_DIR)/package.mk
28
+
29
+define Package/smstools3
30
+  SECTION:=utils
31
+  CATEGORY:=Utilities
32
+  TITLE:=SMS Server Tools 3
33
+  DEPENDS:=+libiconv-full +iconv
34
+  URL:=http://smstools3.kekekasvi.com/
35
+endef
36
+
37
+define Package/smstools3/description
38
+ The SMS Server Tools 3 is a SMS Gateway software which can send and receive
39
+ short messages through GSM modems and mobile phones.
40
+endef
41
+
42
+TARGET_CFLAGS = -D NUMBER_OF_MODEMS=1
43
+TARGET_CFLAGS += -D USE_ICONV
44
+TARGET_CFLAGS += -D DISABLE_INET_SOCKET
45
+TARGET_CFLAGS += -W -Wall
46
+TARGET_CFLAGS += -D_FILE_OFFSET_BITS=64
47
+
48
+TARGET_LDFLAGS += -liconv
49
+
50
+BINDIR=/usr/local/bin
51
+
52
+define Build/Compile
53
+	$(MAKE) -C "$(PKG_BUILD_DIR)"/src \
54
+		CC="$(TARGET_CC)" \
55
+		USER_CFLAGS='$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS) \
56
+		-I"$(STAGING_DIR)/usr/lib/libiconv-full/include"' \
57
+		USER_LDFLAGS='$(TARGET_LFLAGS) $(EXTRA_LDFLAGS) -L"$(STAGING_DIR)/usr/lib/libiconv-full/lib"' \
58
+		all
59
+endef
60
+
61
+define Package/smstools3/install
62
+	$(INSTALL_DIR) $(1)/$(BINDIR)
63
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/smsd $(1)/$(BINDIR)/smsd
64
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/sendsms $(1)/$(BINDIR)/sendsms
65
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/sms2html $(1)/$(BINDIR)/sms2html
66
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/sms2unicode $(1)/$(BINDIR)/sms2unicode
67
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/unicode2sms $(1)/$(BINDIR)/unicode2sms
68
+	$(INSTALL_DIR) $(1)/etc/init.d
69
+	$(INSTALL_DATA) -m 0755 ./files/smstools3.init $(1)/etc/init.d/smstools3
70
+	$(INSTALL_DIR) $(1)/etc
71
+	$(INSTALL_DATA) -m 0755 ./files/smstools3.conf $(1)/etc/smsd.conf
72
+endef
73
+
74
+$(eval $(call BuildPackage,smstools3))

+ 20
- 0
utils/smstools3/files/smstools3.conf View File

@@ -0,0 +1,20 @@
1
+#
2
+# Description: Main configuration file for the smsd
3
+#
4
+
5
+devices = GSM1
6
+incoming = /var/spool/sms/incoming
7
+outgoing = /var/spool/sms/outgoing
8
+checked = /var/spool/sms/checked
9
+failed = /var/spool/sms/failed
10
+sent = /var/spool/sms/sent
11
+receive_before_send = no
12
+autosplit = 3
13
+
14
+[GSM1]
15
+init = AT+CPMS="ME","ME","ME"
16
+device = /dev/ttyUSB0
17
+incoming = yes
18
+pin = 0000
19
+baudrate = 9600
20
+

+ 152
- 0
utils/smstools3/files/smstools3.init View File

@@ -0,0 +1,152 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2014 OpenWrt.org
3
+# smsd initscript openwrt mod
4
+
5
+START=99
6
+STOP=99
7
+
8
+EXTRA_COMMANDS="status"
9
+EXTRA_HELP="        status  View pid and service status "
10
+
11
+# Set USER and GROUP, if necessary:
12
+USER=""
13
+GROUP=""
14
+
15
+# If an unpriviledged user is selected, make sure that next two
16
+# files are writable by that user:
17
+PIDFILE="/var/run/smsd.pid"
18
+INFOFILE="/var/run/smsd.working"
19
+# Logfile can also be defined in here:
20
+LOGFILE="/var/log/smsd.log"
21
+
22
+DAEMON=/usr/local/bin/smsd
23
+# A program which turns power off for couple of seconds:
24
+RESETMODEMS=/usr/local/bin/smsd_resetmodems
25
+NAME=smsd
26
+PSOPT=""
27
+
28
+# Set/edit this before starting service !!!!!
29
+WRT_SPOOL=/var/spool
30
+
31
+# Maximum time to stop smsd, after that it gets killed hardly:
32
+MAXWAIT=45
33
+
34
+boot() {
35
+	start
36
+}
37
+
38
+start() {
39
+	test -x $DAEMON || exit 0
40
+
41
+	echo "Creating minimum spool directories"
42
+	mkdir -p $WRT_SPOOL
43
+	mkdir -p $WRT_SPOOL/sms
44
+	mkdir -p $WRT_SPOOL/sms/incoming
45
+	mkdir -p $WRT_SPOOL/sms/outgoing
46
+	mkdir -p $WRT_SPOOL/sms/checked
47
+	mkdir -p $WRT_SPOOL/sms/failed
48
+	mkdir -p $WRT_SPOOL/sms/sent
49
+
50
+	echo -n "Starting SMS Daemon: "
51
+	MSG="."
52
+	ARGS="-n MAINPROCESS -p$PIDFILE -i$INFOFILE"
53
+	[ "x$USER" != x ] && ARGS="$ARGS -u$USER"
54
+	[ "x$GROUP" != x ] && ARGS="$ARGS -g$GROUP"
55
+	[ "x$LOGFILE" != x ] && ARGS="$ARGS -l$LOGFILE"
56
+	PID=`cat $PIDFILE 2>/dev/null`
57
+	if [ "x$PID" != x ]; then
58
+	  if kill -0 $PID 2>/dev/null; then
59
+	    MSG=" already running ($PID)."
60
+	  else
61
+	    PID=""
62
+	  fi
63
+	fi
64
+	if [ "x$PID" = x ]; then
65
+	  if ps $PSOPT | grep $NAME | grep -v grep >/dev/null; then
66
+	    MSG=" already running."
67
+	  else
68
+	    $DAEMON $ARGS
69
+	    sleep 1
70
+	    PIDS=`ps $PSOPT | grep $NAME | grep -v grep`
71
+	    [ "x$PIDS" = x ] && MSG=" failed."
72
+	  fi
73
+	fi
74
+	echo "$NAME$MSG"
75
+}
76
+
77
+stop() {
78
+	if ps $PSOPT | grep $NAME | grep -v grep >/dev/null; then
79
+	  PID=`cat $PIDFILE 2>/dev/null`
80
+	  if [ "x$PID" != x ]; then
81
+	    P=`kill -0 $PID 2>/dev/null`
82
+	    [ "x$P" != x ] && PID=""
83
+	  fi
84
+	  if [ "x$PID" != x ]; then
85
+	    kill $PID
86
+	  else
87
+	    kill `ps $PSOPT | grep $NAME | grep -v grep | awk '{print $1}'` >/dev/null 2>&1
88
+	  fi
89
+	  sleep 1
90
+	  if ps $PSOPT | grep $NAME | grep -v grep >/dev/null; then
91
+	    echo "Allowing $NAME to terminate gracefully within $MAXWAIT seconds"
92
+	    infofound=0
93
+	    dots=0
94
+	    seconds=0
95
+	    while ps $PSOPT | grep $NAME | grep -v grep >/dev/null; do
96
+	      if [ $infofound -lt 1 ]; then
97
+	        if [ -f $INFOFILE ]; then
98
+	          infofound=1
99
+	          if [ $dots -gt 0 ]; then
100
+	            echo ""
101
+	            dots=0
102
+	          fi
103
+	          $ECHO -n "$NAME is currently "
104
+	          cat $INFOFILE
105
+	          echo "Time counting is now disabled and we will wait until this job is complete."
106
+	        fi
107
+	      fi
108
+	      [ $infofound -lt 1 ] && seconds=`expr $seconds + 1`
109
+	      echo -n "."
110
+	      dots=`expr $dots + 1`
111
+	      if [ "$seconds" -ge $MAXWAIT ]; then
112
+	        if [ $dots -gt 0 ]; then
113
+	          echo ""
114
+	          dots=0
115
+	        fi
116
+	        echo "Timeout occured, killing $NAME hardly."
117
+	        kill -9 `ps $PSOPT | grep $NAME | grep -v grep | awk '{print $1}'` >/dev/null 2>&1
118
+	        [ -f $PIDFILE ] && rm $PIDFILE
119
+	        seconds=0
120
+	      fi
121
+	      sleep 1
122
+	    done
123
+	    [ $dots -gt 0 ] && echo ""
124
+	    #echo "$NAME is stopped."
125
+	  fi
126
+	fi
127
+}
128
+
129
+restart() {
130
+	stop
131
+	start
132
+}
133
+
134
+
135
+status() {
136
+	PID=$(cat $PIDFILE)
137
+
138
+	test -e $PIDFILE
139
+	if [ $? == 0 ]; then
140
+		echo $NAME " running! pid $PID"
141
+	else
142
+		echo $NAME " not running !!!"
143
+	fi
144
+}
145
+
146
+reset() {
147
+	$0 stop
148
+	[ -f "$RESETMODEMS" ] && "$RESETMODEMS"
149
+	sleep 30
150
+	$0 start
151
+}
152
+

+ 13
- 0
utils/smstools3/patches/001-smsd.patch View File

@@ -0,0 +1,13 @@
1
+--- a/src/smsd.c	2010-09-21 13:47:48.000000000 +0300
2
++++ b/src/smsd.c	2013-03-05 05:26:26.000000000 +0300
3
+@@ -5200,8 +5200,8 @@
4
+ 	int result = 1;
5
+ 	char *cmd;
6
+ 	char *p;
7
+-	char answer[500];
8
+-	char buffer[600];
9
++	char answer[1024];
10
++	char buffer[1024];
11
+ 	int fd;
12
+ 	int log_retry = 3;
13
+ 	int i;

+ 12
- 0
utils/smstools3/patches/002-Makefile.patch View File

@@ -0,0 +1,12 @@
1
+--- a/src/Makefile	2014-12-20 18:33:55.654252867 +0100
2
++++ b/src/Makefile	2014-12-20 18:31:10.241359741 +0100
3
+@@ -43,7 +43,7 @@
4
+ 
5
+ ifneq (,$(findstring SOLARIS,$(CFLAGS)))
6
+ ifeq (,$(findstring DISABLE_INET_SOCKET,$(CFLAGS)))
7
+-override LFLAGS += -lsocket -lnsl
8
++	override LFLAGS += -lsocket -lnsl
9
+ endif
10
+ endif
11
+ 
12
+