Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 36a757fdfa451f4377b9e205ce5fc429 > files > 50

smstools-3.1.8-2.fc14.x86_64.rpm

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <META NAME="Title" CONTENT="SMS Server Tools 3">
    <META NAME="Robots" CONTENT="INDEX,FOLLOW">
    <META NAME="Language" CONTENT="English">
    <title>SMS Server Tools 3</title>
<STYLE type="text/css">
BODY {
  BACKGROUND: #ffffff; MARGIN: 5px 5px 10px; FONT: 10pt verdana, geneva, lucida, arial, helvetica, sans-serif; COLOR: #000000
}
td {
  FONT: 10pt verdana, geneva, lucida, arial, helvetica, sans-serif;
}
h3 {
  background-color: #DCDCFE;
}
blockquote {
  background-color: #FFD;
  font-size: 90%;
  padding:5pt;
  padding-top:1pt;
  margin-bottom:5pt;
  border-style: outset;
  border-color: #aaaa99;
  border-width: 0.05pt 2pt 2pt 0.05pt;
}
blockquote p:first-letter {
  font-size: 110%;
  font-weight: bold;
  color: red;
}
</STYLE>
  </head>

<body>
<h2><font color=blue><a href="http://smstools3.kekekasvi.com">SMS Server Tools 3</a></font></h2>
<a href="index.html">Home</a>

<h3><b>NOTE</b> for users running smsd with very heavy load</h3>
<!-- START --><p>
<p>
    Current version of smsd moves files between spooler directories using the original file name.
    If outgoing files are created using a fixed filename (which is not recommended) and lot of
    files using the same name are created within a short period, it's possible that previous file
    and it's .LOCK file are still existing in the spooler directory. In this case a new file cannot
    be moved to the spool. Previously the smsd stopped with a fatal error in this case. Now an
    alarmhandler is called and after it has returned a file moving is retried. If a file still
    cannot be moved, the smsd will stop with a fatal error.<br>
    <br>
    The alarmhandler can be used to help with a file moving conflict. The script can wait until
    a spooler can be used, or it can wait some fixed time like 5 seconds. It can also produce some
    notices to the administration, if necessary.<br>
    <br>
    In some cases this kind of conflict is a result of a previously happened error in the system
    which creates outgoing files to send. In this case it's better to let smsd stop, instead of
    sending couple of thousand messages to somewhere...<br>
    <br>
    In the conflict case the alarmhandler will get following arguments (as an example):
    <ul>
      <li>$1=ALARM
      </li>
      <li>$2=2007-07-06
      </li>
      <li>$3=12:00:00
      </li>
      <li>$4=2
      </li>
      <li>$5=smsd
      </li>
      <li>$6=Conflict with .LOCK file in the spooler: /var/spool/sms/outgoing/test_file /var/spool/sms/checked
      </li>
    </ul>

</p>

<h3>Running (as a root)</h3>
<p>
<b>IMPORTANT:</b> The smsd inherits it's priviledges from the user who started the daemon.
If starting is done by the root or system startup, priviledges of root are inherited.
In this case the smsd can switch to the unpriviledged user account,
if it is defined in config file or command line (in the sms3 script).
If the smsd is started by the unpriviledged user, account switching is not available.
</p>
<p>
Easiest way to run the smsd is running it as a root:
</p>
<p>
<b>Method 1 (recommended for the normal use):</b>
</p>
<ul>
<p>
Enter <b>/etc/init.d/sms3 start</b> to start smsd in background.<br>
Enter <b>/etc/init.d/sms3 stop</b> to stop smsd.
</p>
<p>NOTE: On some installations (Debian, Ubuntu for example) script is using name <b>smstools</b>.
</p>
<p>
In case of Unix, you might create links in your runlevel directories (for example /etc/rc3.d or /etc/init.d/rc3.d) 
if the program shall start and stop automatically together with the operating system.
</p>
<p>
With sms3 script you can ensure that:
<ul>
  <li>If smsd is already running, duplicate daemon is not started.</li>
  <li>When smsd is stopped while it is sending a multipart messsage, the script will wait until all parts are sent.
      Information of the process is printed to terminal, so you can see why the daemon is not stopped immediately.</li>
  <li>In case of troubles there is force-stop argument available. This handles all smsd processes, not just the main process.</li>
</ul>
<br>
<b>NOTE:</b> When the smsd main process receives a termination signal, it sends it to all subprocesses.
After a signal is received, no more new jobs are started.
Already started jobs are completed, which usually will not take too much time.
<br><br>
<b>NOTE:</b> If you are running smsd in heavy traffic environment, and you OS does not wait processes
while it is shutting down, it is recommended to stop the smsd with <i>/etc/init.d/sms3 stop</i> before
shutting down the OS.
</p>
</ul>
<p>
<b>Method 2:</b>
</p>
<ul>
<p>
Run <b>/usr/local/bin/smsd -s</b> to start the program in a command window.<br>
The smsd will run in foreground and status monitor is printed to terminal.<br>
Press Ctrl-C to stop the program.<br>
</p>
</ul>
<p>
<b>Method 3:</b>
</p>
<ul>
<p>
Enter <b>/usr/local/bin/smsd</b> to start the daemon in background.<br>
Enter <b>pkill smsd</b> to stop it.
</p>
</ul>

