Browse Source

Merge pull request #694 from erdoukki/master

smstools3 : ADD smstools3 package
lilik-openwrt-22.03
Steven Barth 10 years ago
parent
commit
916c7377a0
5 changed files with 271 additions and 0 deletions
  1. +74
    -0
      utils/smstools3/Makefile
  2. +20
    -0
      utils/smstools3/files/smstools3.conf
  3. +152
    -0
      utils/smstools3/files/smstools3.init
  4. +13
    -0
      utils/smstools3/patches/001-smsd.patch
  5. +12
    -0
      utils/smstools3/patches/002-Makefile.patch

+ 74
- 0
utils/smstools3/Makefile View File

@ -0,0 +1,74 @@
#
# Copyright (C) 2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=smstools3
PKG_VERSION:=3.1.15
PKG_RELEASE:=1
PKG_MAINTAINER:=Gérald Kerma <dreagle@doukki.net>
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_PARALLEL:=0
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://smstools3.kekekasvi.com/packages/
PKG_MD5SUM:=0241ef60e646fac1a06254a848e61ed7
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
PKG_BUILD_DEPENDS:=libiconv-full iconv socket nsl
include $(INCLUDE_DIR)/package.mk
define Package/smstools3
SECTION:=utils
CATEGORY:=Utilities
TITLE:=SMS Server Tools 3
DEPENDS:=+libiconv-full +iconv
URL:=http://smstools3.kekekasvi.com/
endef
define Package/smstools3/description
The SMS Server Tools 3 is a SMS Gateway software which can send and receive
short messages through GSM modems and mobile phones.
endef
TARGET_CFLAGS = -D NUMBER_OF_MODEMS=1
TARGET_CFLAGS += -D USE_ICONV
TARGET_CFLAGS += -D DISABLE_INET_SOCKET
TARGET_CFLAGS += -W -Wall
TARGET_CFLAGS += -D_FILE_OFFSET_BITS=64
TARGET_LDFLAGS += -liconv
BINDIR=/usr/local/bin
define Build/Compile
$(MAKE) -C "$(PKG_BUILD_DIR)"/src \
CC="$(TARGET_CC)" \
USER_CFLAGS='$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS) \
-I"$(STAGING_DIR)/usr/lib/libiconv-full/include"' \
USER_LDFLAGS='$(TARGET_LFLAGS) $(EXTRA_LDFLAGS) -L"$(STAGING_DIR)/usr/lib/libiconv-full/lib"' \
all
endef
define Package/smstools3/install
$(INSTALL_DIR) $(1)/$(BINDIR)
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/smsd $(1)/$(BINDIR)/smsd
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/sendsms $(1)/$(BINDIR)/sendsms
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/sms2html $(1)/$(BINDIR)/sms2html
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/sms2unicode $(1)/$(BINDIR)/sms2unicode
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/unicode2sms $(1)/$(BINDIR)/unicode2sms
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DATA) -m 0755 ./files/smstools3.init $(1)/etc/init.d/smstools3
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DATA) -m 0755 ./files/smstools3.conf $(1)/etc/smsd.conf
endef
$(eval $(call BuildPackage,smstools3))

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

@ -0,0 +1,20 @@
#
# Description: Main configuration file for the smsd
#
devices = GSM1
incoming = /var/spool/sms/incoming
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
failed = /var/spool/sms/failed
sent = /var/spool/sms/sent
receive_before_send = no
autosplit = 3
[GSM1]
init = AT+CPMS="ME","ME","ME"
device = /dev/ttyUSB0
incoming = yes
pin = 0000
baudrate = 9600

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

