From 0ca06802957d7f908c64dc338446e44256be1ebc Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 10 Apr 2008 00:09:53 +0200 Subject: [PATCH] Prepared core update 13. This will change the format of the mISDN config file back to plain config not XML. For the new old script there is bc required. Additionally the mISDN modules and some related are not loaded by udev on sys-start but manually by the mISDN init script. --- config/rootfiles/common/udev | 1 + config/rootfiles/core/13/files | 4 + config/rootfiles/core/13/meta | 1 + config/rootfiles/core/13/update.sh | 5 + config/udev/blacklist | 19 + lfs/udev | 1 + src/initscripts/init.d/mISDN | 1039 ++++++++++++++++++---------- 7 files changed, 703 insertions(+), 367 deletions(-) create mode 100644 config/rootfiles/core/13/files create mode 100644 config/rootfiles/core/13/meta create mode 100644 config/rootfiles/core/13/update.sh create mode 100644 config/udev/blacklist diff --git a/config/rootfiles/common/udev b/config/rootfiles/common/udev index 1bdec11070..adf1c614c2 100644 --- a/config/rootfiles/common/udev +++ b/config/rootfiles/common/udev @@ -1,4 +1,5 @@ etc/scsi_id.config +etc/modprobe.d/blacklist etc/udev #etc/udev/rules.d #etc/udev/rules.d/05-udev-early.rules diff --git a/config/rootfiles/core/13/files b/config/rootfiles/core/13/files new file mode 100644 index 0000000000..ba8bce191f --- /dev/null +++ b/config/rootfiles/core/13/files @@ -0,0 +1,4 @@ +etc/init.d/mISDN +etc/modprobe.d/blacklist +usr/bin/bc +usr/bin/dc diff --git a/config/rootfiles/core/13/meta b/config/rootfiles/core/13/meta new file mode 100644 index 0000000000..d547fa86fa --- /dev/null +++ b/config/rootfiles/core/13/meta @@ -0,0 +1 @@ +DEPS="" diff --git a/config/rootfiles/core/13/update.sh b/config/rootfiles/core/13/update.sh new file mode 100644 index 0000000000..600ffd9514 --- /dev/null +++ b/config/rootfiles/core/13/update.sh @@ -0,0 +1,5 @@ +#!/bin/bash +. /opt/pakfire/lib/functions.sh +/usr/local/bin/backupctrl exclude >/dev/null 2>&1 +extract_files +/etc/init.d/mISDN config diff --git a/config/udev/blacklist b/config/udev/blacklist new file mode 100644 index 0000000000..73e3207f45 --- /dev/null +++ b/config/udev/blacklist @@ -0,0 +1,19 @@ +blacklist hisax +blacklist hisax_fcpcipnp +blacklist hisax_isac +blacklist crc_ccitt +blacklist isdn +blacklist slhc +blacklist capi +blacklist capifs +blacklist kernelcapi +blacklist kernel_capi +blacklist avmfritz +blacklist hfcmulti +blacklist mISDN_core +blacklist mISDN_l1 +blacklist mISDN_l2 +blacklist l3udss1 +blacklist mISDN_capi +blacklist mISDN_isac +blacklist hfcsusb diff --git a/lfs/udev b/lfs/udev index f5004cbdef..5e91d0a813 100644 --- a/lfs/udev +++ b/lfs/udev @@ -145,6 +145,7 @@ else cp -rf $(DIR_SRC)/config/udev/dvb.sh /etc/udev/ chmod 755 /etc/udev/dvb.sh touch /etc/udev/rules.d/30-persistent-network.rules + cp -vf $(DIR_SRC)/config/udev/backlist /etc/modprobe.d/blacklist endif endif @rm -rf $(DIR_APP) diff --git a/src/initscripts/init.d/mISDN b/src/initscripts/init.d/mISDN index bbe054a0a2..c0f2afdc26 100644 --- a/src/initscripts/init.d/mISDN +++ b/src/initscripts/init.d/mISDN @@ -1,291 +1,124 @@ #!/bin/bash -#---------------------------------------------- +################################################################################ # -# CONFIGURATION: +# misdn-init init script +# +# Copyright (C) 2005, Nadi Sarrar # -MISDN_CONF="/etc/mISDN.conf" -MISDN_CONF_XSL="/usr/lib/mISDN/mISDN.conf.xsl" +# Nadi Sarrar +# +# This program is free software, distributed under the terms of +# the GNU General Public License # -#---------------------------------------------- -SELF="${0}" -USAGE="Usage: ${SELF} start|stop|restart|config|scan|help" +# +# USAGE: +# +# /usr/sbin/misdn-init start|stop|restart|config|scan|help +# -function die { - echo "[!!] ${1}" - exit 1 -} +# chkconfig: 2345 35 60 +# description: mISDN Kernel Modules -function check_cmd -{ - if ! type -p "${1}" > /dev/null; then - if [ "${2}" = "opt" ]; then - return - fi - if [ "$(id -u)" != "0" ]; then - die "$1 not in path, please install and/or be root." - else - die "$1 not in path, please install." - fi - exit 1 - else - local var=$(echo ${1} | tr a-z A-Z) - eval "$var=`type -p ${1}`" - fi -} +# +# CONFIGURATION: +# +# Path to your misdn-init.conf: +# +misdn_init_conf="/etc/misdn-init.conf" +# +################################################################################ -function check_misdn_conf -{ - if [ ! -f ${MISDN_CONF} ]; then - die "${MISDN_CONF} not found. Please run: ${SELF} config" - fi -} +# +# change this to modify the user/group settings of /dev/mISDN +# +USER=asterisk +GROUP=asterisk -check_cmd sed -check_cmd cut -check_cmd cp -check_cmd wc -check_cmd grep -check_cmd xsltproc -check_cmd modprobe -check_cmd sleep -check_cmd lspci -check_cmd lsusb opt -check_cmd mknod -check_cmd chown -check_cmd chmod - -declare -a START_COMMANDS -declare -a STOP_COMMANDS - -declare -a HFCMULTI_card -declare -a HFCMULTI_type -declare -a HFCMULTI_protocol -declare -a HFCMULTI_layermask -HFCMULTI_options='' -MISDNDSP_options='' -L1OIP_options='' - -AVMFRITZ_protocol='' -AVMFRITZ_layermask='' - -HFCPCI_protocol='' -HFCPCI_layermask='' - -L1OIP_type='' -L1OIP_protocol='' -L1OIP_layermask='' -L1OIP_codec='' -L1OIP_ip='' -L1OIP_port='' -L1OIP_localport='' -L1OIP_ondemand='' -L1OIP_id='' - -DEVNODE_user='root' -DEVNODE_group='root' -DEVNODE_mode='0644' - -declare -a SCAN_card -declare -a SCAN_opts -declare -a SCAN_num_ports -declare -a SCAN_port_opts - -function parse_config -{ - local CONFIG=$(${XSLTPROC} ${MISDN_CONF_XSL} ${MISDN_CONF}) - local t p l line i tmpcmd curr tmpstr val - local IFS=$'\n' - - START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install capi" - START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install mISDN_core debug=0" - START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install mISDN_l1 debug=0" - START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install mISDN_l2 debug=0" - START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install l3udss1 debug=0" - START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install mISDN_capi" - - for line in ${CONFIG}; do - case "${line}" in - DEVNODE:mISDN*) - tmpstr=$(echo ${line} | ${SED} -n 's/.*user:\([^ ]*\).*/\1/p') - if [ ! -z "${tmpstr}" ]; then - DEVNODE_user="${tmpstr}" - fi - tmpstr=$(echo ${line} | ${SED} -n 's/.*group:\([^ ]*\).*/\1/p') - if [ ! -z "${tmpstr}" ]; then - DEVNODE_group="${tmpstr}" - fi - tmpstr=$(echo ${line} | ${SED} -n 's/.*mode:\([^ ]*\).*/\1/p') - if [ ! -z "${tmpstr}" ]; then - DEVNODE_mode="${tmpstr}" - fi - ;; - MODULE:hfcmulti*) - HFCMULTI_options=${line:16} - ;; - MODULE:mISDN_dsp*) - MISDNDSP_options=${line:17} - ;; - MODULE:l1oip*) - L1OIP_options=${line:13} - ;; - CARD:BN*) - curr='hfcmulti' - i=${#HFCMULTI_type[@]} - let "t = $(echo ${line} | ${SED} -n 's/.*type:\([^,]*\).*/\1/p')" - HFCMULTI_type[${i}]=$(printf "0x%x" ${t}) - -# this is for the BN2E1 card that needs two type numbers - t=$(echo ${line} | ${SED} -n 's/.*type:[^,]*,\([^ ]*\).*/\1/p') - if [ ! -z "${t}" ]; then - let "t = ${t}" - HFCMULTI_type[${i}]="${HFCMULTI_type[${i}]},$(printf "0x%x" ${t})" - fi +# HFC 8/4 (S0) Options +master_clock=17 - HFCMULTI_card[${i}]=$(echo ${line:5} | ${CUT} -d" " -f1) - ;; - CARD:hfcpci*) - curr='hfcpci' - ;; - CARD:avmfritz*) - curr='avmfritz' - ;; - CARD:l1oip*) - curr='l1oip' - ;; - PORT*) - case "${curr}" in - hfcmulti) - let "p = $(echo ${line} | ${SED} -n 's/.*protocol:\([^ ]*\).*/\1/p')" - HFCMULTI_protocol[${i}]="${HFCMULTI_protocol[${i}]:+"${HFCMULTI_protocol[${i}]},"}$(printf "0x%x" ${p})" - let "l = $(echo ${line} | ${SED} -n 's/.*layermask:\([^ ]*\).*/\1/p')" - HFCMULTI_layermask[${i}]="${HFCMULTI_layermask[${i}]:+"${HFCMULTI_layermask[${i}]},"}$(printf "0x%x" ${l})" - ;; - hfcpci) - let "p = $(echo ${line} | ${SED} -n 's/.*protocol:\([^ ]*\).*/\1/p')" - HFCPCI_protocol="${HFCPCI_protocol:+"${HFCPCI_protocol},"}$(printf "0x%x" ${p})" - let "l = $(echo ${line} | ${SED} -n 's/.*layermask:\([^ ]*\).*/\1/p')" - HFCPCI_layermask="${HFCPCI_layermask:+"${HFCPCI_layermask},"}$(printf "0x%x" ${l})" - ;; - avmfritz) - let "p = $(echo ${line} | ${SED} -n 's/.*protocol:\([^ ]*\).*/\1/p')" - AVMFRITZ_protocol="${AVMFRITZ_protocol:+"${AVMFRITZ_protocol},"}$(printf "0x%x" ${p})" - let "l = $(echo ${line} | ${SED} -n 's/.*layermask:\([^ ]*\).*/\1/p')" - AVMFRITZ_layermask="${AVMFRITZ_layermask:+"${AVMFRITZ_layermask},"}$(printf "0x%x" ${l})" - ;; - l1oip) - let "val = $(echo ${line} | ${SED} -n 's/.*type:\([^ ]*\).*/\1/p')" - L1OIP_type="${L1OIP_type:+"${L1OIP_type},"}$(printf "0x%x" ${val})" - let "val = $(echo ${line} | ${SED} -n 's/.*protocol:\([^ ]*\).*/\1/p')" - L1OIP_protocol="${L1OIP_protocol:+"${L1OIP_protocol},"}$(printf "0x%x" ${val})" - let "val = $(echo ${line} | ${SED} -n 's/.*layermask:\([^ ]*\).*/\1/p')" - L1OIP_layermask="${L1OIP_layermask:+"${L1OIP_layermask},"}$(printf "0x%x" ${val})" - val="$(echo ${line} | ${SED} -n 's/.*codec:\([^ ]*\).*/\1/p')" - L1OIP_codec="${L1OIP_codec:+"${L1OIP_codec},"}${val}" - val="$(echo ${line} | ${SED} -n 's/.*ip:\([^ ]*\).*/\1/p')" - L1OIP_ip="${L1OIP_ip:+"${L1OIP_ip},"}${val}" - val="$(echo ${line} | ${SED} -n 's/.*port:\([^ ]*\).*/\1/p')" - L1OIP_port="${L1OIP_port:+"${L1OIP_port},"}${val}" - val="$(echo ${line} | ${SED} -n 's/.*localport:\([^ ]*\).*/\1/p')" - L1OIP_localport="${L1OIP_localport:+"${L1OIP_localport},"}${val}" - val="$(echo ${line} | ${SED} -n 's/.*ondemand:\([^ ]*\).*/\1/p')" - L1OIP_ondemand="${L1OIP_ondemand:+"${L1OIP_ondemand},"}${val}" - val="$(echo ${line} | ${SED} -n 's/.*id:\([^ ]*\).*/\1/p')" - L1OIP_id="${L1OIP_id:+"${L1OIP_id},"}${val}" - ;; - esac - ;; - esac - done +# HFC-E1 Options +optical=17 +los=19 +ais=20 +slip=21 +nocrc4=24 - if [ ! -z "${HFCMULTI_protocol[0]}" ]; then - tmpcmd="${MODPROBE} --ignore-install hfcmulti type=${HFCMULTI_type[0]}" - i=1 - while [ ! -z "${HFCMULTI_type[${i}]}" ]; do - tmpcmd="${tmpcmd},${HFCMULTI_type[${i}]}" - let "i = ${i} + 1" - done - tmpcmd="${tmpcmd} protocol=${HFCMULTI_protocol[0]}" - i=1 - while [ ! -z "${HFCMULTI_protocol[${i}]}" ]; do - tmpcmd="${tmpcmd},${HFCMULTI_protocol[${i}]}" - let "i = ${i} + 1" - done - tmpcmd="${tmpcmd} layermask=${HFCMULTI_layermask[0]}" - i=1 - while [ ! -z "${HFCMULTI_layermask[${i}]}" ]; do - tmpcmd="${tmpcmd},${HFCMULTI_layermask[${i}]}" - let "i = ${i} + 1" - done - START_COMMANDS[${#START_COMMANDS[@]}]="${tmpcmd} ${HFCMULTI_options}" - fi +# Card Settings +ulaw=9 +dtmf=10 +pcm_slave=12 +ignore_pcm_frameclock=13 - if [ ! -z "${HFCPCI_protocol}" ]; then - START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install hfcpci protocol=${HFCPCI_protocol} layermask=${HFCPCI_layermask}" - fi +rxclock=14 +crystalclock=19 - if [ ! -z "${AVMFRITZ_protocol}" ]; then - START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install avmfritz protocol=${AVMFRITZ_protocol} layermask=${AVMFRITZ_layermask}" - fi +watchdog=20 - if [ ! -z "${L1OIP_type}" ]; then - START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install l1oip type=${L1OIP_type} protocol=${L1OIP_protocol} layermask=${L1OIP_layermask} codec=${L1OIP_codec} ip=${L1OIP_ip} port=${L1OIP_port} localport=${L1OIP_localport} ondemand=${L1OIP_ondemand} id=${L1OIP_id} ${L1OIP_options}" - fi - START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install mISDN_dsp ${MISDNDSP_options}" -} +#dsp defaults +dsp_options=0 -function run_start_commands -{ - local i=0 +poll_option= - echo "-- Loading mISDN modules --" - while [ ! -z "${START_COMMANDS[${i}]}" ]; do - echo ">> ${START_COMMANDS[${i}]}" - eval "${START_COMMANDS[${i}]}" - let "i = ${i} + 1" - done -} +dsp_poll_option= -function run_stop_commands -{ - local mod i=0 +dtmfthreshold_option= - for mod in $(lsmod | ${SED} -ne '/Module/!{s/\([^ ]*\).*/\1/;p}'); do - case "${mod}" in - mISDN_capi | mISDN_dsp | l3udss1 | mISDN_l2 | mISDN_l1 | mISDN_isac | hfcmulti | avmfritz | l1oip) - STOP_COMMANDS[0]="${STOP_COMMANDS[0]:-"${MODPROBE} -r --ignore-remove"} ${mod}" - ;; - mISDN_core) - STOP_COMMANDS[1]="${MODPROBE} -r --ignore-remove mISDN_core" - ;; - esac - done +function check_cmd { + if ! which "${1}" > /dev/null; then + if [ "$(id -u)" != "0" ]; then + echo "[!!] FATAL: $1 not in path, please install and/or be root." + else + echo "[!!] FATAL: $1 not in path, please install." + fi + if [ "${2}" != "notfatal" ] ; then + exit 1 + fi + else + var=$(echo ${1} | tr a-z A-Z) + eval "$var=`which ${1}`" + fi +} - echo "-- Unloading mISDN modules --" - while [ ! -z "${STOP_COMMANDS[${i}]}" ]; do - echo ">> ${STOP_COMMANDS[${i}]}" - eval "${STOP_COMMANDS[${i}]}" - let "i = ${i} + 1" - done +check_cmd modprobe +check_cmd rmmod +check_cmd insmod +check_cmd lspci +check_cmd lsusb notfatal +check_cmd mknod +check_cmd bc +check_cmd cut +check_cmd wc +check_cmd seq +check_cmd sed + +function check_asterisk { + if ps ax | grep -v grep | grep asterisk > /dev/null ; then asterisk -rx "stop now" ; fi } -function scan_devices +function create_card_db { - local skipnext=0 IFS=$'\n' - local NL=" + cardline="" + cardcount=1 + skipnext=0 + + IFS=$'\n' + NL=" " - function addcard { - SCAN_card[${#SCAN_card[@]}]="${1}" - SCAN_opts[${#SCAN_opts[@]}]="${2}" - SCAN_num_ports[${#SCAN_num_ports[@]}]="${3}" - SCAN_port_opts[${#SCAN_port_opts[@]}]="${4}" + cardline="${cardline}${cardcount},${1}${NL}" + let "cardcount = ${cardcount} + 1" + } + + function addport { + let "portcount = ${portcount} + ${1}" } for line in $(${LSPCI} -n -d 0xd161:b410); do - addcard "BN4S0" "" 4 'mode="te" link="ptmp"' + addcard "4,0x4" done for line in $(${LSPCI} -n | ${SED} -n 's/^\(0000:\|\)\([0-9a-f]\{2\}:[0-9a-f]\{2\}.[0-9a-f]\{1\}\)\( Class \| \)[0-9a-f]\{4\}: 1397:\([0-9a-f]\{4\}\).*$/\4 \2/p'); do @@ -297,179 +130,651 @@ function scan_devices 30b1*) case "${line:5}" in 00*) - addcard "BN1E1" "" 1 'mode="nt" link="ptp"' + addcard "1,0x1" ;; *) - if [ $(${LSPCI} -n -s "${line:5:3}" | ${WC} -l) -eq 2 ]; then - addcard "BN2E1" "" 2 'mode="nt" link="ptp"' + if [ $(${LSPCI} -n -s ${line:5:3} -d 0x1397:30b1 | ${WC} -l) -eq 2 ]; then + addcard "2,2E1" skipnext=1 else - addcard "BN1E1" "" 1 'mode="nt" link="ptp"' + addcard "1,0x1" fi ;; esac ;; 16b8*) - addcard "BN8S0" "" 8 'mode="te" link="ptmp"' + addcard "8,0x8" ;; 08b4*) - if ${LSPCI} -n -v -s "${line:5}" | ${GREP} "Subsystem" | ${GREP} "1397:b567" > /dev/null ; then - addcard "BN1S0" "" 1 'mode="te" link="ptmp"' - elif ${LSPCI} -n -v -s "${line:5}" | ${GREP} "Subsystem" | ${GREP} "1397:b566\|1397:b569" > /dev/null ; then - addcard "BN2S0" "" 2 'mode="te" link="ptmp"' + + if ${LSPCI} -n -v -s "${line:5}" | grep "Subsystem" | grep "1397:b567" > /dev/null ; then + addcard "1,0x4" + elif ${LSPCI} -n -v -s "${line:5}" | grep "Subsystem" | grep "1397:b566\|1397:b569" > /dev/null ; then + addcard "2,0x4" else - addcard "BN4S0" "" 4 'mode="te" link="ptmp"' + addcard "4,0x4" fi ;; esac done - for line in $(${LSPCI} -n | ${GREP} "1397:\(2bd\(0\|6\|7\|8\|9\|a\|b\|c\)\|b100\)\|1043:0675\|0871:ffa\(1\|2\)\|1051:0100\|15b0:2bd0\|114f:007\(0\|1\|2\|3\)\|13d1:2bd1\|182d:3069"); do - addcard "hfcpci" "" 1 'mode="te" link="ptmp"' + for line in $(${LSPCI} -n | grep "1397:\(2bd\(0\|6\|7\|8\|9\|a\|b\|c\)\|b100\)\|1043:0675\|0871:ffa\(1\|2\)\|1051:0100\|15b0:2bd0\|114f:007\(0\|1\|2\|3\)\|13d1:2bd1\|182d:3069"); do + addcard "1,hfcpci" done - for line in $(${LSPCI} -n | ${GREP} "1244:\(0a00\|0e00\)"); do - addcard "avmfritz" "" 1 'mode="te" link="ptmp"' + for line in $(${LSPCI} -n | grep "1244:\(0a00\|0e00\)"); do + addcard "1,avmfritz" done for line in $(${LSPCI} -n -d 1050:6692); do - addcard "w6692pci" "" 1 'mode="te" link="ptmp"' + addcard "1,w6692pci" done + if [ -e ${LSUSB} ]; then - for line in $(${LSUSB} | ${GREP} "0959:2bd0\|0675:1688\|07b0:0007\|0742:200\(7\|8\|9\|A\)\|08e3:0301\|07fa:084\(7\|8\)\|07ba:0006"); do - addcard "hfcsusb" "" 1 'mode="te" link="ptmp"' + for line in $(${LSUSB} | grep "0959:2bd0\|0675:1688\|07b0:000\(6\|7\)\|0742:200\(7\|8\|9\|A\)\|08e3:0301\|07fa:084\(7\|8\)\|07ba:0006"); do + addcard "1,hfcsusb" done fi + + echo "${cardline}" } -function write_mISDN_conf +function expand { - local NL=" -" - local TAB=" " - local HEADER=" - - -${TAB}hfcmulti -${TAB}mISDN_dsp -${TAB}mISDN" - local FOOTER="" - local i=0 j=0 MAIN="" - - echo "Writing ${MISDN_CONF} for ${#SCAN_card[@]} mISDN compatible device(s):" - while [ ! -z "${SCAN_card[${i}]}" ]; do - echo ">> ${SCAN_card[${i}]}" - MAIN="${MAIN}${NL}${TAB}" - j=1 - while [ ${j} -le ${SCAN_num_ports[${i}]} ]; do - MAIN="${MAIN}${NL}${TAB}${TAB}${j}" - let "j = ${j} + 1" - done - MAIN="${MAIN}${NL}${TAB}" - let "i = ${i} + 1" + local IFS=$',' + for tok in $1; do + if [ "$(echo $tok | ${SED} -ne 's/\([0-9]*\)-\([0-9]*\)/\1 \2/p')" != "" ]; then + ${SEQ} $(echo $tok | ${SED} -ne 's/\([0-9]*\)-[0-9]*/\1/p') $(echo $tok | ${SED} -ne 's/[0-9]*-\([0-9]*\)/\1/p') + else + echo $tok + fi done +} + +function load_card_modules { + + carddb=$(create_card_db) + + function find_carddb_line { + i=1 + for l in ${carddb} ; do + if [ $i -eq $1 ] ; then + echo $l + return + fi + let "i=$i+1" + done + } - if [ -f ${MISDN_CONF} ]; then - echo "${MISDN_CONF} already present, saving a backup: ${MISDN_CONF}.bak" - ${CP} "${MISDN_CONF}" "${MISDN_CONF}.bak" || die "Could not backup your existing ${MISDN_CONF}!" + if [ ! -z "$1" ] ; then + echo "Loading only $1" fi - echo "${HEADER}${MAIN}${NL}${FOOTER}" > ${MISDN_CONF} + + IFS=$'\n' + skipnr=0 + + for line in $(${SED} -n -e '/^[^#]/p' ${misdn_init_conf}); + do + var=$(echo "${line}" | ${CUT} -d "=" -f1) + val=$(echo "${line}" | ${CUT} -d "=" -f2) + + case "${var}" in + card) + #echo "processing line: $val" + nr=$(echo "${val}" | ${CUT} -d "," -f1) + mod=$(echo "${val}" | ${CUT} -d "," -f2) + opns=$(echo "${val}" | ${CUT} -d "," -f3-) + + #getting portcount from carddb + ports=$(find_carddb_line $nr | ${CUT} -d "," -f2) + let "nr = ${nr} + ${skipnr}" + #echo "nr $nr ports $ports mod $mod opns: $opns" + + case "${mod}" in + 2E1) + hfcmulti[${nr}]=1 + hfcmulti[$((${nr} + 1))]=1 + let "hfcports = ${hfcports} + ${ports}" + IFS=$',' + for li in ${opns}; do + hfcmulti[${nr}]=$(echo "obase=10;2^(${!li}-1)+${hfcmulti[${nr}]}" | ${BC}) + if [ "${li}" != "pcm_slave" ]; then + hfcmulti[$((${nr} + 1))]=$(echo "obase=10;2^(${!li}-1)+${hfcmulti[$((${nr}+1))]}" | ${BC}) + fi + done + IFS=$'\n' + hfcmulti[$((${nr} + 1))]=$(echo "obase=10;2^(${pcm_slave}-1)+${hfcmulti[$((${nr}+1))]}" | ${BC}) + let "skipnr = ${skipnr} + 1" + ;; + 0x*) + hfcmulti[${nr}]=$(echo ${mod} | ${SED} -e "s/^0x\([0-9]*\)/\1/") + let "hfcports = ${hfcports} + ${ports}" + IFS=$',' + for li in ${opns}; do + hfcmulti[${nr}]=$(echo "obase=10;2^(${!li}-1)+${hfcmulti[${nr}]}" | ${BC}) + done + IFS=$'\n' + ;; + *) + other_card[${nr}]=${mod} + ;; + esac + ;; + te_ptp) + for li in $(expand "${val}"); do + layermask[${li}]="0xf" + protocol[${li}]=34 # 0x22 == 34 + done + ;; + te_ptmp) + for li in $(expand "${val}"); do + layermask[${li}]="0xf" + protocol[${li}]=2 # 0x2 == 2 + done + ;; + nt_*) + for li in $(expand "${val}"); do + layermask[${li}]="0x3" + protocol[${li}]=18 # 0x12 == 18 + done + ;; + te_capi_ptp) + for li in $(expand "${val}"); do + layermask[${li}]="0x0" + protocol[${li}]=34 # 0x22 == 34 + done + + export addcapi=1 + ;; + te_capi_ptmp) + for li in $(expand "${val}"); do + layermask[${li}]="0x0" + protocol[${li}]=2 # 0x2 == 2 + done + + export addcapi=1 + ;; + + option) + port=`echo "${val}" | ${SED} -e "s/^\([0-9]*\),.*/\1/"` + opt=`echo "${val}" | ${SED} -e "s/^[0-9]*,\(.*\)/\1/"` + + if [ -z ${protocol[${port}]} ]; then + protocol[${port}]="0" + fi + + IFS=$',' + for li in ${opt}; do + protocol[${port}]=$(echo "obase=10;2^(${!li}-1)+${protocol[${port}]}" | ${BC}) + done + IFS=$'\n' + ;; + poll) + poll=${val} + poll_option=poll=${val} + ;; + dsp_poll) + dsp_poll_option=poll=${val} + ;; + pcm) + pcm=${val} + ;; + dsp_options) + export dsp_options=${val} + ;; + dtmfthreshold) + export dtmfthreshold_option="dtmfthreshold=${val}" + ;; + debug) + debug=${val} + ;; + timer) + timer=${val} + ;; + *) + echo "unknown variable: ${var}" + ;; + esac + + done + + echo "-----------------------------------------" + echo " Loading module(s) for your misdn-cards:" + echo "-----------------------------------------" + + card_index=1 + port_index=1 + while [ ! -z ${hfcmulti[${card_index}]} ] || [ ! -z ${other_card[${card_index}]} ]; + do + if [ ! -z ${hfcmulti[${card_index}]} ]; then + # MODPROBE COMMAND FOR hfcmulti CARD + hfcmulti_type="type=" + hfcmulti_prot="protocol=" + hfcmulti_layer="layermask=" + while [ ! -z ${hfcmulti[${card_index}]} ]; + do + hfcmulti_type="${hfcmulti_type}$(echo "obase=16;\"0x\";${hfcmulti[${card_index}]}" | ${BC} )," + let "card_index = ${card_index} + 1" + done + while [ ${hfcports} -gt 0 ]; + do + if [ ! -z ${protocol[${port_index}]} ]; then + hfcmulti_prot="${hfcmulti_prot}$(echo "obase=16;\"0x\";${protocol[${port_index}]}" | ${BC})," + else + hfcmulti_prot="${hfcmulti_prot}0x2," + fi + if [ ! -z ${layermask[${port_index}]} ]; then + hfcmulti_layer="${hfcmulti_layer}${layermask[${port_index}]}," + else + hfcmulti_layer="${hfcmulti_layer}0xf," + fi + let "port_index = ${port_index} + 1" + let "hfcports = ${hfcports} - 1" + done + hfcmulti_type="$(echo ${hfcmulti_type} | ${SED} -e 's/^\(.*\),$/\1/')" + hfcmulti_prot="$(echo ${hfcmulti_prot} | ${SED} -e 's/^\(.*\),$/\1/')" + hfcmulti_layer="$(echo ${hfcmulti_layer} | ${SED} -e 's/^\(.*\),$/\1/')" + hfcmulti_cmd="${MODPROBE} --ignore-install hfcmulti ${hfcmulti_type} ${hfcmulti_prot} ${hfcmulti_layer}" + if [ ! -z ${poll} ]; then + hfcmulti_cmd="${hfcmulti_cmd} poll=${poll}" + fi + if [ ! -z ${pcm} ]; then + hfcmulti_cmd="${hfcmulti_cmd} pcm=${pcm}" + fi + if [ ! -z ${debug} ]; then + hfcmulti_cmd="${hfcmulti_cmd} debug=${debug}" + fi + + if [ ! -z ${timer} ]; then + hfcmulti_cmd="${hfcmulti_cmd} timer=${timer}" + fi + + if [ -z "$1" ] ; then + echo ${hfcmulti_cmd} + eval ${hfcmulti_cmd} + else + if [ "$1" = "hfcmulti" ] ; then + echo ${hfcmulti_cmd} + eval ${hfcmulti_cmd} + fi + fi + else + # MODPROBE COMMAND FOR _NON_ hfcmulti CARD + other_mod="${other_card[${card_index}]}" + other_cmd="${MODPROBE} --ignore-install ${other_mod}" + if [ ! -z ${protocol[${port_index}]} ]; then + other_prot="protocol=$(echo "obase=16;\"0x\";${protocol[${port_index}]}" | ${BC})," + else + other_prot="protocol=0x2," + fi + if [ ! -z ${layermask[${port_index}]} ]; then + other_layer="layermask=${layermask[${port_index}]}," + else + other_layer="layermask=0xf," + fi + other_extra="" + modinfo $other_mod | egrep -q 'parm: *poll' && other_extra="$other_extra ${poll_option}" + + let "prev = ${card_index}" + let "card_index = ${card_index} + 1" + let "port_index = ${port_index} + 1" + while [ "${other_card[${card_index}]}" == "${other_card[${prev}]}" ]; + do + if [ ! -z ${protocol[${port_index}]} ]; then + other_prot="${other_prot}$(echo "obase=16;\"0x\";${protocol[${port_index}]}" | ${BC})," + else + other_prot="${other_prot}0x2," + fi + if [ ! -z ${layermask[${port_index}]} ]; then + other_layer="${other_layer}${layermask[${port_index}]}," + else + other_layer="${other_layer}0xf," + fi + let "prev = ${card_index}" + let "card_index = ${card_index} + 1" + let "port_index = ${port_index} + 1" + done + + other_prot="$(echo ${other_prot} | ${SED} -e 's/^\(.*\),$/\1/')" + other_layer="$(echo ${other_layer} | ${SED} -e 's/^\(.*\),$/\1/')" + other_cmd="${other_cmd} ${other_prot} ${other_layer} ${other_extra}" + + if [ -z "$1" ] ; then + echo "${other_cmd}" + eval ${other_cmd} + else + if [ "$1" = "${other_card[${prev}]}" ] ; then + echo ${other_cmd} + eval ${other_cmd} + fi + fi + + + fi + done } -function print_scan_results -{ - local i=0 +function unload_card_modules { + + IFS=$'\n' + + for line in $(${SED} -ne '/^[^#]/p' ${misdn_init_conf}); + do + var=$(echo "${line}" | ${CUT} -d "=" -f 1) + val=$(echo "${line}" | ${CUT} -d "=" -f 2) + + case "${var}" in + card) + nr=$(echo "${val}" | ${CUT} -d "," -f 1) + mod=$(echo "${val}" | ${CUT} -d "," -f 2) + case "${mod}" in + 2E1) + modulelist[${nr}]=hfcmulti + ;; + 0x*) + modulelist[${nr}]=hfcmulti + ;; + *) + modulelist[${nr}]=${mod} + ;; + esac + ;; + esac + + done + + echo "-------------------------------------------" + echo " Unloading module(s) for your misdn-cards:" + echo "-------------------------------------------" + + rmmod_cmd="${RMMOD} ${modulelist[1]}" + echo "${rmmod_cmd}" + eval ${rmmod_cmd} - echo "${#SCAN_card[@]} mISDN compatible device(s) found:" - while [ ! -z "${SCAN_card[${i}]}" ]; do - echo ">> ${SCAN_card[${i}]}" - let "i = ${i} + 1" + index=2 + prev=1 + while [ ! -z ${modulelist[${index}]} ]; + do + if [ ${modulelist[${index}]} != ${modulelist[${prev}]} ]; then + rmmod_cmd="${RMMOD} ${modulelist[${index}]}" + echo "${rmmod_cmd}" + eval ${rmmod_cmd} + fi + let "prev = ${index}" + let "index = ${index} + 1" done } -function mk_misdn_dev -{ - if [ ! -e /dev/mISDN ]; then - echo "creating device node: /dev/mISDN" - ${MKNOD} /dev/mISDN c 46 0 - fi - ${CHOWN} ${DEVNODE_user}:${DEVNODE_group} /dev/mISDN - ${CHMOD} ${DEVNODE_mode} /dev/mISDN -} +function create_misdn_init_conf { + cardline="" + cardcount=1 + portcount=0 + cardconf="" + IFS=$'\n' + NL=" +" + carddb=$(create_card_db) + + for line in $carddb ; do + tmp="card=$(echo $line | ${CUT} -d, -f1,3)" + let "portcount = ${portcount} + $(echo $line | ${CUT} -d, -f2)" + cardline="${cardline}${tmp}${NL}" + done + function die { + echo "[!!] ${1}" + exit 1 + } + + if [ "${1}" == "scan" ]; then + echo "[OK] found the following devices:" + echo "${cardline}[ii] run \"/usr/sbin/misdn-init config\" to store this information to ${misdn_init_conf}" + else + + index=1 + portline="te_ptmp=" + while [ ${index} -le ${portcount} ]; do + portline="${portline}${index}," + let "index = ${index} + 1" + done + portline="$(echo ${portline} | ${SED} -e 's/^\(.*\),$/\1/')" + + misdn_cfg_pt1="# +# Configuration file for your misdn hardware # -# MAIN +# Usage: /usr/sbin/misdn-init start|stop|restart|config|scan|help # -case "${1}" in +# +# Card Settings +# +# Syntax: card=,[,