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 create_misdn_init_conf {
cardcount=1
cardconf=""
IFS=$'\n'
NL="
"
function die {
echo "[!!] ${1}"
exit 1
}
function addcard {
cardline="${cardline}card=${cardcount},${1}${NL}"
let "cardcount = ${cardcount} + 1"
}
function addport {
let "portcount = ${portcount} + ${1}"
}
portcount=0
for line in $(${LSPCI} -n -d 1397:30b1); do
addcard "0x1"
addport 1
done
for line in $(${LSPCI} -n -d 1397:08b4); do
addcard "0x4"
addport 4
done
for line in $(${LSPCI} -n -d 1397:16b8); do
addcard "0x8"
addport 8
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"
addport 1
done
for line in $(${LSPCI} -n -d 1244:0xa00); do
addcard "avmfritz"
addport 1
done
if [ "${1}" == "scan" ]; then
echo "[OK] found the following devices:"
echo "${cardline}[ii] run \"/etc/init.d/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/')"
# <option> master_clock - use master clock for this S/T interface
# (only once per chip, only for HFC 8/4)
# optical - optical (only HFC-E1)
# los - report LOS (only HFC-E1)
# ais - report AIS (only HFC-E1)
# slip - report SLIP (only HFC-E1)
#
#option=1,master_clock
#option=2,ais
#option=3,optical,los,ais,slip
#
# General Options for your hfcmulti hardware
#
# poll=<number>
#
# Only one poll value must be given for all cards.
# Give the number of samples for each fifo process.
# By default 128 is used. Decrease to reduce delay, increase to
# reduce cpu load. If unsure, don't mess with it!!!
# Valid is 32, 64, 128, 256.
#
# pcm=<number>
#
# Give the id of the PCM bus. All PCM busses with the same ID
# are expected to be connected and have equal slots.
# Only one chip of the PCM bus must be master, the others slave.
# -1 means no support of PCM bus.
#
# debug=<number>
#
# Enable debugging (see hfc_multi.h for debug options).
#
poll=64
#pcm=1
debug=0"
if [ -f ${misdn_init_conf} ]; then
cp "${misdn_init_conf}" "${misdn_init_conf}.save" || die "could not backup your existing ${misdn_init_conf}!"
echo "[OK] ${misdn_init_conf} already present. backing it up to ${misdn_init_conf}.save"
fi
echo "${misdn_cfg_pt1}${NL}${cardline}${NL}${misdn_cfg_pt2}${NL}${portline}${NL}${NL}${misdn_cfg_pt3}" > ${misdn_init_conf} || die "could not write to /etc/misdn-init.conf!"
#echo "${misdn_cfg_pt1}${NL}${cardline}${NL}${misdn_cfg_pt2}${NL}${portline}${NL}${NL}${misdn_cfg_pt3}" > testconf || die "could not write to /etc/misdn-init.conf!"
echo "[OK] ${misdn_init_conf} created. It's now safe to run \"/etc/init.d/misdn-init start\""
if [ ${portcount} -gt 1 ]; then
echo "[ii] make your ports (1-${portcount}) available in asterisk by editing \"/etc/asterisk/misdn.conf\""
elif [ ${portcount} -eq 1 ]; then
echo "[ii] make your port (1) available in asterisk by editing \"/etc/asterisk/misdn.conf\""
fi
fi
}
function check_cfg_file {
if [ ! -f ${misdn_init_conf} ]; then
echo "[!!] failed to load: ${misdn_init_conf}"
echo "run \"/etc/init.d/misdn-init config\" to scan your devices and generate a basic config file."