@ -0,0 +1,152 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2014 OpenWrt.org
# smsd initscript openwrt mod
START=99
STOP=99
EXTRA_COMMANDS="status"
EXTRA_HELP=" status View pid and service status "
# Set USER and GROUP, if necessary:
USER=""
GROUP=""
# If an unpriviledged user is selected, make sure that next two
# files are writable by that user:
PIDFILE="/var/run/smsd.pid"
INFOFILE="/var/run/smsd.working"
# Logfile can also be defined in here:
LOGFILE="/var/log/smsd.log"
DAEMON=/usr/local/bin/smsd
# A program which turns power off for couple of seconds:
RESETMODEMS=/usr/local/bin/smsd_resetmodems
NAME=smsd
PSOPT=""
# Set/edit this before starting service !!!!!
WRT_SPOOL=/var/spool
# Maximum time to stop smsd, after that it gets killed hardly:
MAXWAIT=45
boot() {
start
}
start() {
test -x $DAEMON || exit 0
echo "Creating minimum spool directories"
mkdir -p $WRT_SPOOL
mkdir -p $WRT_SPOOL/sms
mkdir -p $WRT_SPOOL/sms/incoming
mkdir -p $WRT_SPOOL/sms/outgoing
mkdir -p $WRT_SPOOL/sms/checked
mkdir -p $WRT_SPOOL/sms/failed
mkdir -p $WRT_SPOOL/sms/sent
echo -n "Starting SMS Daemon: "
MSG="."
ARGS="-n MAINPROCESS -p$PIDFILE -i$INFOFILE"
[ "x$USER" != x ] && ARGS="$ARGS -u$USER"
[ "x$GROUP" != x ] && ARGS="$ARGS -g$GROUP"
[ "x$LOGFILE" != x ] && ARGS="$ARGS -l$LOGFILE"
PID=`cat $PIDFILE 2>/dev/null`
if [ "x$PID" != x ]; then
if kill -0 $PID 2>/dev/null; then
MSG=" already running ($PID)."
else
PID=""
fi
fi
if [ "x$PID" = x ]; then
if ps $PSOPT | grep $NAME | grep -v grep >/dev/null; then
MSG=" already running."
else
$DAEMON $ARGS
sleep 1
PIDS=`ps $PSOPT | grep $NAME | grep -v grep`
[ "x$PIDS" = x ] && MSG=" failed."
fi
fi
echo "$NAME$MSG"
}
stop() {
if ps $PSOPT | grep $NAME | grep -v grep >/dev/null; then
PID=`cat $PIDFILE 2>/dev/null`
if [ "x$PID" != x ]; then
P=`kill -0 $PID 2>/dev/null`
[ "x$P" != x ] && PID=""
fi
if [ "x$PID" != x ]; then
kill $PID
else
kill `ps $PSOPT | grep $NAME | grep -v grep | awk '{print $1}'` >/dev/null 2>&1
fi
sleep 1
if ps $PSOPT | grep $NAME | grep -v grep >/dev/null; then
echo "Allowing $NAME to terminate gracefully within $MAXWAIT seconds"
infofound=0
dots=0
seconds=0
while ps $PSOPT | grep $NAME | grep -v grep >/dev/null; do
if [ $infofound -lt 1 ]; then
if [ -f $INFOFILE ]; then
infofound=1
if [ $dots -gt 0 ]; then
echo ""
dots=0
fi
$ECHO -n "$NAME is currently "
cat $INFOFILE
echo "Time counting is now disabled and we will wait until this job is complete."
fi
fi
[ $infofound -lt 1 ] && seconds=`expr $seconds + 1`
echo -n "."
dots=`expr $dots + 1`
if [ "$seconds" -ge $MAXWAIT ]; then
if [ $dots -gt 0 ]; then
echo ""
dots=0
fi
echo "Timeout occured, killing $NAME hardly."
kill -9 `ps $PSOPT | grep $NAME | grep -v grep | awk '{print $1}'` >/dev/null 2>&1
[ -f $PIDFILE ] && rm $PIDFILE
seconds=0
fi
sleep 1
done
[ $dots -gt 0 ] && echo ""
#echo "$NAME is stopped."
fi
fi
}
restart() {
stop
start
}
status() {
PID=$(cat $PIDFILE)
test -e $PIDFILE
if [ $? == 0 ]; then
echo $NAME " running! pid $PID"
else
echo $NAME " not running !!!"
fi
}
reset() {
$0 stop
[ -f "$RESETMODEMS" ] && "$RESETMODEMS"
sleep 30
$0 start
}

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

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

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

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

Loading…
Cancel
Save