<h3>Running smsd as an unpriviledged user</h3>
<p>
In some environments it is more suitable to run smsd with priviledges of a standard user.
There are two ways to do this:
<ul>
  <li>Recommended way: Define user account settings in sms3 script and use it to start the smsd by the root.</li>
  <li>Start the smsd by the unpriviledged user.</li>
</ul>
</p>
<p>
In both cases you must ensure that <i>infofile</i> and <i>pidfile</i> are writable by the unpriviledged user.
Location and name of those files can be defined in the config file, if sms3 script is not used.
Most recommended way is using the sms3 script, and change settings in this script.
</p>
<p>
In the sms3 script there are settings <i>USER=""</i> and <i>GROUP=""</i>.<br>
Usual settings for these are the same group and user who owns the modem device,
for example <b>USER="uucp", GROUP="dialer"</b> or <b>USER="smsd", GROUP="dialout"</b>.
Selected user must have write permissions to the device(s).
</p>
<p>
Selected user must also have write permissions to the spool directories.
For example those directories can be owned by this user.
Other users who are permitted to send messages should have write permissions to the outgoing directory.
</p>
<p>
<i>infofile</i> and <i>pidfile</i> should be moved to the place which is writable by the selected user, for example:<br>
<b>PIDFILE="/var/run/smsd/smsd.pid"</b> and<br>
<b>INFOFILE="/var/run/smsd/smsd.working"</b><br>
<br>
Usually the default <i>logfile</i> is not writable by the unpriviledged user,
this should be defined in the sms3 script too:<br>
<b>LOGFILE="/var/log/smsd/smsd.log"</b>
</p>
<p>
When the smsd is trying to start, all permissions and availability of directories are checked.
If there are any problems, they are reported and smsd shuts down.
This prevents problems in the future, for example when smsd was run for couple of days and
<i>failed</i> directory is first time needed.
If a directory is not accessible, smsd stops.
</p>

<h3>Sending a message</h3>
<p>
Run the command <b>sendsms 491721234567 'Hello, how are you'</b> to send a message or put an <a href="fileformat.html">SMS file</a> into the Outgoing Folder /var/spool/sms/outgoing.
</p><p>
To read a received message, take a look into the Incoming Folder /var/spool/sms/incoming.
</p>

<h3>Using a Regular Run feature (version >= 3.1)</h3>
<p>
After version >= 3.1 it is possible to define an external <i>regular_run</i> script or program in the configuration file. 
This program or script is executed at a given interval while the smsd is running. 
Because the smsd controls when the script is executed, there is no need to start/stop procedures like using traditional crontab. 
In the future versions there will also be some return value handling. 
Currently return values other than zero are reported to the log file.
</p><p>
This example is about verifying the delivery of a sent message. 
If it's not delivered fast enough, a same message is sent to the alternate phone number.
</p><p>
When the first message is sent:
<ul>
  <li>There is <b>To:</b> field for primary number.</li>
  <li>There is also <b>Alternate_to:</b> field for an alternate number. The smsd does not use this field by itself.</li>
  <li>Status report is requested: <b>Report: yes</b> (or smsd.conf report = yes).</li>
  <li>The smsd adds <b>Sent: timestamp</b> and <b>Message_id: nr</b> fields automatically to the sent message file.</li>
</ul>
</p><p>
When a status report is received, it's stored to the incoming folder as described in the <a href="fileformat.html">SMS file format</a>. 
An eventhandler can find the relevant sent message and add the <b>Received: timestamp</b> header to the message file.
</p><p>
If a destination phone is switched off, or it's out of GSM network, the status report is not received, 
of course because the message is not delivered.
</p>
We have to check if there is a sent message which had status report requested (Message_id field is present) and there is 
also an alternate destination number, but not a Received timestamp. If this kind of message is found, we have to check how long we
have been waiting a delivery. For example after about 30 minutes of waiting, we could do the following:
<ul>
  <li><b>Alternate_to</b> number is taken to the memory and removed from the first message.</li>
  <li>The modified first message is copied to the temp.</li>
  <li><b>To</b> number in the temp message is replaced with a number which was an alternate to.</li>
  <li>A temp message is moved to the outgoing folder.</li>
</ul>
It's not necessary to remove old Message_id and Sent headers. 
The smsd will remove them automatically when the message is moved to the sent folder. 
If a status report is requested for the new message, the smsd will place a new Message_id header to the message file.
</p><p>
See <b>smstools3/scripts/regular_run</b> script for more details. 
This script is compatible with ASCII messages with character set ISO or GSM. 
This kind of functionality can also be made with MySQL, but this example is file based.
</p>

<hr>
</body>
</html>