diff options
Diffstat (limited to 'asterisk-load-tests/install.sh')
-rwxr-xr-x | asterisk-load-tests/install.sh | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/asterisk-load-tests/install.sh b/asterisk-load-tests/install.sh new file mode 100755 index 0000000..8544cfa --- /dev/null +++ b/asterisk-load-tests/install.sh @@ -0,0 +1,137 @@ +#!/bin/bash +# TODO: Check how to deal with anknown boards IP addresses + +FULL_TEST="1121122213231424511211" + +PCB="root@192.168.0." +ASTERISK_PATH="/etc/asterisk/" +DAHDI_PATH="/etc/dahdi/" + +XHD_HST="xivo-hardware-dev" +SCENARIO_PATH="/home/proformatique/load-tester/load-tester/scenarios/call-then-hangup/" +scenario_cmd="sipp -inf users.csv -sf scenario.xml -i 127.0.0.1 -r 1.0 -d 1000 -rp 9000 127.0.0.1" + + + +usage() +{ +cat << EOF +usage: $0 [OPTIONS] ADDRESS + +This script init a load_tester scenario and launch it. You should read the README file.. + +OPTIONS: + -h Show this message + -n=NUM The dial number, default is for the whole test + -u Update the config files on the target (PCB) and host (XHD) + +ADDRESS: + The IP address last byte of the targeted PCB + +EXAMPLE: + $ $0 -u -n=13231411 84 + +EOF +} + +exit_on_error() { + if [ ! $? -eq 0 ] + then + [ $# -gt 0 ] && echo $* + exit 1 + fi +} + +# +# Configure PCB and XHD +# +update() +{ + PCB="$PCB$BYTE" + scp pcb/system.conf $PCB:$DAHDI_PATH || exit_on_error "EE scp PCB" + scp pcb/extensions.conf $PCB:$ASTERISK_PATH || exit_on_error "EE scp PCB" + scp pcb/chan_dahdi.conf $PCB:$ASTERISK_PATH || exit_on_error "EE scp PCB" + ssh -T $PCB <<\EOI +dahdi_cfg +/etc/init.d/asterisk restart +exit +EOI + exit_on_error "EE dahdi and asterisk on PCB" + + sudo cp xhd/system.conf $DAHDI_PATH || exit_on_error "EE cp on XHD" + sudo cp xhd/extensions.conf $ASTERISK_PATH || exit_on_error "EE cp on XHD" + sudo cp xhd/chan_dahdi.conf $ASTERISK_PATH || exit_on_error "EE cp on XHD" + sudo dahdi_cfg || exit_on_error "EE dahdi_cfg XHD" + sudo /etc/init.d/asterisk stop || exit_on_error "EE asterisk stop XHD" + sleep 1 + sudo /etc/init.d/asterisk start || exit_on_error "EE asterisk start XHD" +} + + + +while getopts ":hn:u" OPTION +do + case $OPTION in + h) + usage + exit + ;; + n) + NUMBER=$OPTARG + ;; + u) + INIT=1 + ;; + ?) + usage + exit 1 + ;; + esac +done + +shift $(( OPTIND -1 )) + +if [ ! $# -eq 1 ] +then + echo "$0 needs one ADDRESS, exiting" + usage + exit 1 +fi + +BYTE=$* + +# +# Several checks +# +hstname=`hostname` +if [ ! $hstname = $XHD_HST ] +then + echo "This script is intended to be run from XHD, exiting" + exit 1 +fi + +if [ ! `which sipp` ] +then + echo "This script needs \`sipp' on your PATH, exiting" + exit 1 +fi + +if [ ! -d $SCENARIO_PATH ] +then + echo "Path not found:\`$SCENARIO_PATH', exiting" + exit 1 +fi + +[ -z $INIT ] || update +[ -z $NUMBER ] && NUMBER=$FULL_TEST + +# +# Running the test +# +echo Running the test... +H=$PWD +cd $SCENARIO_PATH +$scenario_cmd -s $NUMBER +cd $H + +exit 0 |