Created
September 15, 2016 06:54
-
-
Save deanet/0d28a678ce7beb01bcf43ec0b9cf920f to your computer and use it in GitHub Desktop.
How to configure multiple modem PlaySMS Gammu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#convert sms3 file format to gammu file format based playsms | |
#github.com/deanet | |
tanggal=`date +%Y%m%d_%H%M%S` | |
test -f /var/spool/sms/incoming/* | |
if [ "$?" == "0" ];then | |
for sms in `ls /var/spool/sms/incoming/*`;do | |
from=`cat $sms | grep From: | tr -d "From: "` | |
sed '/\:/d;/^\s*$/d' $sms > /var/spool/gammu/inbox/IN${tanggal}_00_${from}_00.txt | |
mv $sms /var/spool/sms/incomingread/; | |
done | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to configure multiple modem PlaySMS Gammu. These are ways to works with outgoing sms (sent reports) and incoming sms (inbox reports) with multiple modem on PlaySMS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
##convert sms3 file format to gammu file format based playsms | |
##github.com/deanet | |
watch -n 10 /root/bin/convert2gammu.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# This script can be used to start/stop smsd | |
# as a daemon in Linux, Solaris, Cygwin, FreeBSD | |
# and MAC OS X Terminal window (Darwin). | |
# This script is to be used with smsd version >= 3.0.3. | |
### BEGIN INIT INFO | |
# Provides: smstools | |
# Required-Start: $syslog | |
# Required-Stop: | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts smstools | |
### END INIT INFO | |
# 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="-e" | |
ECHO=echo | |
case `uname` in | |
*BSD|Darwin) | |
PSOPT="axc" | |
;; | |
SunOS) | |
ECHO=/usr/ucb/echo | |
;; | |
esac | |
# Maximum time to stop smsd, after that it gets killed hardly: | |
MAXWAIT=45 | |
case "$1" in | |
start) | |
test -x $DAEMON || exit 0 | |
$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" | |
/usr/local/bin/playsmsd /etc/playsmsd.conf start | |
;; | |
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." | |
echo "If you are very hasty, use \"$0 force-stop\" to kill $NAME hardly (not recommended)." | |
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." | |
/usr/local/bin/playsmsd /etc/playsmsd.conf stop | |
fi | |
fi | |
;; | |
restart|reload) | |
$0 stop | |
$0 start | |
;; | |
force-stop) | |
if ps $PSOPT | grep $NAME | grep -v grep >/dev/null; then | |
echo "Killing $NAME." | |
kill -9 `ps $PSOPT | grep $NAME | grep -v grep | awk '{print $1}'` >/dev/null 2>&1 | |
fi | |
[ -f $PIDFILE ] && rm $PIDFILE | |
;; | |
reset) | |
$0 stop | |
[ -f "$RESETMODEMS" ] && "$RESETMODEMS" | |
sleep 30 | |
$0 start | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|force-stop|reset}" | |
exit 1 | |
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Global configuration | |
devices = modem6, modem7 | |
loglevel = 5 | |
# logfiles | |
stats = /var/log/sms/stats | |
logfile = /var/log/sms/smsd.log | |
# Default queue directory = /var/spool/sms | |
outgoing = /var/spool/sms/outgoing | |
checked = /var/spool/sms/checked | |
failed = /var/spool/sms/failed | |
incoming = /var/spool/sms/incoming | |
sent = /var/spool/sms/sent | |
# do not set report folder, let status report files saved in incoming | |
#report = /var/spool/sms/report | |
delaytime = 2 | |
errorsleeptime = 10 | |
blocktime = 180 | |
autosplit = 3 | |
#receive_before_send = yes | |
date_filename = number | |
# Queue configurations | |
[queues] | |
modem6 = /var/spool/sms/modem6 | |
modem7 = /var/spool/sms/modem7 | |
# Modem configurations | |
# Modem name: modem1 | |
# Modem type: Wavecom USB | |
[modem6] | |
#init = AT+CNMI=2,2,0,1,0;+CMEE=1 | |
device = /dev/ttyUSB6 | |
baudrate = 115200 | |
incoming = yes | |
report = yes | |
queues = modem6 | |
# Modem name: modem2 | |
# Modem type: Wavecom USB | |
[modem7] | |
#init = AT+CNMI=2,2,0,1,0;+CMEE=1 | |
device = /dev/ttyUSB7 | |
baudrate = 115200 | |
incoming = yes | |
report = yes | |
queues = modem7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment