Fix service

This commit is contained in:
Dominic Grimm 2024-08-01 18:21:40 +02:00
parent e110ca0a0f
commit a45d3fba6b

View file

@ -23,18 +23,13 @@
### Build PTLib ### Build PTLib
- Version 2.18.6 - Version 2.18.6
- Dependency of Opal, bundled with Opal source code (SourceForge) - Dependency of Opal, bundled with Opal source code (SourceForge)
- http://wiki.opalvoip.org/index.php?n=Main.BuildingPTLibUnix - http://wiki.opalvoip.org/index.php?n=Main.BuildingPTLibUnix
- Wiki outdated:
- `libssl1.0-dev` -> `libssl-dev`
- **TODO: Remove dependencies, most of them are optional** - **TODO: Remove dependencies, most of them are optional**
```bash ```bash
sudo apt install \ sudo apt install \
g++ git make autoconf libpcap-dev libexpat-dev libssl-dev libsasl2-dev libldap-dev \ g++ git make autoconf libpcap-dev libexpat1-dev libssl-dev libsasl2-dev libldap2-dev \
unixodbc-dev liblua5.3-dev libv8-dev libncurses-dev libsdl2-dev \ unixodbc-dev liblua5.3-dev libv8-dev libncurses-dev libsdl2-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
``` ```
@ -59,15 +54,12 @@ sudo make install
- Version 3.18.6 - Version 3.18.6
- http://wiki.opalvoip.org/index.php?n=Main.BuildingOpalUnix - http://wiki.opalvoip.org/index.php?n=Main.BuildingOpalUnix
- Wiki outdated: - Dont use `libavcodec-dev` -> Compile error
- `libsrtp-dev` -> `libsrtp2-dev`
- Dont use `capiutils`, we are not using ISDN capable cards
- Dont use `libavcodec-dev` -> Compile error
- **TODO: Remove dependencies, most of them are optional** - **TODO: Remove dependencies, most of them are optional**
```bash ```bash
sudo apt install \ sudo apt install \
lisrtp2-dev libgsm1-dev libspeex-dev libopus-dev libx264-dev \ libsrtp2-dev libgsm1-dev libspeex-dev libopus-dev libx264-dev \
libvpx-dev libtheora-dev libspandsp-dev dahdi libvpx-dev libtheora-dev libspandsp-dev dahdi
``` ```
@ -101,14 +93,15 @@ sudo cp ./t38modem /usr/local/bin
### Init script ### Init script
- To automatically start t38modem, you need to create Systemd services, as well as start and stop scripts - To automatically start t38modem, you need to create Systemd services, as well as start and stop scripts
- init.d script is adapted from https://web.archive.org/web/20111231021042/https://www.foriamroot.org/hylafax-6-0-debian-or-ubuntu-t38modem-1-0-asterisk-1-6/ - script is adapted from https://web.archive.org/web/20111231021042/https://www.foriamroot.org/hylafax-6-0-debian-or-ubuntu-t38modem-1-0-asterisk-1-6/
- `sudo mkdir -p /etc/t38modem/bin/`
```bash ```bash
#!/bin/bash #!/bin/bash
# /etc/init.d/t38modem # /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-x.y.z # Adjust lib versions! export PTLIBPLUGINDIR=/usr/local/lib/ptlib-x.y.z:/usr/local/lib/opal-a.b.c # Adjust lib versions!
case "$1" in case "$1" in
start) start)
@ -118,7 +111,7 @@ case "$1" in
# - T38MODEM_SIP_PASSWORD # - T38MODEM_SIP_PASSWORD
# - T38MODEM_SIP_SERVER # - 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>'" 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>"
exec $COMMAND > /dev/null 2>&1 & exec $COMMAND > /dev/null 2>&1 &
PID=$! PID=$!
echo "Starting t38modem with pid $PID (pidfile /run/t38modem.pid)" echo "Starting t38modem with pid $PID (pidfile /run/t38modem.pid)"
@ -146,7 +139,7 @@ exit 0
``` ```
```bash ```bash
sudo chmod +x /etc/init.d/t38modem sudo chmod +x /etc/t38modem/bin/run
``` ```
- `-t` enables debugging - `-t` enables debugging
@ -165,8 +158,8 @@ T38MODEM_SIP_SERVER="voip.example.com"
- Give only root access to the config - Give only root access to the config
```bash ```bash
sudo chown root:root /etc/t38modem sudo chown root:root /etc/t38modem/config
sudo chmod 700 /etc/t38modem sudo chmod 700 /etc/t38modem/config
``` ```
- 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-1` , just as if it was a real Hayes compatible modem (https://www.computerhope.com/atcom.htm)
@ -191,14 +184,16 @@ sudo chmod 700 /etc/t38modem
# /etc/systemd/system/t38modem.service # /etc/systemd/system/t38modem.service
[Unit] [Unit]
Description=t38modem Description=t38modem
After=network.target After=network-online.target
Wants=network-online.target
[Service] [Service]
Type=simple Type=simple
ExecStart=/etc/init.d/t38modem start ExecStart=/etc/t38modem/bin/run start
ExecStop=/etc/init.d/t38modem stop ExecStop=/etc/t38modem/bin/run stop
PIDFile=/run/t38modem.pid PIDFile=/run/t38modem.pid
KillMode=none KillMode=none
Restart=always
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
@ -216,4 +211,13 @@ sudo systemctl start t38modem.service
## HylaFax ## HylaFax
- **TODO** - Version 6
- `sudo apt install hylafax-server`
- Set Postfix Configuration to **Local only** in dpkg-reconfigure menu
- Run `sudo faxsetup`
- Add new modem
- Enter correct modem port (`ttyT38-1`)
- Enter dialing configuration
- Accept default configuration for everything else
- It should automatically detect it to be a `T38FAX` modem