6
KVERS=${KVERS:-`uname -r`}
7
MODULES_DIR="$DESTDIR/lib/modules/$KVERS/misc"
9
AST_SCRIPT=/etc/init.d/asterisk
10
# Use this file to pass options to modules:
11
PERLLIBDIR=`perl -V:sitelib | cut -d "'" -f 2`
13
# Manual list of modules. They will be loaded by insmod.
14
# If reside in a subdir, add it explicitly.
18
# this one *is* resolved recusively.
19
# the only reason to set a different value is if you use hpec / oslec,
20
# as Zaptel depends on them.
21
REMOVE_MODULES="zaptel"
23
if [ -r $DESTDIR/live.conf ]; then . $DESTDIR/live.conf; fi
25
# Give priority to our installed binaries:
26
PATH=$DESTDIR/sbin:$DESTDIR/usr/sbin:$PATH
29
# TODO: If you already use PERL5DIR, please fix this part:
30
PERL5LIB="$DESTDIR/$PERLLIBDIR"
33
# the same as xpp/utils/zaptel_drivers .
34
# With the remote mode, I can't rely on files in the source directory.
36
perl -MZaptel::Hardware -e '
37
my $hardware = Zaptel::Hardware->scan;
38
print join(" ", $hardware->drivers);
42
# Detect the modules used in the system:
43
for mod in `zaptel_drivers`; do
46
MODULES_LOAD="$MODULES_LOAD xpp/xpp xpp/xpd_fxs"
47
MODULES_LOAD="$MODULES_LOAD xpp/xpd_fxo xpp/xpd_pri"
48
MODULES_LOAD="$MODULES_LOAD xpp/xpp_usb"
50
wctdm24xxp | wct4xxp | wcte12xp | wctc4xp)
51
MODULES_LOAD="$MODULES_LOAD $mod/$mod"
54
: # requires different handling
57
MODULES_LOAD="$MODULES_LOAD $mod"
62
# Initialize the Xorcom Astribank (xpp/) using perl utiliites:
63
# intended to replace all the the three functions below if user has
64
# installed the zaptel-perl utilities.
66
# do nothing if there are no astribank devices:
67
if ! grep -q connected /proc/xpp/xbuses 2>/dev/null; then return 0; fi
69
echo "Waiting for Astribank devices to initialize:"
70
cat /proc/xpp/XBUS-[0-9]*/waitfor_xpds 2>/dev/null || true
72
# overriding locales for the above two, as perl can be noisy
73
# when locales are missing.
74
# No register all the devices if they didn't auto-register:
75
LC_ALL=C zt_registration on
77
# this one could actually be run after ztcfg:
78
LC_ALL=C xpp_sync "$XPP_SYNC"
81
# recursively unload a module and its dependencies, if possible.
82
# where's modprobe -r when you need it?
83
# inputs: module to unload.
84
# returns: the result from
87
line=`lsmod 2>/dev/null | grep "^$1 "`
88
if [ "$line" = '' ]; then return; fi # module was not loaded
91
# $1: the original module, $2: size, $3: refcount, $4: deps list
92
mods=`echo $4 | tr , ' '`
93
# xpp_usb keeps the xpds below busy if an xpp hardware is
94
# connected. Hence must be removed before them:
95
case "$module" in xpd_*) mods="xpp_usb $mods";; esac
97
# run in a subshell, so it won't step over our vars:
99
# TODO: the following is probably the error handling we want:
100
# if [ $? != 0 ]; then return 1; fi
107
echo "$me: Run Zaptel in a test environment"
108
echo 'Version: $Id: live_zap 4257 2008-05-12 22:19:00Z tzafrir $'
110
echo "Usage: equivalent of:"
111
echo "$me install make install"
112
echo "$me config make config"
113
echo "$me unload /etc/init.d/zaptel stop"
114
echo "$me load /etc/init.d/zaptel start"
115
echo "$me reload /etc/init.d/zaptel restart"
116
echo "$me rsync TARGET (copies file to /tmp/live in TARGET)"
117
echo "$me exec COMMAND (Runs COMMAND in 'live' environment)"
123
make install DESTDIR=$DESTDIR DYNFS=yes "$@"
127
make config DESTDIR=$DESTDIR "$@"
128
mkdir -p $DESTDIR/etc/asterisk
131
if [ $# -ne 2 ]; then
132
echo >&2 "$0: Error: rsync requires a target parameter".
135
# copy the script itself and the installed directory to the
137
rsync -ai "$0" $DESTDIR "$2:/tmp/"
141
for mod in $REMOVE_MODULES; do
146
# TODO: Find a way to use modprobe.
147
# Or implement a way to pass arguments to modules here (yuck)
148
for module in $MODULES_LOAD; do
149
eval module_args="\$`basename ${module}`_ARGS"
150
insmod $MODULES_DIR/$module.ko $module_args
153
ZAPTEL_DEFAULTS=$DESTDIR/live.conf \
154
ZAPTEL_BOOT_DEBIAN=$DESTDIR/live.conf \
155
ZAPTEL_BOOT_FEDORA=$DESTDIR/live.conf \
156
ZAPCONF_FILE=$DESTDIR/etc/zaptel.conf \
157
ZAPATA_FILE=$DESTDIR/etc/asterisk/zapata-channels.conf \
159
ztcfg -c $DESTDIR/etc/zaptel.conf
160
# TODO: fxotune, hpec
161
# or find a way to reuse init.d start sequence.
163
# TODO: A local copy of Asterisk, configured with zapconf.
164
# doable, but trickier.
172
if [ $# -lt 2 ]; then
173
# No command given: start a subshell in the environemnt
174
# of the "live" system:
175
echo >&2 "$0: Error: exec requires a command to run"
179
# Command given: run it:
187
echo >&2 "$0: Error: incorrect command \"$1\". Aborting"