|
| 1 | +#!/bin/bash |
| 2 | +## |
| 3 | +## Configures rvd.xml based on global configuration options in restcomm.conf and advanced.conf. |
| 4 | +## |
| 5 | +## usage: |
| 6 | +## |
| 7 | +## ./config-rvd-logging.sh - adds handler and logger (INFO) elements if missing |
| 8 | +## ./config-rvd-logging.sh DEBUG - creates or updates loggers by setting level to DEBUG |
| 9 | +## ./config-rvd-logging.sh DEBUG FILE - creates or updates loggers (DEBUG) but also configures them to use the 'FILE' periodic handler (main restcomm log) |
| 10 | +## |
| 11 | +## requirements: |
| 12 | +## |
| 13 | +## RESTCOMM_HOME env variable to be set |
| 14 | +## rvd.xml should be in place (under $RESTCOMM_HOME/standalone/deployments/restcomm-rvd.war) |
| 15 | +## |
| 16 | +## Author: otsakir@gmail.com - Orestis Tsakiridis |
| 17 | + |
| 18 | +# Variables |
| 19 | +RVD_ROOT=$RESTCOMM_HOME/standalone/deployments/restcomm-rvd.war |
| 20 | +RVD_XML_FILE=$RVD_ROOT/WEB-INF/rvd.xml |
| 21 | + |
| 22 | +updateVideoSupport() { |
| 23 | + matchesCount=`xmlstarlet sel -t -v "count(/rvd/videoSupport)" "$RVD_XML_FILE"` |
| 24 | + if [ $matchesCount -ge 1 ]; then |
| 25 | + xmlstarlet ed -P -u "/rvd/videoSupport" -v "$1" "$RVD_XML_FILE" > ${RVD_XML_FILE}_tmp |
| 26 | + mv ${RVD_XML_FILE}_tmp ${RVD_XML_FILE} |
| 27 | + else |
| 28 | + xmlstarlet ed -P -s "/rvd" -t elem -n "videoSupport" -v "$1" "$RVD_XML_FILE" > ${RVD_XML_FILE}_tmp |
| 29 | + mv ${RVD_XML_FILE}_tmp ${RVD_XML_FILE} |
| 30 | + fi |
| 31 | +} |
| 32 | + |
| 33 | +updateMaxMediaFileSize() { |
| 34 | + matchesCount=`xmlstarlet sel -t -v "count(/rvd/maxMediaFileSize)" "$RVD_XML_FILE"` |
| 35 | + if [ $matchesCount -ge 1 ]; then |
| 36 | + xmlstarlet ed -P -u "/rvd/maxMediaFileSize" -v "$1" "$RVD_XML_FILE" > ${RVD_XML_FILE}_tmp |
| 37 | + mv ${RVD_XML_FILE}_tmp ${RVD_XML_FILE} |
| 38 | + else |
| 39 | + xmlstarlet ed -P -s "/rvd" -t elem -n "maxMediaFileSize" -v "$1" "$RVD_XML_FILE" > ${RVD_XML_FILE}_tmp |
| 40 | + mv ${RVD_XML_FILE}_tmp ${RVD_XML_FILE} |
| 41 | + fi |
| 42 | +} |
| 43 | + |
| 44 | +# MAIN |
| 45 | + |
| 46 | +if [ -z "$RESTCOMM_HOME" ] |
| 47 | +then |
| 48 | + echo "RESTCOMM_HOME env variable not set. Aborting." |
| 49 | + exit 1 |
| 50 | +fi |
| 51 | +if [ ! -f "$RVD_XML_FILE" ] |
| 52 | +then |
| 53 | + echo "rvd.xml not found. Aborting." |
| 54 | + return |
| 55 | +fi |
| 56 | + |
| 57 | +echo "Configuring RVD" |
| 58 | + |
| 59 | +if [ "$RVD_VIDEO_SUPPORT" = true ] ; then |
| 60 | + updateVideoSupport true |
| 61 | +else |
| 62 | + updateVideoSupport false |
| 63 | +fi |
| 64 | +updateMaxMediaFileSize "$RVD_MAX_MEDIA_FILE_SIZE" |
| 65 | +echo "Updated rvd.xml" |
| 66 | + |
0 commit comments