From 4510e38975f8602e5e03502be518b9402837cbec Mon Sep 17 00:00:00 2001 From: Chris Walker Date: Thu, 2 Apr 2020 00:08:34 +0700 Subject: network/t38modem: Updated for version 3.15. Signed-off-by: Willy Sudiarto Raharjo --- network/t38modem/README | 19 ++++- network/t38modem/doinst.sh | 26 ++++++ network/t38modem/rc.t38modem | 152 +++++++++++++++++++++++++++++++++++ network/t38modem/rc.t38modem.conf | 40 +++++++++ network/t38modem/resetmodem | 28 +++++++ network/t38modem/slack-desc | 2 +- network/t38modem/t38modem.SlackBuild | 35 ++++---- network/t38modem/t38modem.info | 14 ++-- 8 files changed, 285 insertions(+), 31 deletions(-) create mode 100644 network/t38modem/doinst.sh create mode 100644 network/t38modem/rc.t38modem create mode 100644 network/t38modem/rc.t38modem.conf create mode 100644 network/t38modem/resetmodem diff --git a/network/t38modem/README b/network/t38modem/README index 8b80ff7d18..d9f5eb211b 100644 --- a/network/t38modem/README +++ b/network/t38modem/README @@ -4,7 +4,18 @@ What is t38modem? * From IP network view point it's a H.323/SIP endpoint with T.38 fax support. * From your view point it's a gateway between an application and IP network. -This package requires both the OPAL and ptlib packages (both available on -SlackBuilds.) After building and installing OPAL package keep the OPAL source -tree on disk. This package will point to OPAL source tree and use files created -during its build processes to create this package. +After installation update the /etc/rc.d/rc.t38modem.conf file with your SIP +account details and add the following to your /etc/rc.d/rc.local script: + + if [ -x /etc/rc.d/rc.t38modem ]; then + /etc/rc.d/rc.t38modem start + fi + +Optionally, you can add the following to your /etc/rc.d/rc.local_shutdown: + + if [ -x /etc/rc.d/rc.t38modem ]; then + /etc/rc.d/rc.t38modem stop + fi + +If you are using this package with Asterisk there is a sample resetmodem script +that can be placed in the your /var/spool/hylafax/etc directory. diff --git a/network/t38modem/doinst.sh b/network/t38modem/doinst.sh new file mode 100644 index 0000000000..29b7e602de --- /dev/null +++ b/network/t38modem/doinst.sh @@ -0,0 +1,26 @@ +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... +} + +preserve_perms() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + if [ -e $OLD ]; then + cp -a $OLD ${NEW}.incoming + cat $NEW > ${NEW}.incoming + mv ${NEW}.incoming $NEW + fi + config $NEW +} + +preserve_perms etc/rc.d/rc.t38modem.new +config etc/rc.d/rc.t38modem.conf.new + diff --git a/network/t38modem/rc.t38modem b/network/t38modem/rc.t38modem new file mode 100644 index 0000000000..158debc2ef --- /dev/null +++ b/network/t38modem/rc.t38modem @@ -0,0 +1,152 @@ +#!/bin/sh + +############################# +# READ T38MODEM CONFIG FILE # +############################# + +# Get the configuration information from /etc/rc.d/rc.t38modem.conf: +. /etc/rc.d/rc.t38modem.conf + +########### +# LOGGING # +########### + +# If possible, log events in /var/log/messages: +if [ -f /var/run/syslogd.pid -a -x /usr/bin/logger ]; then + LOGGER=/usr/bin/logger +else # output to stdout/stderr: + LOGGER=/bin/cat +fi + +MAXMODEMS=6 + +# Function to return PID of modem instance: +modem_pid() { + PID=$(ps -C t38modem -o pid,cmd | grep ${1} | grep -v grep | awk '{print $1}') + echo "$PID" +} + +# Function to start modem interface: +modem_up() { + i=0 + while [ $i -lt $MAXMODEMS ]; do + if [ "${MODEMNAME[$i]}" = "${1}" ]; then + PID=$(modem_pid "${1}") + if [ -n "$PID" ]; then + echo "Modem "${1}" already up..." + else + echo "Starting t38modem on ${1}..." + # Build PTTY name + PTTY=${PTTY[$i]} + if [ -z "${PTTY}" ]; then + PTTY="+/dev/${MODEMNAME[$i]}" + fi + # Start t38modem + nohup \ + /usr/bin/t38modem \ + --no-h323 \ + --sip-t38-udptl-redundancy ${T38_REDUNDANCY[$i]} \ + --sip-listen udp\$*:${LISTEN_PORT[$i]} \ + --sip-register ${SIP_ACCOUNT[$i]}@${SIP_SERVER[$i]},${SIP_PASSWORD[$i]} \ + --ptty ${PTTY} \ + --force-fax-mode \ + --route "modem:.*=sip:@${SIP_SERVER[$i]}" \ + --route "sip:.*=modem:" \ + > /dev/null 2>&1 & + fi + break + fi + i=$(($i+1)) + done +} + +# Function to stop modem interface: +modem_down() { + PID=$(modem_pid "${1}") + if [ -n "$PID" ]; then + echo "Stopping t38modem for modem ${1}..." + kill $PID + fi +} + +# Function to report status on modem interface: +modem_status() { + PID=$(modem_pid "${1}") + echo -n "Modem ${1}: " + if [ -n "$PID" ]; then + echo "up" + else + echo "down" + fi +} + +# Function to bring modems up: +start() { + for i in ${MODEMNAME[@]} ; do + modem_up $i + done +} + +# Function to take modems down: +stop() { + for i in ${MODEMNAME[@]} ; do + modem_down $i + done +} + +# Function to query modem states: +status() { + for i in ${MODEMNAME[@]} ; do + modem_status $i + done +} + +############ +### MAIN ### +############ + +case "$1" in +'start') + start + ;; +'stop') + stop + ;; +'restart') + stop + sleep 5 + start + ;; +'status') + status + ;; +*_start) + MODEM=$(echo $1 | /bin/cut -d '_' -f 1) + modem_up $MODEM + ;; +*_stop) + MODEM=$(echo $1 | /bin/cut -d '_' -f 1) + modem_down $MODEM + ;; +*_restart) + MODEM=$(echo $1 | /bin/cut -d '_' -f 1) + modem_down $MODEM + sleep 5 + modem_up $MODEM + ;; +*_status) + MODEM=$(echo $1 | /bin/cut -d '_' -f 1) + modem_status $MODEM + ;; +*_up) + MODEM=$(echo $1 | /bin/cut -d '_' -f 1) + modem_up $MODEM + ;; +*_down) + MODEM=$(echo $1 | /bin/cut -d '_' -f 1) + modem_down $MODEM + ;; +*) + echo "usage: $0 start|stop|restart|status" +esac + diff --git a/network/t38modem/rc.t38modem.conf b/network/t38modem/rc.t38modem.conf new file mode 100644 index 0000000000..bb05c85527 --- /dev/null +++ b/network/t38modem/rc.t38modem.conf @@ -0,0 +1,40 @@ +##################################################### +# Must be set to the number of modems in the config # +##################################################### + +# Config information for modem0: +MODEMNAME[0]="ttyx0" +PTTY[0]="" +SIP_SERVER[0]= +SIP_ACCOUNT[0]= +SIP_PASSWORD[0]= +LISTEN_PORT[0]=5060 +T38_REDUNDANCY[0]=3 + +# Config information for modem1: +MODEMNAME[1]="ttyx1" +PTTY[1]="" +SIP_SERVER[1]= +SIP_ACCOUNT[1]= +SIP_PASSWORD[1]= +LISTEN_PORT[1]=5061 +T38_REDUNDANCY[1]=3 + +# Config information for modem2: +MODEMNAME[2]="ttyx2" +PTTY[2]="" +SIP_SERVER[2]= +SIP_ACCOUNT[2]= +SIP_PASSWORD[2]= +LISTEN_PORT[2]=5062 +T38_REDUNDANCY[2]=3 + +# Config information for modem3: +MODEMNAME[3]="ttyx3" +PTTY[3]="" +SIP_SERVER[3]= +SIP_ACCOUNT[3]= +SIP_PASSWORD[3]= +LISTEN_PORT[3]=5063 +T38_REDUNDANCY[3]=3 + diff --git a/network/t38modem/resetmodem b/network/t38modem/resetmodem new file mode 100644 index 0000000000..661cec143c --- /dev/null +++ b/network/t38modem/resetmodem @@ -0,0 +1,28 @@ +#!/usr/bin/bash + +# This script can be used to unwedge a stuck t38modem virtual modem. In order +# to use this script, you'll need to do the following: +# +# Use the /etc/rc.d/rc.t38modem script provided to start/stop t38modem. This +# will allow you to start up multiple virtual modems using a separate t38modem +# process for each line. You can then start/stop/restart an individual modem +# line without interrupting the other ongoing faxes. +# +# Using visudo, add the following to /etc/sudoers: +# +# # Hylafax system commands +# uucp ALL=(ALL) NOPASSWD: /etc/rc.d/rc.t38modem +# +# Copy this file to the /var/spool/hylafax/etc and set its execute bit: +# +# cp /usr/doc/hylafax-3.15/Hylafax/resetmodem /var/spool/hylafax/etc +# chmod +x /var/spool/hylafax/etc/resetmodem +# + +DEV=$(basename $1) + +if [ "$DEV" = "ttyx0" -o "$DEV" = "ttyx1" -o "$DEV" = "ttyx2" -o "$DEV" = "ttyx3" ]; then + sudo /etc/rc.d/rc.t38modem "${DEV}_restart" +fi + + diff --git a/network/t38modem/slack-desc b/network/t38modem/slack-desc index a650441304..032acfd2f1 100644 --- a/network/t38modem/slack-desc +++ b/network/t38modem/slack-desc @@ -16,4 +16,4 @@ t38modem: support t38modem: * From your view point it's a gateway between an application and IP t38modem: network t38modem: -t38modem: Homepage: https://sourceforge.net/projects/t38modem/ +t38modem: Homepage: https://github.com/T38Modem/t38modem diff --git a/network/t38modem/t38modem.SlackBuild b/network/t38modem/t38modem.SlackBuild index b0690134e9..489b096299 100644 --- a/network/t38modem/t38modem.SlackBuild +++ b/network/t38modem/t38modem.SlackBuild @@ -2,7 +2,7 @@ # Slackware build script for t38modem -# Copyright 2015 Christopher Walker Copperas Cove, TX +# Copyright 2015-2020 Chris Walker Kempner, TX # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -23,13 +23,13 @@ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PRGNAM=t38modem -VERSION=${VERSION:-2.0.0} +VERSION=${VERSION:-3.15} BUILD=${BUILD:-1} TAG=${TAG:-_SBo} if [ -z "$ARCH" ]; then case "$( uname -m )" in - i?86) ARCH=i486 ;; + i?86) ARCH=i586 ;; arm*) ARCH=arm ;; *) ARCH=$( uname -m ) ;; esac @@ -40,8 +40,8 @@ TMP=${TMP:-/tmp/SBo} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} -if [ "$ARCH" = "i486" ]; then - SLKCFLAGS="-O2 -march=i486 -mtune=i686" +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" @@ -61,8 +61,7 @@ mkdir -p $TMP $PKG $OUTPUT cd $TMP rm -rf $PRGNAM-$VERSION -tar xvf $CWD/${PRGNAM}_${VERSION}.orig.tar.gz -tar xvf $CWD/${PRGNAM}_${VERSION}-4.debian.tar.gz +unzip $CWD/$PRGNAM-$VERSION.zip cd $PRGNAM-$VERSION chown -R root:root . find -L . \ @@ -71,23 +70,21 @@ find -L . \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; -# -# Apply patches -# -patch -p1 <$TMP/debian/patches/t38modem-opal3.10-patch -patch -p1 <$TMP/debian/patches/spelling-error-fix -patch -p1 <$TMP/debian/patches/opal-3.10.7.patch -patch -p1 <$TMP/debian/patches/opal-3.10.9.patch - CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ PTLIBDIR=/usr/share/ptlib \ -OPALDIR=$TMP/opal-${OPALVER:-3.10.10} \ - make USE_UNIX98_PTY=1 USE_LEGACY_PTY=1 USE_OPAL=1 opt +OPALDIR=$TMP/opal-${OPALVER:-3.10.15} \ + make USE_UNIX98_PTY=1 USE_LEGACY_PTY=1 USE_OPAL=1 # Install binaries, READMEs, etc., mkdir -p $PKG/usr/bin -install -o root -g root obj_linux_*_opal/t38modem $PKG/usr/bin +install -o root -g root t38modem $PKG/usr/bin + +mkdir -p $PKG/etc/rc.d +install -o root -g root $CWD/rc.t38modem \ + $PKG/etc/rc.d/rc.t38modem.new +install -o root -g root -m 600 $CWD/rc.t38modem.conf \ + $PKG/etc/rc.d/rc.t38modem.conf.new # Strip binaries and libraries find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ @@ -99,12 +96,14 @@ cp -a \ $TMP/$PRGNAM-$VERSION/ReadMe.txt \ $PKG/usr/doc/$PRGNAM-$VERSION cp -a \ + $CWD/resetmodem \ $TMP/$PRGNAM-$VERSION/HylaFAX/config.ttyx \ $PKG/usr/doc/$PRGNAM-$VERSION/HylaFAX cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh cd $PKG /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} diff --git a/network/t38modem/t38modem.info b/network/t38modem/t38modem.info index bcab7eff84..09a7c9dc50 100644 --- a/network/t38modem/t38modem.info +++ b/network/t38modem/t38modem.info @@ -1,12 +1,10 @@ PRGNAM="t38modem" -VERSION="2.0.0" -HOMEPAGE="https://sourceforge.net/projects/t38modem/" -DOWNLOAD="http://http.debian.net/debian/pool/main/t/t38modem/t38modem_2.0.0.orig.tar.gz \ - http://http.debian.net/debian/pool/main/t/t38modem/t38modem_2.0.0-4.debian.tar.gz" -MD5SUM="ffcb224ac414693f2d0a5af720d4952a \ - 8072c6645a33f2660a58acd6f651d42a" +VERSION="3.15" +HOMEPAGE="https://github.com/T38Modem/t38modem" +DOWNLOAD="https://github.com/T38Modem/t38modem/archive/3.15/t38modem-3.15.zip" +MD5SUM="c340d2b6657ba81eaaab4a816367bbe0" DOWNLOAD_x86_64="" MD5SUM_x86_64="" -REQUIRES="opal" -MAINTAINER="Christopher Walker" +REQUIRES="t38modem-opal" +MAINTAINER="Chris Walker" EMAIL="kris240376@gmail.com" -- cgit v1.2.3