run.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. src_dir='src'
  3. if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi
  4. # linux shell color support.
  5. RED="\\033[31m"
  6. GREEN="\\033[32m"
  7. YELLOW="\\033[33m"
  8. BLACK="\\033[0m"
  9. ./etc/init.d/srs-demo restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi
  10. echo "启动SRS服务器成功"
  11. ./etc/init.d/srs-demo-19350 restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS转发服务器失败"; exit $ret; fi
  12. echo "启动SRS转发服务器成功"
  13. ./etc/init.d/srs-api restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动API服务器失败"; exit $ret; fi
  14. echo "启动API服务器成功"
  15. ip=`ifconfig|grep "inet "|grep -v "127.0.0.1"|awk -F 'inet ' 'NR==1 {print $2}'|awk '{print $1}'|sed "s/addr://g"`
  16. port=8085
  17. cat<<END
  18. 默认的12路流演示:
  19. http://$ip:$port/players
  20. 默认的播放器流演示:
  21. http://$ip:$port/players/srs_player.html?vhost=players
  22. 推流(主播)应用演示:
  23. http://$ip:$port/players/srs_publisher.html?vhost=players
  24. 视频会议(聊天室)应用演示:
  25. http://$ip:$port/players/srs_chat.html?vhost=players
  26. 默认的测速应用演示:
  27. http://$ip:$port/players/srs_bwt.html?key=35c9b402c12a7246868752e2878f7e0e&vhost=bandcheck.srs.com
  28. END
  29. which getenforce >/dev/null 2>&1
  30. if [[ 0 -eq $? && `getenforce` != 'Disabled' ]]; then
  31. echo -e "${RED}请关闭selinux:${BLACK}";
  32. echo -e "${RED} 打开配置文件:sudo vi /etc/sysconfig/selinux${BLACK}";
  33. echo -e "${RED} 修改为:SELINUX=disabled${BLACK}";
  34. echo -e "${RED} 重启系统:sudo reboot${BLACK}";
  35. fi
  36. if [[ -f /etc/init.d/iptables ]]; then
  37. sudo /etc/init.d/iptables status >/dev/null 2>&1;
  38. if [[ $? -ne 3 ]]; then
  39. echo -e "${RED}请关闭防火墙:${BLACK}";
  40. echo -e "${RED} sudo /etc/init.d/iptables stop${BLACK}";
  41. fi
  42. fi
  43. echo -e "${GREEN}请在hosts中添加一行:${BLACK}"
  44. echo -e "${RED} $ip demo.srs.com${BLACK}"
  45. echo -e "${GREEN}演示地址:${BLACK}"
  46. echo -e "${RED} http://$ip:$port${BLACK}"
  47. echo -e "@see https://github.com/ossrs/srs/wiki/v1_CN_SampleDemo"