hatte ein angepasstes install-ZAPHFC
#!/bin/bash
#
# Version 1.0.1-2f - 6 December 2005 (draft)
#
# Usual caveats apply, so make sure you have backups: BEFORE YOU START!.
#
# Writtten by W1zz (please ask questions via AAH forum) w1zz {at} users [dot] sourceforge [dot] net
#
#
# This script is explicitly designed to load bristuff for BRI ISDN
#
# It was written and tested against AAH 2.0 (from ISO)
#
# It has not been tested with any other release (yet) so YMMV
#
# I don't expect other bristuff devices to work with this script.
# (which does not mean they won't - but don't expect it)
# Reported issues:
#
# - One user reported that running from an ISO build (AAH2.0) on a dual CPU machine
# that /bin/sh could not be found. [WORKAROUND] replace #!/bin/sh above with #!/bin/bash
#
# - Not known to be an issue: But if you have tried installing using a method similar to that
# described on
http://dondisperato.blogspot.com/ then you should remove the edits in /etc/rc.d/rc.local
# This scripts configures Asterisk to load the zaphfc module in the same way that it
# loads any other zap module
#
# - Also reported: "During the script I saw a FAILED flash by during zaptel unload. But zaptel
# seems to never unload correctly....." (by the same person as it happens).
#
# - Not all motherboards will run the bristuff patched code. E.g. a motherboard known not to work is the Asus A7VC
# If this is the case you may be best reporting this to the guys at Junghanns.
# Otherwise you'll need to find another motherboard.
#
echo ""
echo "-----------------------------------------------------"
echo installing HFC ISDN support using BRISTUFF
echo "-----------------------------------------------------"
echo ""
# -------------------------------------------
# Static parameters
# -------------------------------------------
#
# If you want to build against a newer version of bristuff then you can call this script with e.g.:
#
# "install-bristuff-ZAPHCFC bristuff-0.3.1"
#
# (You will need to determine the version from junghanns web site.)
# To reduce the chance of error, use the same capitalisation that you see on the download site.
if [ $1 ]
then
BRISTUFF_VERSION=$1
else
BRISTUFF_VERSION=bristuff-0.3.0-PRE-1d
fi
if [ $2 ]
then
FLORZ_VERSION=$2
else
FLORZ_VERSION=zaphfc_0.3.0-PRE-1_florz-10
fi
ASTERISK_VERSION=1.2.1
DOWNLOAD_SITE=http://www.junghanns.net/downloads/
DOWNLOAD_SITE_FLORZ=http://zaphfc.florz.dyndns.org/
SOURCE_DIRECTORY=/usr/src
SLEEP_TIME=5
# -------------------------------------------
# Parameters read from system
# -------------------------------------------
LOGFILE=/etc/asterisk/install-zaphfc-`date -d today '+%y-%m-%d.%T'`
CURRENT_DIRECTORY=`pwd`
# Check lspci and see if there is one or more HFC cards listed... This is not foolproof.
NUMBER_HFC_PCI=`lspci|grep -c HFC`
cd $SOURCE_DIRECTORY
echo "" >$LOGFILE
echo "STARTED: Running $0 in $CURRENT_DIRECTORY on `date`" >>$LOGFILE
# -------------------------------------------
# If no HFC chipset card found, check user really wants to run this...
# -------------------------------------------
if [ 0 -eq $NUMBER_HFC_PCI ]
then
echo "-----------------------------------------------------"
echo -e "lspci:\t\t\tDoes NOT show an entry for an HFC device" >>$LOGFILE
echo "No HFC based chipset was found when lspci was run."
echo "Are you sure you wish to continue this build? [y/n]"
echo "-----------------------------------------------------"
read CONTINUE
if [ P$CONTINUE = Py ]
then
echo OK....
else
exit 0
fi
fi
# -------------------------------------------
# Kernel setup
# -------------------------------------------
KERNEL_VERSION=`uname -r`
MODULES_DIRECTORY=/lib/modules/$KERNEL_VERSION/extra
if [ Psmp = P`uname -r|grep -o smp` ]
then
KERNEL_DIRECTORY=${KERNEL_VERSION%%smp}-smp-`uname -m`
KERNEL_CPU=smp
else
KERNEL_DIRECTORY=$KERNEL_VERSION-`uname -m`
KERNEL_CPU=one
fi
echo "" >>$LOGFILE
echo -e "Kernel version:\t\t$KERNEL_VERSION" >>$LOGFILE
echo -e "Kernel directory:\t$KERNEL_DIRECTORY" >>$LOGFILE
echo -e "Modules directory:\t$MODULES_DIRECTORY" >>$LOGFILE
# check that the kernel libraries for the currently running kernel are present
# if not try and install or update them
if [ ! -d $SOURCE_DIRECTORY/kernels/$KERNEL_DIRECTORY/ ]
then
echo ""
echo "-----------------------------------------------------"
echo " Attempting to download/update kernel libraries..."
echo "-----------------------------------------------------"
if [ smp = $KERNEL_CPU ]
then
PACKAGE=kernel-smp-devel
PRESENT=`rpm -qa kernel-smp-devel`
if [ Pkernel-smp-devel != P${PRESENT:0:16} ]
then
ACTION=install
else
ACTION=update
fi
else
PACKAGE=kernel-devel
PRESENT=`rpm -qa kernel-devel`
if [ Pkernel-devel != P${PRESENT:0:12} ]
then
ACTION=install
else
ACTION=update
fi
fi
echo -e "yum:\t\t\tRunning yum to $ACTION $PACKAGE" >>$LOGFILE
echo "Running yum to $ACTION $PACKAGE"
yum -y $ACTION $PACKAGE
fi
# re-check that the kernel libraries for the currently running kernel are present
if [ ! -d $SOURCE_DIRECTORY/kernels/$KERNEL_DIRECTORY/ ]
then
echo ""
echo "-----------------------------------------------------"
echo "Unable to find or update kernel libraries for the currently"
echo "running kernel"
echo "Expecting to find $SOURCE_DIRECTORY/kernels/$KERNEL_DIRECTORY/"
echo ""
echo "You are running: $KERNEL_VERSION"
echo ""
echo "The kernel libraries loaded in $SOURCE_DIRECTORY/kernels are:"
echo ""
ls -1 $SOURCE_DIRECTORY/kernels
echo ""
exit 1
else
echo ""
echo "-----------------------------------------------------"
echo "Seting up links to kernel sources"
echo "-----------------------------------------------------"
echo ""
### If the links exist, remove them in case they are pointing to another version of the kernel.
if [ -d /usr/src/linux/ ]
then
rm -f /usr/src/linux
fi
ln -s $SOURCE_DIRECTORY/kernels/$KERNEL_DIRECTORY /usr/src/linux
echo -e "Link linux:\t\t`ls -l linux`" >>$LOGFILE
if [ -d /usr/src/linux-2.6/ ]
then
rm -f /usr/src/linux-2.6
fi
ln -s $SOURCE_DIRECTORY/kernels/$KERNEL_DIRECTORY /usr/src/linux-2.6
echo -e "Link linux-2.6:\t\t`ls -l linux-2.6`" >>$LOGFILE
fi
# -------------------------------------------
# Download Sources & prepare
# -------------------------------------------
echo ""
echo "-----------------------------------------------------"
echo "Downloading $DOWNLOAD_SITE/$BRISTUFF_VERSION.tar.gz."
echo "-----------------------------------------------------"
echo ""
if [ ! -f $BRISTUFF_VERSION.tar.gz ]
then
echo >>$LOGFILE
echo -e "Bristuff tar:\t\tDownloading $BRISTUFF_VERSION.tar.gz" >>$LOGFILE
wget $DOWNLOAD_SITE/$BRISTUFF_VERSION.tar.gz
else
echo "Local copy found. Not downloading"
echo -e "Bristuff tar:\t\tFound. Not downloading" >>$LOGFILE
fi
### if they have been previously downloaded remove.
if [ -d $BRISTUFF_VERSION ]
then
echo -e "Bristuff dir:\t\tPrevious install found. Removing." >>$LOGFILE
rm -rf $BRISTUFF_VERSION
fi
echo ""
echo "-----------------------------------------------------"
echo "Unpacking $BRISTUFF_VERSION.tar.gz."
echo "-----------------------------------------------------"
echo ""
tar -zxvf $BRISTUFF_VERSION.tar.gz
cd $BRISTUFF_VERSION
echo -e "Junghanns script:\tRunning `date -d today '+%T'`" >>$LOGFILE
echo ""
echo "-----------------------------------------------------"
echo "Running Junghanns script"
echo "-----------------------------------------------------"
echo ""
./download.sh
# change of makefile vor via epia mainboard
cd /usr/src/$BRISTUFF_VERSION/asterisk\-$ASTERISK_VERSION
mv Makefile Makefile.old
sed 's/\#PROC\=i586/PROC\=i586/g' Makefile.old > Makefile
cd /usr/src/$BRISTUFF_VERSION
echo ""
echo "-----------------------------------------------------"
echo "Downloading $DOWNLOAD_SITE_FLORZ/$FLORZ_VERSION.diff.gz."
echo "-----------------------------------------------------"
echo ""
if [ ! -f $FLORZ_VERSION.diff.gz ]
then
echo >>$LOGFILE
echo -e "FLORZ wget:\t\tDownloading $FLORZ_VERSION.diff.gz" >>$LOGFILE
wget $DOWNLOAD_SITE_FLORZ/$FLORZ_VERSION.diff.gz
else
echo "Local copy found. Not downloading"
echo -e "FLORZ tar:\t\tFound. Not downloading" >>$LOGFILE
fi
### if they have been previously downloaded remove.
if [ -d $FLORZ_VERSION ]
then
echo -e "FLORZ dir:\t\tPrevious install found. Removing." >>$LOGFILE
rm -rf $FLORZ_VERSION
fi
echo -e "FLORZ patch:\tRunning `date -d today '+%T'`" >>$LOGFILE
echo ""
echo "-----------------------------------------------------"
echo "Running FLORZ Patch"
echo "-----------------------------------------------------"
echo ""
gunzip $FLORZ_VERSION.diff.gz
mv $FLORZ_VERSION.diff $FLORZ_VERSION.diff.old
sed 's/1\.2\.0/1\.2\.1/g' $FLORZ_VERSION.diff.old > $FLORZ_VERSION.diff
cat $FLORZ_VERSION.diff | patch -p1
# -------------------------------------------
# System preparation
# -------------------------------------------
echo ""
echo "-----------------------------------------------------"
echo "Shutting down Asterisk & unloading zaptel"
echo "-----------------------------------------------------"
echo ""
/usr/sbin/amportal stop
if [ 0 -ne `lsmod|grep -c ztdummy` ]
then
rmmod ztdummy
echo -e "Found ztdummy:\t\tUnloading" >>$LOGFILE
fi
/bin/sleep 2
if [ 0 -ne `lsmod|grep -c zaptel` ]
then
/sbin/service zaptel stop
echo -e "Found zaptel:\t\tUnloading" >>$LOGFILE
fi
# -------------------------------------------
# Build
# -------------------------------------------
echo ""
echo "-----------------------------------------------------"
cd $SOURCE_DIRECTORY/$BRISTUFF_VERSION/zaptel-$ASTERISK_VERSION
echo "Building zaptel in: `pwd`"
echo "-----------------------------------------------------"
echo ""
make clean; make; make install
echo -e "Zaptel build:\t\t`ls -l zaptel.ko`" >>$LOGFILE
/bin/sleep $SLEEP_TIME
echo ""
echo "-----------------------------------------------------"
cd $SOURCE_DIRECTORY/$BRISTUFF_VERSION/libpri-$ASTERISK_VERSION
echo "Building libpri in: `pwd`"
echo "-----------------------------------------------------"
echo ""
make clean; make; make install
echo -e "Libpri build:\t\t`ls -l libpri.so`" >>$LOGFILE
/bin/sleep $SLEEP_TIME
echo ""
echo "-----------------------------------------------------"
cd $SOURCE_DIRECTORY/$BRISTUFF_VERSION/zaphfc
echo "Building zaphfc in: `pwd`"
echo "-----------------------------------------------------"
echo ""
make clean; make
echo -e "Zaphfc build:\t\t`ls -l zaphfc.ko`" >>$LOGFILE
/bin/sleep $SLEEP_TIME
### Check if module already exists, if so rename, then copy new module to libs/extra directory
if [ -f $MODULES_DIRECTORY/zaphfc.ko ]
then
mv $MODULES_DIRECTORY/zaphfc.ko $MODULES_DIRECTORY/zaphfc.ko.`stat -c %Y $MODULES_DIRECTORY/zaphfc.ko`
fi
cp $SOURCE_DIRECTORY/$BRISTUFF_VERSION/zaphfc/zaphfc.ko $MODULES_DIRECTORY/
echo ""
echo "-----------------------------------------------------"
cd $SOURCE_DIRECTORY/$BRISTUFF_VERSION/asterisk-$ASTERISK_VERSION
echo "Building Asterisk in: `pwd`"
echo "-----------------------------------------------------"
echo ""
make clean; make; make install
echo -e "Asterisk build:\t\t`ls -l asterisk`" >>$LOGFILE
/bin/sleep $SLEEP_TIME
# -------------------------------------------
# Re-configure for new ISDN card
# -------------------------------------------
echo ""
echo "-----------------------------------------------------"
echo "Setting up zaptel configuration"
echo "-----------------------------------------------------"
echo ""
if [ 0 -eq $NUMBER_HFC_PCI ]
then
echo "It does not look as if you have the HFC based ISDN card installed in your system."
echo "(Though this test may not be foolproof)"
echo ""
echo "When you have the card installed you should edit:"
echo ""
echo "modprobe.conf and add:"
echo ""
echo "install zaphfc /sbin/modprobe --ignore-install zaphfc && /sbin/ztcfg"
echo ""
echo "and then edit:"
echo ""
echo "/etc/sysconfig/zaptel and add:"
echo ""
echo 'MODULES="$MODULES zaphfc" # HFC ISDN module'
echo ""
else
echo -e "lspci:\t\t\tShows $NUMBER_HFC_PCI HFC device(s)" >>$LOGFILE
## check if zaphfc is already in /etc/modprobe.conf
if [ 0 -eq `fgrep -c zaphfc /etc/modprobe.conf` ]
then
echo "install zaphfc /sbin/modprobe --ignore-install zaphfc && /sbin/ztcfg" >> /etc/modprobe.conf
echo -e "modprobe.conf:\t\tAdding zaphfc entry" >>$LOGFILE
fi
echo -e "modprobe.conf:\t\t`fgrep zaphfc /etc/modprobe.conf`" >>$LOGFILE
## check if zaphfc is already in /etc/sysconfig/zaptel
if [ 0 -eq `fgrep -c zaphfc /etc/sysconfig/zaptel` ]
then
echo " " >> /etc/sysconfig/zaptel
echo 'MODULES="$MODULES zaphfc" # HFC ISDN module' >> /etc/sysconfig/zaptel
echo -e "sysconfig/zaptel:\tAdding zaphfc entry" >>$LOGFILE
fi
echo -e "sysconfig/zaptel:\t`fgrep zaphfc /etc/sysconfig/zaptel`" >>$LOGFILE
echo "" >>$LOGFILE
echo ""
echo "-----------------------------------------------------"
echo "Attempting to load/unload zaphfc independantly of zaptel"
echo "-----------------------------------------------------"
echo ""
TRY_UNLOAD=0
echo -n "Loading...."
modprobe zaphfc
RC=$?
if [ 0 -ne $RC ]
then
echo -t "\nFAILED: modprobe exited reporting an error."
echo "FAILED: Unable to load zaphfc."
echo "FAILED: You will need to fix this before proceeding"
echo "Load zaphfc:\t\tFailed - modprobe returned exit code $RC" >>$LOGFILE
exit 0
else
echo Success: zaphfc reported no errors on loading
echo "Load zaphfc:\t\tSuccess - modprobe reported no errors on loading zaphfc" >>$LOGFILE
TRY_UNLOAD=1
fi
if [ $TRY_UNLOAD -eq 1 ]
then
echo -n "Unloading...."
rmmod zaphfc
RC=$?
if [ 0 -ne $RC ]
then
echo -t "\nFAILED: Failed to unload (unexpected). Not disastrous, but you should investigate later."
echo "Unload zaphfc:\t\tFailed - rmmod returned exit code $RC" >>$LOGFILE
else
echo "Success: zaphfc unloaded sucessfully."
echo "Unload zaphfc:\t\tSuccess - rmmod reported no errors on unloading" >>$LOGFILE
fi
fi
fi
# -------------------------------------------
# Restart system
# -------------------------------------------
echo ""
echo "-----------------------------------------------------"
echo "Loading zaptel and starting Asterisk"
echo "-----------------------------------------------------"
echo ""
echo ""
echo "************************************************************"
echo "* WARNING WARNING WARNING WARNING WARNING WARNING WARNING *"
echo "* IF you use any other zap hardware you need to *"
echo "* edit /etc/sysconfig/zaptel to re-enable the driver load *"
echo "* on zaptel start *"
echo "************************************************************"
echo ""
/sbin/service zaptel start
/bin/sleep $SLEEP_TIME
/usr/sbin/amportal start
echo ""
echo "-----------------------------------------------------"
echo "Checking contents of /proc/zaptel"
echo "-----------------------------------------------------"
echo ""
# Don't look for an HFC process unless we think there is actually an HFC card installed.
if [ 0 -ne $NUMBER_HFC_PCI ]
then
if [ 0 -eq `fgrep -c zaphfc /proc/zaptel/*` ]
then
echo "zaphfc not found in /proc/zaptel/ directory"
echo ""
echo 'Try rebooting, then run "cat /proc/zaptel/*" from a console prompt'
echo ""
echo -e "proc:\t\t\tzaphfc not found in /proc/zaptel/" >>$LOGFILE
echo "" >>$LOGFILE
echo "-----------------------------------------------------"
echo " Contents of this builds logfile:"
echo "-----------------------------------------------------"
cat $LOGFILE
else
cat /proc/zaptel/*
echo -e "proc:\t\t\tzaphfc found in /proc/zaptel/" >>$LOGFILE
fi
fi
echo
echo "************************************************************"
echo "* You now need to configure: *"
echo "* /etc/zaptel.conf *"
echo "* /etc/asterisk/zapata-auto.conf (or similar) *"
echo "************************************************************"
echo
cd $CURRENT_DIRECTORY
echo "" >>$LOGFILE
echo "FINISHED: Running $0 in $CURRENT_DIRECTORY on `date`" >>$LOGFILE
echo "" >>$LOGFILE
exit 0