winlin

auto detect the sed command for osx.

@@ -504,11 +504,7 @@ if [ $__SRS_BUILD_NGINX = YES ]; then @@ -504,11 +504,7 @@ if [ $__SRS_BUILD_NGINX = YES ]; then
504 # srs will write ts/m3u8 file use current user, 504 # srs will write ts/m3u8 file use current user,
505 # nginx default use nobody, so cannot read the ts/m3u8 created by srs. 505 # nginx default use nobody, so cannot read the ts/m3u8 created by srs.
506 cp ${SRS_OBJS}/nginx/conf/nginx.conf ${SRS_OBJS}/nginx/conf/nginx.conf.bk 506 cp ${SRS_OBJS}/nginx/conf/nginx.conf ${SRS_OBJS}/nginx/conf/nginx.conf.bk
507 - if [ $OS_IS_OSX = YES ]; then  
508 - sed -i '' "s/^.user nobody;/user `whoami`;/g" ${SRS_OBJS}/nginx/conf/nginx.conf  
509 - else  
510 - sed -i "s/^.user nobody;/user `whoami`;/g" ${SRS_OBJS}/nginx/conf/nginx.conf  
511 - fi 507 + $SED '' "s/^.user nobody;/user `whoami`;/g" ${SRS_OBJS}/nginx/conf/nginx.conf
512 fi 508 fi
513 509
514 # the demo dir. 510 # the demo dir.
1 #!/bin/bash 1 #!/bin/bash
2 2
  3 +OS_IS_OSX=NO
  4 +uname -s|grep Darwin >/dev/null 2>&1
  5 +ret=$?; if [[ 0 -eq $ret ]]; then
  6 + OS_IS_OSX=YES
  7 +fi
  8 +echo "Is OSX: ${OS_IS_OSX}"
  9 +
  10 +# the sed command
  11 +SED="sed -i"
  12 +if [ $OS_IS_OSX = YES ]; then SED="sed -i ''"; fi
  13 +
3 # when export srs-librtmp single files 14 # when export srs-librtmp single files
4 # package the whole project to srs_librtmp.h and srs_librtmp.cpp 15 # package the whole project to srs_librtmp.h and srs_librtmp.cpp
5 # 16 #
@@ -59,7 +70,7 @@ function build_module_hpp() @@ -59,7 +70,7 @@ function build_module_hpp()
59 for item in ${SRS_LIBRTMP_OBJS[*]}; do 70 for item in ${SRS_LIBRTMP_OBJS[*]}; do
60 FILE_NAME="${item%.*}" 71 FILE_NAME="${item%.*}"
61 echo "// following is generated by ${FILE_NAME}.hpp" >> $FILE && 72 echo "// following is generated by ${FILE_NAME}.hpp" >> $FILE &&
62 - sed -i "s|#include <srs_|//#include <srs_|g" $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.hpp && 73 + $SED "s|#include <srs_|//#include <srs_|g" $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.hpp &&
63 cat $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.hpp >>$FILE 74 cat $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.hpp >>$FILE
64 ret=$?; if [[ $ret -ne 0 ]]; then 75 ret=$?; if [[ $ret -ne 0 ]]; then
65 echo -e "${RED}failed to generate the srs_librtmp.cpp by ${FILE_NAME}.hpp. {${BLACK}" 76 echo -e "${RED}failed to generate the srs_librtmp.cpp by ${FILE_NAME}.hpp. {${BLACK}"
@@ -78,7 +89,7 @@ function build_module_cpp() @@ -78,7 +89,7 @@ function build_module_cpp()
78 for item in ${SRS_LIBRTMP_OBJS[*]}; do 89 for item in ${SRS_LIBRTMP_OBJS[*]}; do
79 FILE_NAME="${item%.*}" 90 FILE_NAME="${item%.*}"
80 echo "// following is generated by ${FILE_NAME}.cpp" >> $FILE && 91 echo "// following is generated by ${FILE_NAME}.cpp" >> $FILE &&
81 - sed -i "s|#include <srs_|//#include <srs_|g" $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.cpp && 92 + $SED "s|#include <srs_|//#include <srs_|g" $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.cpp &&
82 cat $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.cpp >>$FILE 93 cat $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.cpp >>$FILE
83 ret=$?; if [[ $ret -ne 0 ]]; then 94 ret=$?; if [[ $ret -ne 0 ]]; then
84 echo -e "${RED}failed to generate the srs_librtmp.cpp by ${FILE_NAME}.cpp. {${BLACK}" 95 echo -e "${RED}failed to generate the srs_librtmp.cpp by ${FILE_NAME}.cpp. {${BLACK}"