eSMSd¶
eSMSd is a simple GPL replacement for Gnokii's SMS daemon smsd. All it does is:
- reads incoming SMS from mobile phone and stores them into database
- sends SMS that are in database outbox using the phone
You can download it using git:
git clone http://repos.e-x-a.org/esmsd.git
Dependencies:¶
- MySQL with a command line client (can be easily tuned for any other SQL)
- Gnokii installation with working --sendsms and --getsms commands
- bash, awk, sed, logger and mktemp utility (you already have those)
Benefits over official Gnokii SMSd are:¶
- everything is done in simple and very configurable manner using only ~200line bash script. This adds much space for easy hacking etc.
- no pthread/mutex hangs, no segfaults (which smsd sometimes produces on 64bits)
Installation & Configuration:¶
1] copy stuff to correct folders:¶
- /usr/bin/esmsd
- /etc/esmsd.conf
- /etc/init.d/esmsd (.init)
2] setup a database like this:¶
create database sms_gateway;
create user sms identified by 'smsdpassword';
grant all privileges on sms_gateway.* to sms;
create table `inbox` (
`id` int(10) unsigned not null auto_increment,
`number` varchar(20) collate latin1_bin not null default '',
`insertdate` timestamp not null default current_timestamp,
`text` text collate latin1_bin
primary key (`id`)
);
create table `outbox` (
`id` int(10) unsigned not null auto_increment,
`number` varchar(20) collate latin1_bin not null default '',
`text` varchar(160) collate latin1_bin default null,
`processed` tinyint(4) not null default '0',
`error` tinyint(4) not null default '-1',
`dreport` tinyint(4) not null default '0',
`priority` int(11) not null default '1',
`inserted` timestamp not null default current_timestamp,
`processed_time` timestamp not null default '0000-00-00 00:00:00',
`hour_min` tinyint(4) default '0',
`hour_max` tinyint(4) default '23',
primary key (`id`),
key `ob_inserted` (`inserted`),
key `ob_hour_min` (`hour_min`),
key `ob_hour_max` (`hour_max`),
key `ob_processed` (`processed`)
);
3] Configure and run the SMS daemon.¶
Before you execute the initscript/executable, you need to place esmsd.conf to /etc/ and fill it with values that make it connect to the database. Should be pretty easy.
You might need a bit of bash script debugging knowhow to have it running correctly. But I tried hard, so it should 'just work'
You might also need to check it for possible SQL injections over SMS (which aren't the stuff one would like to get into). But I checked it several times, so it should be secure too.
4] Play with it.¶
SQL code to easily send a sms:
insert into outbox set number='606123456',text='Hello world!';
You might like to mess with priority parameters (especially if outgoing queue is full of boring SMS and you need to send one faster), hour_min and hour_max which specifies in what daytime to send the sms), dreport (which, when set to 1, causes a delivery report to be available in inbox later), and watch for processed, error and other values.
SQL code to read incoming SMSes is:
select * from inbox;
which is pretty straightforward and self-explained.
5] Troubleshoot.¶
Run it by hand, from console. Read bash error messages. Watch syslog (everything gets logged to your logging daemon with tag 'esmsd').
Feel free to write me an e-mail in case you find a bug (especially bash/mysql interaction is very rough now).