正在显示
6 个修改的文件
包含
248 行增加
和
25 行删除
| @@ -44,8 +44,8 @@ do | @@ -44,8 +44,8 @@ do | ||
| 44 | 44 | ||
| 45 | case "$option" in | 45 | case "$option" in |
| 46 | -*=*) | 46 | -*=*) |
| 47 | - value=`echo "$option" | sed -e 's/[-_a-zA-Z0-9]*=//'` | ||
| 48 | - option=`echo "$option" | sed -e 's/=[-_a-zA-Z0-9]*//'` | 47 | + value=`echo "$option" | sed -e 's|[-_a-zA-Z0-9/]*=||'` |
| 48 | + option=`echo "$option" | sed -e 's|=[-_a-zA-Z0-9/]*||'` | ||
| 49 | ;; | 49 | ;; |
| 50 | *) value="" ;; | 50 | *) value="" ;; |
| 51 | esac | 51 | esac |
| @@ -162,6 +162,7 @@ cat << END > ${SRS_MAKEFILE} | @@ -162,6 +162,7 @@ cat << END > ${SRS_MAKEFILE} | ||
| 162 | 162 | ||
| 163 | # install prefix. | 163 | # install prefix. |
| 164 | SRS_PREFIX=${SRS_PREFIX} | 164 | SRS_PREFIX=${SRS_PREFIX} |
| 165 | +DESTDIR=\$(SRS_PREFIX) | ||
| 165 | 166 | ||
| 166 | END | 167 | END |
| 167 | 168 | ||
| @@ -217,22 +218,22 @@ uninstall: | @@ -217,22 +218,22 @@ uninstall: | ||
| 217 | @rm -rf \$(SRS_PREFIX) | 218 | @rm -rf \$(SRS_PREFIX) |
| 218 | 219 | ||
| 219 | install-api: install | 220 | install-api: install |
| 220 | - @echo "mkdir \$(SRS_PREFIX)" | ||
| 221 | - @mkdir -p \$(SRS_PREFIX) | 221 | + @echo "mkdir \$(DESTDIR)" |
| 222 | + @mkdir -p \$(DESTDIR) | ||
| 222 | @echo "copy binary files" | 223 | @echo "copy binary files" |
| 223 | - @mkdir -p \$(SRS_PREFIX)/research/api-server | ||
| 224 | - @cp research/api-server/server.py \$(SRS_PREFIX)/research/api-server | ||
| 225 | - @mkdir -p \$(SRS_PREFIX)/objs/ffmpeg/bin | ||
| 226 | - @cp objs/ffmpeg/bin/ffmpeg \$(SRS_PREFIX)/objs/ffmpeg/bin | 224 | + @mkdir -p \$(DESTDIR)/research/api-server |
| 225 | + @cp research/api-server/server.py \$(DESTDIR)/research/api-server | ||
| 226 | + @mkdir -p \$(DESTDIR)/objs/ffmpeg/bin | ||
| 227 | + @cp objs/ffmpeg/bin/ffmpeg \$(DESTDIR)/objs/ffmpeg/bin | ||
| 227 | @echo "copy html files" | 228 | @echo "copy html files" |
| 228 | - @mkdir -p \$(SRS_PREFIX)/research/api-server/static-dir/players | ||
| 229 | - @cp research/api-server/static-dir/crossdomain.xml \$(SRS_PREFIX)/research/api-server/static-dir | ||
| 230 | - @cp research/api-server/static-dir/index.html \$(SRS_PREFIX)/research/api-server/static-dir | ||
| 231 | - @cp -r research/api-server/static-dir/players/* \$(SRS_PREFIX)/research/api-server/static-dir/players | 229 | + @mkdir -p \$(DESTDIR)/research/api-server/static-dir/players |
| 230 | + @cp research/api-server/static-dir/crossdomain.xml \$(DESTDIR)/research/api-server/static-dir | ||
| 231 | + @cp research/api-server/static-dir/index.html \$(DESTDIR)/research/api-server/static-dir | ||
| 232 | + @cp -r research/api-server/static-dir/players/* \$(DESTDIR)/research/api-server/static-dir/players | ||
| 232 | @echo "copy init.d script files" | 233 | @echo "copy init.d script files" |
| 233 | - @mkdir -p \$(SRS_PREFIX)/etc/init.d | ||
| 234 | - @cp etc/init.d/srs-api \$(SRS_PREFIX)/etc/init.d | ||
| 235 | - @sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(SRS_PREFIX)/etc/init.d/srs-api | 234 | + @mkdir -p \$(DESTDIR)/etc/init.d |
| 235 | + @cp etc/init.d/srs-api \$(DESTDIR)/etc/init.d | ||
| 236 | + @sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(DESTDIR)/etc/init.d/srs-api | ||
| 236 | @echo "" | 237 | @echo "" |
| 237 | @echo "api installed, to link and start api:" | 238 | @echo "api installed, to link and start api:" |
| 238 | @echo " sudo ln -sf /usr/local/srs/etc/init.d/srs-api /etc/init.d/srs-api" | 239 | @echo " sudo ln -sf /usr/local/srs/etc/init.d/srs-api /etc/init.d/srs-api" |
| @@ -241,18 +242,18 @@ install-api: install | @@ -241,18 +242,18 @@ install-api: install | ||
| 241 | @echo "@see: https://github.com/winlinvip/simple-rtmp-server/wiki/LinuxService" | 242 | @echo "@see: https://github.com/winlinvip/simple-rtmp-server/wiki/LinuxService" |
| 242 | 243 | ||
| 243 | install: | 244 | install: |
| 244 | - @echo "mkdir \$(SRS_PREFIX)" | ||
| 245 | - @mkdir -p \$(SRS_PREFIX) | 245 | + @echo "mkdir \$(DESTDIR)" |
| 246 | + @mkdir -p \$(DESTDIR) | ||
| 246 | @echo "copy binary files" | 247 | @echo "copy binary files" |
| 247 | - @mkdir -p \$(SRS_PREFIX)/objs | ||
| 248 | - @cp objs/srs \$(SRS_PREFIX)/objs | 248 | + @mkdir -p \$(DESTDIR)/objs |
| 249 | + @cp objs/srs \$(DESTDIR)/objs | ||
| 249 | @echo "copy srs conf files" | 250 | @echo "copy srs conf files" |
| 250 | - @mkdir -p \$(SRS_PREFIX)/conf | ||
| 251 | - @cp conf/*.conf \$(SRS_PREFIX)/conf | 251 | + @mkdir -p \$(DESTDIR)/conf |
| 252 | + @cp conf/*.conf \$(DESTDIR)/conf | ||
| 252 | @echo "copy init.d script files" | 253 | @echo "copy init.d script files" |
| 253 | - @mkdir -p \$(SRS_PREFIX)/etc/init.d | ||
| 254 | - @cp etc/init.d/srs \$(SRS_PREFIX)/etc/init.d | ||
| 255 | - @sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(SRS_PREFIX)/etc/init.d/srs | 254 | + @mkdir -p \$(DESTDIR)/etc/init.d |
| 255 | + @cp etc/init.d/srs \$(DESTDIR)/etc/init.d | ||
| 256 | + @sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(DESTDIR)/etc/init.d/srs | ||
| 256 | @echo "" | 257 | @echo "" |
| 257 | @echo "srs installed, to link and start srs:" | 258 | @echo "srs installed, to link and start srs:" |
| 258 | @echo " sudo ln -sf /usr/local/srs/etc/init.d/srs /etc/init.d/srs" | 259 | @echo " sudo ln -sf /usr/local/srs/etc/init.d/srs /etc/init.d/srs" |
trunk/scripts/_log.sh
0 → 100755
| 1 | +# import log utility and check the detail log file is ok | ||
| 2 | +# @param log the log file path, default to /dev/null | ||
| 3 | + | ||
| 4 | +####################################### | ||
| 5 | +# color echo. | ||
| 6 | +####################################### | ||
| 7 | +RED="\\e[31m" | ||
| 8 | +GREEN="\\e[32m" | ||
| 9 | +YELLOW="\\e[33m" | ||
| 10 | +BLACK="\\e[0m" | ||
| 11 | +POS="\\e[110G" | ||
| 12 | + | ||
| 13 | +# if need to log to file, change the log path. | ||
| 14 | +if [[ ! $log ]]; then | ||
| 15 | + log=/dev/null; | ||
| 16 | +fi | ||
| 17 | + | ||
| 18 | +ok_msg(){ | ||
| 19 | + echo -e "${1}${POS}${BLACK}[${GREEN} OK ${BLACK}]" | ||
| 20 | + | ||
| 21 | + # write to log file. | ||
| 22 | + echo "[info] ${1}" >> $log | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +warn_msg(){ | ||
| 26 | + echo -e "${1}${POS}${BLACK}[ ${YELLOW}WARN${BLACK} ]" | ||
| 27 | + | ||
| 28 | + # write to log file. | ||
| 29 | + echo "[error] ${1}" >> $log | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +failed_msg(){ | ||
| 33 | + echo -e "${1}${POS}${BLACK}[${RED}FAILED${BLACK}]" | ||
| 34 | + | ||
| 35 | + # write to log file. | ||
| 36 | + echo "[error] ${1}" >> $log | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +function check_log(){ | ||
| 40 | + log_dir="`dirname $log`" | ||
| 41 | + (mkdir -p ${log_dir} && sudo chmod 777 ${log_dir} && touch $log) | ||
| 42 | + ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "create log failed, ret=$ret"; return $ret; fi | ||
| 43 | + ok_msg "create log( ${log} ) success" | ||
| 44 | + | ||
| 45 | + echo "bravo-vms setup `date`" >> $log | ||
| 46 | + ok_msg "see detail log: tailf ${log}" | ||
| 47 | + | ||
| 48 | + return 0 | ||
| 49 | +} |
trunk/scripts/install.sh
0 → 100755
| 1 | +#!/bin/bash | ||
| 2 | + | ||
| 3 | +# user can config the following configs, then package. | ||
| 4 | +INSTALL=/usr/local/srs | ||
| 5 | + | ||
| 6 | +################################################################################## | ||
| 7 | +################################################################################## | ||
| 8 | +################################################################################## | ||
| 9 | +# discover the current work dir, the log and access. | ||
| 10 | +echo "argv[0]=$0" | ||
| 11 | +if [[ ! -f $0 ]]; then | ||
| 12 | + echo "directly execute the scripts on shell."; | ||
| 13 | + work_dir=`pwd` | ||
| 14 | +else | ||
| 15 | + echo "execute scripts in file: $0"; | ||
| 16 | + work_dir=`dirname $0`; work_dir=`(cd ${work_dir} && pwd)` | ||
| 17 | +fi | ||
| 18 | +product_dir=$work_dir | ||
| 19 | + | ||
| 20 | +log="${work_dir}/logs/package.`date +%s`.log" && . ${product_dir}/scripts/_log.sh && check_log | ||
| 21 | +ret=$?; if [[ $ret -ne 0 ]]; then exit $ret; fi | ||
| 22 | + | ||
| 23 | +# user must stop service first. | ||
| 24 | +ok_msg "check previous install" | ||
| 25 | +if [[ -f /etc/init.d/srs ]]; then | ||
| 26 | + /etc/init.d/srs status >/dev/null 2>&1 | ||
| 27 | + ret=$?; if [[ 0 -eq ${ret} ]]; then | ||
| 28 | + failed_msg "you must stop the service first: sudo /etc/init.d/srs stop"; | ||
| 29 | + exit 1; | ||
| 30 | + fi | ||
| 31 | +fi | ||
| 32 | +ok_msg "previous install checked" | ||
| 33 | + | ||
| 34 | +# backup old srs | ||
| 35 | +ok_msg "backup old srs" | ||
| 36 | +install_root=$INSTALL | ||
| 37 | +install_bin=$install_root/objs/srs | ||
| 38 | +if [[ -d $install_root ]]; then | ||
| 39 | + version="unknown" | ||
| 40 | + if [[ -f $install_bin ]]; then | ||
| 41 | + version=`$install_bin -v 2>/dev/stdout 1>/dev/null` | ||
| 42 | + fi | ||
| 43 | + | ||
| 44 | + backup_dir=${install_root}.`date "+%Y-%m-%d_%H-%M-%S"`.v-$version | ||
| 45 | + ok_msg "backup installed dir, version=$version" | ||
| 46 | + ok_msg " to=$backup_dir" | ||
| 47 | + mv $install_root $backup_dir >>$log 2>&1 | ||
| 48 | + ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "backup installed dir failed"; exit $ret; fi | ||
| 49 | + ok_msg "backup installed dir success" | ||
| 50 | +fi | ||
| 51 | +ok_msg "old srs backuped" | ||
| 52 | + | ||
| 53 | +# prepare files. | ||
| 54 | +ok_msg "prepare files" | ||
| 55 | +( | ||
| 56 | + sed -i "s|^ROOT=.*|ROOT=\"${INSTALL}\"|g" $work_dir/etc/init.d/srs | ||
| 57 | +) >> $log 2>&1 | ||
| 58 | +ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "prepare files failed"; exit $ret; fi | ||
| 59 | +ok_msg "prepare files success" | ||
| 60 | + | ||
| 61 | +# copy core files | ||
| 62 | +ok_msg "copy core components" | ||
| 63 | +( | ||
| 64 | + mkdir -p $install_root | ||
| 65 | + cp -r $work_dir/conf $install_root && | ||
| 66 | + cp -r $work_dir/etc $install_root && | ||
| 67 | + cp -r $work_dir/objs $install_root | ||
| 68 | +) >>$log 2>&1 | ||
| 69 | +ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "copy core components failed"; exit $ret; fi | ||
| 70 | +ok_msg "copy core components success" | ||
| 71 | + | ||
| 72 | +# install init.d scripts | ||
| 73 | +ok_msg "install init.d scripts" | ||
| 74 | +( | ||
| 75 | + rm -rf /etc/init.d/srs && | ||
| 76 | + ln -sf $install_root/etc/init.d/srs /etc/init.d/srs | ||
| 77 | +) >>$log 2>&1 | ||
| 78 | +ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install init.d scripts failed"; exit $ret; fi | ||
| 79 | +ok_msg "install init.d scripts success" | ||
| 80 | + | ||
| 81 | +# install system service | ||
| 82 | +lsb_release --id|grep "CentOS" >/dev/null 2>&1; os_id_centos=$? | ||
| 83 | +lsb_release --id|grep "Ubuntu" >/dev/null 2>&1; os_id_ubuntu=$? | ||
| 84 | +if [[ 0 -eq $os_id_centos ]]; then | ||
| 85 | + ok_msg "install system service for CentOS" | ||
| 86 | + /sbin/chkconfig --add srs && /sbin/chkconfig srs on | ||
| 87 | + ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install system service failed"; exit $ret; fi | ||
| 88 | + ok_msg "install system service success" | ||
| 89 | +elif [[ 0 -eq $os_id_ubuntu ]]; then | ||
| 90 | + ok_msg "install system service for Ubuntu" | ||
| 91 | + update-rc.d srs defaults | ||
| 92 | + ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install system service failed"; exit $ret; fi | ||
| 93 | + ok_msg "install system service success" | ||
| 94 | +else | ||
| 95 | + warn_msg "ignore and donot install system service for `lsb_release --id|awk '{print $3}'`." | ||
| 96 | +fi | ||
| 97 | + | ||
| 98 | +echo "" | ||
| 99 | +echo "see: https://github.com/winlinvip/simple-rtmp-server/wiki/LinuxService" | ||
| 100 | +echo "install success, you can:" | ||
| 101 | +echo -e "${GREEN} sudo /etc/init.d/srs start${BLACK}" | ||
| 102 | + | ||
| 103 | +exit 0 |
trunk/scripts/package.sh
0 → 100755
| 1 | +#!/bin/bash | ||
| 2 | + | ||
| 3 | +# user can config the following configs, then package. | ||
| 4 | +INSTALL=/usr/local/srs | ||
| 5 | + | ||
| 6 | +################################################################################## | ||
| 7 | +################################################################################## | ||
| 8 | +################################################################################## | ||
| 9 | +# discover the current work dir, the log and access. | ||
| 10 | +echo "argv[0]=$0" | ||
| 11 | +if [[ ! -f $0 ]]; then | ||
| 12 | + echo "directly execute the scripts on shell."; | ||
| 13 | + work_dir=`pwd` | ||
| 14 | +else | ||
| 15 | + echo "execute scripts in file: $0"; | ||
| 16 | + work_dir=`dirname $0`; work_dir=`(cd ${work_dir} && pwd)` | ||
| 17 | +fi | ||
| 18 | +work_dir=`(cd ${work_dir}/.. && pwd)` | ||
| 19 | +product_dir=$work_dir | ||
| 20 | +build_objs=${work_dir}/objs | ||
| 21 | +package_dir=${build_objs}/package | ||
| 22 | + | ||
| 23 | +log="${build_objs}/logs/package.`date +%s`.log" && . ${product_dir}/scripts/_log.sh && check_log | ||
| 24 | +ret=$?; if [[ $ret -ne 0 ]]; then exit $ret; fi | ||
| 25 | + | ||
| 26 | +# check os version | ||
| 27 | +os_name=`lsb_release --id|awk '{print $3}'` && | ||
| 28 | +os_release=`lsb_release --release|awk '{print $2}'` && | ||
| 29 | +os_major_version=`echo $os_release|awk -F '.' '{print $1}'` | ||
| 30 | +ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "lsb_release get os info failed."; exit $ret; fi | ||
| 31 | +ok_msg "target os is ${os_name}-${os_major_version} ${os_release}" | ||
| 32 | + | ||
| 33 | +# build srs | ||
| 34 | +# @see https://github.com/winlinvip/simple-rtmp-server/wiki/Build | ||
| 35 | +ok_msg "start build srs" | ||
| 36 | +( | ||
| 37 | + cd $work_dir && | ||
| 38 | + ./configure --with-ssl --with-hls --with-nginx --with-ffmpeg --with-http-callback --prefix=$INSTALL && | ||
| 39 | + make && rm -rf $package_dir && make DESTDIR=$package_dir install | ||
| 40 | +) >> $log 2>&1 | ||
| 41 | +ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "build srs failed"; exit $ret; fi | ||
| 42 | +ok_msg "build srs success" | ||
| 43 | + | ||
| 44 | +# copy extra files to package. | ||
| 45 | +ok_msg "start copy extra files to package" | ||
| 46 | +( | ||
| 47 | + cp $work_dir/scripts/install.sh $package_dir/INSTALL && | ||
| 48 | + sed -i "s|^INSTALL=.*|INSTALL=${INSTALL}|g" $package_dir/INSTALL && | ||
| 49 | + mkdir -p $package_dir/scripts && | ||
| 50 | + cp $work_dir/scripts/_log.sh $package_dir/scripts/_log.sh && | ||
| 51 | + chmod +x $package_dir/INSTALL | ||
| 52 | +) >> $log 2>&1 | ||
| 53 | +ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "copy extra files failed"; exit $ret; fi | ||
| 54 | +ok_msg "copy extra files success" | ||
| 55 | + | ||
| 56 | +# zip package. | ||
| 57 | +ok_msg "start zip package" | ||
| 58 | +( | ||
| 59 | + srs_version=`${build_objs}/srs -v 2>/dev/stdout 1>/dev/null` && | ||
| 60 | + zip_dir="SRS-${os_name}${os_major_version}-${srs_version}" && | ||
| 61 | + mv $package_dir ${build_objs}/${zip_dir} && | ||
| 62 | + cd ${build_objs} && zip -q -r ${zip_dir}.zip ${zip_dir} && | ||
| 63 | + mv ${build_objs}/${zip_dir} $package_dir | ||
| 64 | +) >> $log 2>&1 | ||
| 65 | +ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "zip package failed"; exit $ret; fi | ||
| 66 | +ok_msg "zip package success" | ||
| 67 | + | ||
| 68 | +ok_msg "srs package success" | ||
| 69 | + | ||
| 70 | +exit 0 |
| @@ -639,7 +639,7 @@ int SrsConfig::parse_options(int argc, char** argv) | @@ -639,7 +639,7 @@ int SrsConfig::parse_options(int argc, char** argv) | ||
| 639 | } | 639 | } |
| 640 | 640 | ||
| 641 | if (show_version) { | 641 | if (show_version) { |
| 642 | - printf("%s\n", RTMP_SIG_SRS_VERSION); | 642 | + fprintf(stderr, "%s\n", RTMP_SIG_SRS_VERSION); |
| 643 | } | 643 | } |
| 644 | 644 | ||
| 645 | if (show_help || show_version) { | 645 | if (show_help || show_version) { |
-
请 注册 或 登录 后发表评论