Rewrite config and systemd service as a template
This commit is contained in:
parent
6ca8567911
commit
65909cf84d
1 changed files with 32 additions and 50 deletions
80
README.md
80
README.md
|
@ -178,42 +178,22 @@ It will be the script to manage the current status of t38modem.
|
||||||
# /etc/t38modem/bin/run
|
# /etc/t38modem/bin/run
|
||||||
|
|
||||||
export LD_LIBRARY_PATH=/usr/local/lib
|
export LD_LIBRARY_PATH=/usr/local/lib
|
||||||
export PTLIBPLUGINDIR=/usr/local/lib/ptlib-x.y.z:/usr/local/lib/opal-a.b.c # Adjust lib versions!
|
export PTLIBPLUGINDIR=/usr/local/lib/ptlib-2.18.6:/usr/local/lib/opal-3.18.6 # Adjust lib versions!
|
||||||
|
|
||||||
case "$1" in
|
if [ -z "${1}" ]; then
|
||||||
start)
|
>&2 echo "Config file path not set! Aborting..."
|
||||||
. /etc/t38modem/config
|
|
||||||
# defines
|
|
||||||
# - T38MODEM_SIP_USERNAME
|
|
||||||
# - T38MODEM_SIP_PASSWORD
|
|
||||||
# - T38MODEM_SIP_SERVER
|
|
||||||
|
|
||||||
COMMAND="t38modem -u T38modem --ptty +/dev/ttyT38-1 --sip-proxy ${T38MODEM_SIP_USERNAME}:${T38MODEM_SIP_PASSWORD}@${T38MODEM_SIP_SERVER} --sip-register ${T38MODEM_SIP_USERNAME}@${T38MODEM_SIP_SERVER},${T38MODEM_SIP_PASSWORD} --sip-listen udp\$:5060 --route t38:.*=sip:<dn>@${T38MODEM_SIP_SERVER} --route sip:.*=t38:<dn>"
|
|
||||||
echo "${COMMAND}"
|
|
||||||
exec $COMMAND > /dev/null 2>&1 &
|
|
||||||
PID=$!
|
|
||||||
echo "Starting t38modem with pid $PID (pidfile /run/t38modem.pid)"
|
|
||||||
echo $PID > /run/t38modem.pid
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
if [ ! -f "/run/t38modem.pid" ]; then
|
|
||||||
echo "t38modem is not running! (/run/t38modem.pid does not exist)"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "Stopping t38modem pid: "
|
. "${1}"
|
||||||
PID=`cat /run/t38modem.pid`
|
|
||||||
kill -9 $PID
|
|
||||||
rm /run/t38modem.pid
|
|
||||||
echo "${PID} Done"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage: $0 {start|stop}"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
command="t38modem --ptty +/dev/ttyT38-${T38MODEM_PTTY_ID} --sip-proxy ${T38MODEM_SIP_USERNAME}:${T38MODEM_SIP_PASSWORD}@${T38MODEM_SIP_SERVER} --sip-register ${T38MODEM_SIP_USERNAME}@${T38MODEM_SIP_SERVER},${T38MODEM_SIP_PASSWORD} --sip-listen udp\$:5060 --stun ${T38MODEM_STUN_SERVER} --route t38:.*=sip:<dn>@${T38MODEM_SIP_SERVER} --route sip:.*=t38:<dn>"
|
||||||
|
|
||||||
|
if [ "$T38MODEM_DISABLE_T38" = true ]; then
|
||||||
|
command="${command} --disable-t38-mode --audio"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec $command
|
||||||
```
|
```
|
||||||
|
|
||||||
And then we'll have to make it executable like this.
|
And then we'll have to make it executable like this.
|
||||||
|
@ -223,32 +203,34 @@ sudo chmod +x /etc/t38modem/bin/run
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Quick script overview
|
#### Quick script overview
|
||||||
- Using that script, it is possible to `start` or `stop` the emulated modem.
|
- Using this script, it is possible to start t38modem with a config file as an argument
|
||||||
- `-t` enables debugging
|
- `-t` enables debugging
|
||||||
- More `t`'s is deeper debugging (e.g. `-tttt`)
|
- More `t`'s is deeper debugging (e.g. `-tttt`)
|
||||||
- You can of course run the t38modem command without this init script
|
|
||||||
- If t38modem says it was able to create the virtual modem but `/dev/ttyT38-1` is not available, you do not have sufficient permissions
|
- If t38modem says it was able to create the virtual modem but `/dev/ttyT38-1` is not available, you do not have sufficient permissions
|
||||||
- Configuration is specified in `/etc/t38modem/config`
|
- Configuration is specified in `/etc/t38modem/config/XX`
|
||||||
|
|
||||||
### Create the configuration file
|
### Create the configuration file
|
||||||
Create a file using the following contents at `/etc/t38modem/config`.
|
Create a file using the following contents at `/etc/t38modem/config/XX`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# /etc/t38modem/config
|
# /etc/t38modem/config
|
||||||
|
T38MODEM_PTTY_ID="XX" # /dev/ttyT38-XX
|
||||||
T38MODEM_SIP_USERNAME="USERNAME"
|
T38MODEM_SIP_USERNAME="USERNAME"
|
||||||
T38MODEM_SIP_PASSWORD="PASSWORD"
|
T38MODEM_SIP_PASSWORD="PASSWORD"
|
||||||
T38MODEM_SIP_SERVER="voip.example.com"
|
T38MODEM_SIP_SERVER="voip.example.com"
|
||||||
|
T38MODEM_STUN_SERVER="stun.example.com:1234"
|
||||||
|
T38MODEM_DISABLE_T38=false # enable if your SIP server prefers G.711
|
||||||
```
|
```
|
||||||
|
|
||||||
You should give only root access to the config.
|
You should give only root access to the config.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo chown root:root /etc/t38modem/config
|
sudo chown root:root -R /etc/t38modem/config/
|
||||||
sudo chmod 700 /etc/t38modem/config
|
sudo chmod 700 -R /etc/t38modem/config/
|
||||||
```
|
```
|
||||||
|
|
||||||
### Testing your setup
|
### Testing your setup
|
||||||
- You can now communicate with your modem `/dev/ttyT38-1`, just as if it was a real Hayes compatible modem (https://www.computerhope.com/atcom.htm)
|
- You can now communicate with your modem `/dev/ttyT38-XX`, just as if it was a real Hayes compatible modem (https://www.computerhope.com/atcom.htm)
|
||||||
- Test using minicom, configure it to point to our modem. Each command is initiated by a Return
|
- Test using minicom, configure it to point to our modem. Each command is initiated by a Return
|
||||||
- Dial a number:
|
- Dial a number:
|
||||||
- Get the attention of the modem: `at` -> `OK`
|
- Get the attention of the modem: `at` -> `OK`
|
||||||
|
@ -265,33 +247,31 @@ sudo chmod 700 /etc/t38modem/config
|
||||||
- Test the command before running the init script!
|
- Test the command before running the init script!
|
||||||
|
|
||||||
### systemd service
|
### systemd service
|
||||||
If you want to run a fax server, you can create a systemd service to let your emulated fax modem start automatically on system boot.
|
If you want to run a fax server, you can create a systemd service template to let your emulated fax modem start automatically on system boot.
|
||||||
To do this you have to copy paste the following into `/etc/systemd/system/t38modem.service`.
|
To do this you have to copy paste the following into `/etc/systemd/system/t38modem@.service`.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# /etc/systemd/system/t38modem.service
|
# /etc/systemd/system/t38modem@.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=t38modem
|
Description=t38modem
|
||||||
After=network-online.target
|
After=network-online.target
|
||||||
Wants=network-online.target
|
Wants=network-online.target
|
||||||
|
AssertPathExists=/etc/t38modem/config/%i
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/etc/t38modem/bin/run start
|
|
||||||
ExecStop=/etc/t38modem/bin/run stop
|
|
||||||
PIDFile=/run/t38modem.pid
|
|
||||||
KillMode=none
|
|
||||||
Restart=always
|
Restart=always
|
||||||
|
ExecStart=/etc/t38modem/bin/run /etc/t38modem/config/%i
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
```
|
```
|
||||||
Enable and start the service using the following commands:
|
Enable and start the service for your config file (`/etc/t38modem/config/XX`) using the following commands:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable t38modem.service
|
sudo systemctl enable t38modem@XX.service
|
||||||
sudo systemctl start t38modem.service
|
sudo systemctl start t38modem@XX.service
|
||||||
```
|
```
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
@ -305,7 +285,7 @@ sudo systemctl start t38modem.service
|
||||||
- Run `sudo faxsetup`
|
- Run `sudo faxsetup`
|
||||||
|
|
||||||
- Add new modem
|
- Add new modem
|
||||||
- Enter correct modem port (`ttyT38-1`)
|
- Enter correct modem port (`ttyT38-XX`)
|
||||||
- Enter dialing configuration
|
- Enter dialing configuration
|
||||||
- Accept default configuration for everything else
|
- Accept default configuration for everything else
|
||||||
- It should automatically detect it to be a `T38FAX` modem
|
- It should automatically detect it to be a `T38FAX` modem
|
||||||
|
@ -315,6 +295,7 @@ sudo systemctl start t38modem.service
|
||||||
|
|
||||||
- If you get some protocol errors, just let HylaFax do its thing.
|
- If you get some protocol errors, just let HylaFax do its thing.
|
||||||
Fax over SIP is not stable at all in my experience
|
Fax over SIP is not stable at all in my experience
|
||||||
|
- If your call is cleared because it `Could not find common media capabilities` t38modem may not have been able to load PTLib or Opal. Check your library paths!
|
||||||
|
|
||||||
|
|
||||||
## Cron
|
## Cron
|
||||||
|
@ -342,6 +323,7 @@ FaxMaster: $USER # replace with fax admin account
|
||||||
## Dial Rules for Eventphone
|
## Dial Rules for Eventphone
|
||||||
|
|
||||||
```
|
```
|
||||||
|
# /etc/hylafax/config.ttyXX
|
||||||
CountryCode: 1
|
CountryCode: 1
|
||||||
AreaCode: 999
|
AreaCode: 999
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue