Currently, the code assumes that the Freeswitch executable is
at /usr/local/freeswitch/bin/freeswitch, and does no checking
whatsoever.  Based on feedback I've gotten, I've implemented a new
strategy:

./configure checks where the Freeswitch executable is located.
Currently, it only checks /usr/local/freeswtich/bin/freeswitch, but
alternative locations can be given with the --with-freeswitch switch.

If Freeswitch is found, FREESWITCH_PREFIX is set accordingly.  If
Freeswitch is not found, a warning is given, and FREESWITCH_PREFIX is
set to /usr/local/freeswitch.

At start-up time, "freeswitch.sh --configtest" tests whether
FREESWITCH_PREFIX/bin/freeswitch is present and executable.  If not, it
prints an error and returns a non-zero status.

The attached patch implements this strategy, along with a few minor
fixes.  I'd like feedback.

Dale

Index: sipXproxy/bin/sipxcallresolver.sh.in
===================================================================
--- sipXproxy/bin/sipxcallresolver.sh.in	(revision 15340)
+++ sipXproxy/bin/sipxcallresolver.sh.in	(working copy)
@@ -52,7 +52,7 @@
 assertRoot() {
     user=`whoami`
     if [ "${user}" != "root" ]; then
-      echo_error "Error: Must be root to run sipxcallresolver.sh script."
+      echo "Error: Must be root to run sipxcallresolver.sh script." >&2
       exit 1
     fi
 }
Index: sipXfreeSwitch/configure.ac
===================================================================
--- sipXfreeSwitch/configure.ac	(revision 15340)
+++ sipXfreeSwitch/configure.ac	(working copy)
@@ -15,6 +15,7 @@
 
 SFAC_INIT_FLAGS
 CHECK_GENERATE_MANPAGES
+CHECK_FREESWITCH
 
 AC_CONFIG_FILES([
   Makefile 
Index: sipXfreeSwitch/bin/freeswitch.sh.in
===================================================================
--- sipXfreeSwitch/bin/freeswitch.sh.in	(revision 15340)
+++ sipXfreeSwitch/bin/freeswitch.sh.in	(working copy)
@@ -10,6 +10,8 @@
 Status=0
 Args=""
 
+. @SIPX_LIBEXECDIR@/sipx-utils.sh
+
 iam=`whoami`
 
 while [ $# -ne 0 ]
@@ -90,15 +92,21 @@
            @SIPX_LIBEXECDIR@/setup.d/freeswitch_setup.sh
         else
            Status=1
-           echo -e "\n Invalid FreeSWITCH folders & files permissions, run 'freeswitch.sh --configtest' as root to fix this \n"
+           echo -e "\n Invalid FreeSWITCH folders & files permissions, run 'freeswitch.sh --configtest' as root to fix this \n" >&2
         fi  
      fi
+
      # check validity of xml routing rules
 #     @SIPX_BINDIR@/sipx-validate-xml @FREESWITCH_PREFIX@/conf/freeswitch.xml
-#     Status=$?
+#     Status=$((${Status} + $?))
 
+     if [ ! -x @FREESWITCH_PREFIX@/bin/freeswitch ]
+     then
+	 echo "Error: FreeSWITCH executable is not at @FREESWITCH_PREFIX@/bin/freeswitch" >&2
+	 Status=$((${Status} + 1))
+     fi
+
      ;;
 esac
 
 exit $Status
-
Index: config/sipXlib.m4
===================================================================
--- config/sipXlib.m4	(revision 15340)
+++ config/sipXlib.m4	(working copy)
@@ -87,9 +87,6 @@
     AC_SUBST(SIPX_VARLIB,  [${localstatedir}/lib/sipxpbx])
     AC_SUBST(SIPX_VXMLDATADIR,[${localstatedir}/sipxdata/mediaserver/data])
 
-    # Freeswitch prefix directory
-    AC_SUBST(FREESWITCH_PREFIX,  [/usr/local/freeswitch])
-
     ## Used in a number of different project and subjective where this should really go
     ## INSTALL instruction assume default, otherwise safe to change/override
     AC_ARG_VAR(wwwdir, [Web root for web content, default is ${datadir}/www. \
@@ -168,7 +165,7 @@
     -e 's/^ *\$ .*\/configure *//' \
     config.log`
 
-  ## Strip out configure switched that cause issue in RPM spec file
+  ## Strip out configure switches that cause issue in RPM spec file
   ## configure switch. Does not support spaces in paths
   for a in $ConfigureArgs; do
     case ${a} in
Index: config/general.m4
===================================================================
--- config/general.m4	(revision 15340)
+++ config/general.m4	(working copy)
@@ -1433,6 +1433,35 @@
     fi
 ])dnl
 
+# ============ F R E E S W I T C H ==================
+AC_DEFUN([CHECK_FREESWITCH],
+[   AC_MSG_CHECKING([for FreeSWITCH])
+    AC_ARG_WITH(freeswitch,
+                [--with-freeswitch=PATH to FreeSWITCH install directory],
+		[freeswitch_path=$withval],
+		[freeswitch_path="/usr/local/freeswitch"]
+                )
+    for dir in $freeswitch_path ; do
+        freeswitch_dir="$dir"
+        if test -x "$dir/bin/freeswitch"; then
+            found_freeswitch="yes";
+            break;
+        fi
+    done
+
+    if test x_$found_freeswitch = x_yes; then
+        AC_MSG_RESULT([    FreeSWITCH installed in $freeswitch_dir])
+    else
+        AC_MSG_WARN([    'bin/freeswitch' not in any of: $freeswitch_path])
+        freeswitch_dir="/usr/local/freeswitch"
+        AC_MSG_WARN([    assuming it will be in $freeswitch_dir])
+    fi
+    AC_SUBST(FREESWITCH_PREFIX, $freeswitch_dir)
+],
+[
+    AC_MSG_RESULT(yes)
+])dnl
+
 # ================== COMPILER VENDOR ====================================
 
 AC_DEFUN([AX_COMPILER_VENDOR],
Index: sipXconfig/configure.ac
===================================================================
--- sipXconfig/configure.ac	(revision 15340)
+++ sipXconfig/configure.ac	(working copy)
@@ -46,6 +46,7 @@
 CHECK_RUBY_MODULE([soap/wsdlDriver])
 CHECK_GEM([0.8.11])
 CHECK_RAKE([0.7])
+CHECK_FREESWITCH
 # CHECK_RPM_DEBUG
 
 
_______________________________________________
sipx-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-dev
Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev

Reply via email to