Merge remote-tracking branch 'grimm/main'

This commit is contained in:
Moritz Kempe 2024-08-12 14:55:32 +02:00
commit 2c925a1aa5

View file

@ -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`
@ -268,33 +250,31 @@ sudo chmod 700 /etc/t38modem/config
Dont let that hodld you back. Dont let that hodld you back.
### 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/>
@ -306,7 +286,7 @@ These instructions were tested using Hylafax version 6
## Configure HylaFax ## Configure HylaFax
- 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 (see Dial Rules for Eventphone EPVPN) - Enter dialing configuration (see Dial Rules for Eventphone EPVPN)
- 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
@ -316,6 +296,7 @@ These instructions were tested using Hylafax version 6
- 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
@ -341,6 +322,7 @@ If you want to use Eventhone EPVPN, you can apply the following dial settings on
You can find the config at `/etc/hylafax/config.ttyT38-1`. You can find the config at `/etc/hylafax/config.ttyT38-1`.
In this case `ttyT38-1` is the modem block device. In this case `ttyT38-1` is the modem block device.
``` ```
# /etc/hylafax/config.ttyXX
CountryCode: 1 CountryCode: 1
AreaCode: 999 AreaCode: 999
``` ```