summaryrefslogtreecommitdiff
path: root/board/massive_call/install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'board/massive_call/install.sh')
-rwxr-xr-xboard/massive_call/install.sh98
1 files changed, 98 insertions, 0 deletions
diff --git a/board/massive_call/install.sh b/board/massive_call/install.sh
new file mode 100755
index 0000000..23c7f8b
--- /dev/null
+++ b/board/massive_call/install.sh
@@ -0,0 +1,98 @@
+#!/bin/bash
+
+S_HOST="root"
+ASTERISK_PATH="/etc/asterisk/"
+DAHDI_PATH="/etc/dahdi/"
+
+usage()
+{
+cat << EOF
+usage: $0 OPTION ADDRESS...
+
+This script init at least one target designed by its IP ADDRESS on the NT or TE MODE.
+
+OPTIONS:
+ -h Show this message
+ -m=MODE either 'te' or 'nt'
+
+ADDRESS:
+ The IP address of at least one target to update.
+
+EXAMPLE:
+ $ $0 -m te 10.42.0.21 10.42.0.23
+
+EOF
+}
+
+exit_on_error() {
+ if [ ! $? -eq 0 ]
+ then
+ [ $# -gt 0 ] && echo $*
+ exit 1
+ fi
+}
+
+
+update()
+{
+ [ $# -lt 2 ]; exit_on_error "EE update() needs at least two args"
+ echo "Updating $2 in $1 mode"
+
+ S_HOST="$TARGET_HOST@$2"
+
+ scp system.conf.$1 $S_HOST:$DAHDI_PATH/system.conf ; exit_on_error "EE scp system.conf"
+ scp chan_dahdi.conf.$1 $S_HOST:$ASTERISK_PATH/chan_dahdi.conf ; exit_on_error "EE scp chan_d"
+ scp extensions.conf $S_HOST:$ASTERISK_PATH ; exit_on_error "EE scp exten"
+ ssh -T $S_HOST <<\EOI
+dahdi_cfg
+/etc/init.d/asterisk restart
+exit
+EOI
+ exit_on_error "Failed to copy files"
+}
+
+
+
+while getopts ":hm:" OPTION
+do
+ case $OPTION in
+ h)
+ usage
+ exit
+ ;;
+ m)
+ MODE=$OPTARG
+ ;;
+ ?)
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+shift $(( OPTIND -1 ))
+
+if [ $# -lt 1 ]
+then
+ echo "$0 needs at least one target ADDRESS, exiting"
+ usage
+ exit 1
+fi
+
+TARGET=$*
+
+case "$MODE" in
+ "te"|"TE" ) MODE="te";;
+ "nt"|"NT" ) MODE="nt";;
+ *) echo "Wrong MODE type, exiting"; exit 1;;
+esac
+
+set $TARGET
+for ip;
+do
+ update $MODE $ip
+done
+
+exit 0
+
+# vim: et:sw=2:sts=2