mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
add package and install script
This commit is contained in:
parent
34efa15118
commit
ade3630fa6
6 changed files with 248 additions and 25 deletions
|
@ -44,8 +44,8 @@ do
|
||||||
|
|
||||||
case "$option" in
|
case "$option" in
|
||||||
-*=*)
|
-*=*)
|
||||||
value=`echo "$option" | sed -e 's/[-_a-zA-Z0-9]*=//'`
|
value=`echo "$option" | sed -e 's|[-_a-zA-Z0-9/]*=||'`
|
||||||
option=`echo "$option" | sed -e 's/=[-_a-zA-Z0-9]*//'`
|
option=`echo "$option" | sed -e 's|=[-_a-zA-Z0-9/]*||'`
|
||||||
;;
|
;;
|
||||||
*) value="" ;;
|
*) value="" ;;
|
||||||
esac
|
esac
|
||||||
|
|
45
trunk/configure
vendored
45
trunk/configure
vendored
|
@ -162,6 +162,7 @@ cat << END > ${SRS_MAKEFILE}
|
||||||
|
|
||||||
# install prefix.
|
# install prefix.
|
||||||
SRS_PREFIX=${SRS_PREFIX}
|
SRS_PREFIX=${SRS_PREFIX}
|
||||||
|
DESTDIR=\$(SRS_PREFIX)
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -217,22 +218,22 @@ uninstall:
|
||||||
@rm -rf \$(SRS_PREFIX)
|
@rm -rf \$(SRS_PREFIX)
|
||||||
|
|
||||||
install-api: install
|
install-api: install
|
||||||
@echo "mkdir \$(SRS_PREFIX)"
|
@echo "mkdir \$(DESTDIR)"
|
||||||
@mkdir -p \$(SRS_PREFIX)
|
@mkdir -p \$(DESTDIR)
|
||||||
@echo "copy binary files"
|
@echo "copy binary files"
|
||||||
@mkdir -p \$(SRS_PREFIX)/research/api-server
|
@mkdir -p \$(DESTDIR)/research/api-server
|
||||||
@cp research/api-server/server.py \$(SRS_PREFIX)/research/api-server
|
@cp research/api-server/server.py \$(DESTDIR)/research/api-server
|
||||||
@mkdir -p \$(SRS_PREFIX)/objs/ffmpeg/bin
|
@mkdir -p \$(DESTDIR)/objs/ffmpeg/bin
|
||||||
@cp objs/ffmpeg/bin/ffmpeg \$(SRS_PREFIX)/objs/ffmpeg/bin
|
@cp objs/ffmpeg/bin/ffmpeg \$(DESTDIR)/objs/ffmpeg/bin
|
||||||
@echo "copy html files"
|
@echo "copy html files"
|
||||||
@mkdir -p \$(SRS_PREFIX)/research/api-server/static-dir/players
|
@mkdir -p \$(DESTDIR)/research/api-server/static-dir/players
|
||||||
@cp research/api-server/static-dir/crossdomain.xml \$(SRS_PREFIX)/research/api-server/static-dir
|
@cp research/api-server/static-dir/crossdomain.xml \$(DESTDIR)/research/api-server/static-dir
|
||||||
@cp research/api-server/static-dir/index.html \$(SRS_PREFIX)/research/api-server/static-dir
|
@cp research/api-server/static-dir/index.html \$(DESTDIR)/research/api-server/static-dir
|
||||||
@cp -r research/api-server/static-dir/players/* \$(SRS_PREFIX)/research/api-server/static-dir/players
|
@cp -r research/api-server/static-dir/players/* \$(DESTDIR)/research/api-server/static-dir/players
|
||||||
@echo "copy init.d script files"
|
@echo "copy init.d script files"
|
||||||
@mkdir -p \$(SRS_PREFIX)/etc/init.d
|
@mkdir -p \$(DESTDIR)/etc/init.d
|
||||||
@cp etc/init.d/srs-api \$(SRS_PREFIX)/etc/init.d
|
@cp etc/init.d/srs-api \$(DESTDIR)/etc/init.d
|
||||||
@sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(SRS_PREFIX)/etc/init.d/srs-api
|
@sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(DESTDIR)/etc/init.d/srs-api
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "api installed, to link and start api:"
|
@echo "api installed, to link and start api:"
|
||||||
@echo " sudo ln -sf /usr/local/srs/etc/init.d/srs-api /etc/init.d/srs-api"
|
@echo " sudo ln -sf /usr/local/srs/etc/init.d/srs-api /etc/init.d/srs-api"
|
||||||
|
@ -241,18 +242,18 @@ install-api: install
|
||||||
@echo "@see: https://github.com/winlinvip/simple-rtmp-server/wiki/LinuxService"
|
@echo "@see: https://github.com/winlinvip/simple-rtmp-server/wiki/LinuxService"
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@echo "mkdir \$(SRS_PREFIX)"
|
@echo "mkdir \$(DESTDIR)"
|
||||||
@mkdir -p \$(SRS_PREFIX)
|
@mkdir -p \$(DESTDIR)
|
||||||
@echo "copy binary files"
|
@echo "copy binary files"
|
||||||
@mkdir -p \$(SRS_PREFIX)/objs
|
@mkdir -p \$(DESTDIR)/objs
|
||||||
@cp objs/srs \$(SRS_PREFIX)/objs
|
@cp objs/srs \$(DESTDIR)/objs
|
||||||
@echo "copy srs conf files"
|
@echo "copy srs conf files"
|
||||||
@mkdir -p \$(SRS_PREFIX)/conf
|
@mkdir -p \$(DESTDIR)/conf
|
||||||
@cp conf/*.conf \$(SRS_PREFIX)/conf
|
@cp conf/*.conf \$(DESTDIR)/conf
|
||||||
@echo "copy init.d script files"
|
@echo "copy init.d script files"
|
||||||
@mkdir -p \$(SRS_PREFIX)/etc/init.d
|
@mkdir -p \$(DESTDIR)/etc/init.d
|
||||||
@cp etc/init.d/srs \$(SRS_PREFIX)/etc/init.d
|
@cp etc/init.d/srs \$(DESTDIR)/etc/init.d
|
||||||
@sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(SRS_PREFIX)/etc/init.d/srs
|
@sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(DESTDIR)/etc/init.d/srs
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "srs installed, to link and start srs:"
|
@echo "srs installed, to link and start srs:"
|
||||||
@echo " sudo ln -sf /usr/local/srs/etc/init.d/srs /etc/init.d/srs"
|
@echo " sudo ln -sf /usr/local/srs/etc/init.d/srs /etc/init.d/srs"
|
||||||
|
|
49
trunk/scripts/_log.sh
Executable file
49
trunk/scripts/_log.sh
Executable file
|
@ -0,0 +1,49 @@
|
||||||
|
# import log utility and check the detail log file is ok
|
||||||
|
# @param log the log file path, default to /dev/null
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# color echo.
|
||||||
|
#######################################
|
||||||
|
RED="\\e[31m"
|
||||||
|
GREEN="\\e[32m"
|
||||||
|
YELLOW="\\e[33m"
|
||||||
|
BLACK="\\e[0m"
|
||||||
|
POS="\\e[110G"
|
||||||
|
|
||||||
|
# if need to log to file, change the log path.
|
||||||
|
if [[ ! $log ]]; then
|
||||||
|
log=/dev/null;
|
||||||
|
fi
|
||||||
|
|
||||||
|
ok_msg(){
|
||||||
|
echo -e "${1}${POS}${BLACK}[${GREEN} OK ${BLACK}]"
|
||||||
|
|
||||||
|
# write to log file.
|
||||||
|
echo "[info] ${1}" >> $log
|
||||||
|
}
|
||||||
|
|
||||||
|
warn_msg(){
|
||||||
|
echo -e "${1}${POS}${BLACK}[ ${YELLOW}WARN${BLACK} ]"
|
||||||
|
|
||||||
|
# write to log file.
|
||||||
|
echo "[error] ${1}" >> $log
|
||||||
|
}
|
||||||
|
|
||||||
|
failed_msg(){
|
||||||
|
echo -e "${1}${POS}${BLACK}[${RED}FAILED${BLACK}]"
|
||||||
|
|
||||||
|
# write to log file.
|
||||||
|
echo "[error] ${1}" >> $log
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_log(){
|
||||||
|
log_dir="`dirname $log`"
|
||||||
|
(mkdir -p ${log_dir} && sudo chmod 777 ${log_dir} && touch $log)
|
||||||
|
ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "create log failed, ret=$ret"; return $ret; fi
|
||||||
|
ok_msg "create log( ${log} ) success"
|
||||||
|
|
||||||
|
echo "bravo-vms setup `date`" >> $log
|
||||||
|
ok_msg "see detail log: tailf ${log}"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
103
trunk/scripts/install.sh
Executable file
103
trunk/scripts/install.sh
Executable file
|
@ -0,0 +1,103 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# user can config the following configs, then package.
|
||||||
|
INSTALL=/usr/local/srs
|
||||||
|
|
||||||
|
##################################################################################
|
||||||
|
##################################################################################
|
||||||
|
##################################################################################
|
||||||
|
# discover the current work dir, the log and access.
|
||||||
|
echo "argv[0]=$0"
|
||||||
|
if [[ ! -f $0 ]]; then
|
||||||
|
echo "directly execute the scripts on shell.";
|
||||||
|
work_dir=`pwd`
|
||||||
|
else
|
||||||
|
echo "execute scripts in file: $0";
|
||||||
|
work_dir=`dirname $0`; work_dir=`(cd ${work_dir} && pwd)`
|
||||||
|
fi
|
||||||
|
product_dir=$work_dir
|
||||||
|
|
||||||
|
log="${work_dir}/logs/package.`date +%s`.log" && . ${product_dir}/scripts/_log.sh && check_log
|
||||||
|
ret=$?; if [[ $ret -ne 0 ]]; then exit $ret; fi
|
||||||
|
|
||||||
|
# user must stop service first.
|
||||||
|
ok_msg "check previous install"
|
||||||
|
if [[ -f /etc/init.d/srs ]]; then
|
||||||
|
/etc/init.d/srs status >/dev/null 2>&1
|
||||||
|
ret=$?; if [[ 0 -eq ${ret} ]]; then
|
||||||
|
failed_msg "you must stop the service first: sudo /etc/init.d/srs stop";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
ok_msg "previous install checked"
|
||||||
|
|
||||||
|
# backup old srs
|
||||||
|
ok_msg "backup old srs"
|
||||||
|
install_root=$INSTALL
|
||||||
|
install_bin=$install_root/objs/srs
|
||||||
|
if [[ -d $install_root ]]; then
|
||||||
|
version="unknown"
|
||||||
|
if [[ -f $install_bin ]]; then
|
||||||
|
version=`$install_bin -v 2>/dev/stdout 1>/dev/null`
|
||||||
|
fi
|
||||||
|
|
||||||
|
backup_dir=${install_root}.`date "+%Y-%m-%d_%H-%M-%S"`.v-$version
|
||||||
|
ok_msg "backup installed dir, version=$version"
|
||||||
|
ok_msg " to=$backup_dir"
|
||||||
|
mv $install_root $backup_dir >>$log 2>&1
|
||||||
|
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "backup installed dir failed"; exit $ret; fi
|
||||||
|
ok_msg "backup installed dir success"
|
||||||
|
fi
|
||||||
|
ok_msg "old srs backuped"
|
||||||
|
|
||||||
|
# prepare files.
|
||||||
|
ok_msg "prepare files"
|
||||||
|
(
|
||||||
|
sed -i "s|^ROOT=.*|ROOT=\"${INSTALL}\"|g" $work_dir/etc/init.d/srs
|
||||||
|
) >> $log 2>&1
|
||||||
|
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "prepare files failed"; exit $ret; fi
|
||||||
|
ok_msg "prepare files success"
|
||||||
|
|
||||||
|
# copy core files
|
||||||
|
ok_msg "copy core components"
|
||||||
|
(
|
||||||
|
mkdir -p $install_root
|
||||||
|
cp -r $work_dir/conf $install_root &&
|
||||||
|
cp -r $work_dir/etc $install_root &&
|
||||||
|
cp -r $work_dir/objs $install_root
|
||||||
|
) >>$log 2>&1
|
||||||
|
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "copy core components failed"; exit $ret; fi
|
||||||
|
ok_msg "copy core components success"
|
||||||
|
|
||||||
|
# install init.d scripts
|
||||||
|
ok_msg "install init.d scripts"
|
||||||
|
(
|
||||||
|
rm -rf /etc/init.d/srs &&
|
||||||
|
ln -sf $install_root/etc/init.d/srs /etc/init.d/srs
|
||||||
|
) >>$log 2>&1
|
||||||
|
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install init.d scripts failed"; exit $ret; fi
|
||||||
|
ok_msg "install init.d scripts success"
|
||||||
|
|
||||||
|
# install system service
|
||||||
|
lsb_release --id|grep "CentOS" >/dev/null 2>&1; os_id_centos=$?
|
||||||
|
lsb_release --id|grep "Ubuntu" >/dev/null 2>&1; os_id_ubuntu=$?
|
||||||
|
if [[ 0 -eq $os_id_centos ]]; then
|
||||||
|
ok_msg "install system service for CentOS"
|
||||||
|
/sbin/chkconfig --add srs && /sbin/chkconfig srs on
|
||||||
|
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install system service failed"; exit $ret; fi
|
||||||
|
ok_msg "install system service success"
|
||||||
|
elif [[ 0 -eq $os_id_ubuntu ]]; then
|
||||||
|
ok_msg "install system service for Ubuntu"
|
||||||
|
update-rc.d srs defaults
|
||||||
|
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install system service failed"; exit $ret; fi
|
||||||
|
ok_msg "install system service success"
|
||||||
|
else
|
||||||
|
warn_msg "ignore and donot install system service for `lsb_release --id|awk '{print $3}'`."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "see: https://github.com/winlinvip/simple-rtmp-server/wiki/LinuxService"
|
||||||
|
echo "install success, you can:"
|
||||||
|
echo -e "${GREEN} sudo /etc/init.d/srs start${BLACK}"
|
||||||
|
|
||||||
|
exit 0
|
70
trunk/scripts/package.sh
Executable file
70
trunk/scripts/package.sh
Executable file
|
@ -0,0 +1,70 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# user can config the following configs, then package.
|
||||||
|
INSTALL=/usr/local/srs
|
||||||
|
|
||||||
|
##################################################################################
|
||||||
|
##################################################################################
|
||||||
|
##################################################################################
|
||||||
|
# discover the current work dir, the log and access.
|
||||||
|
echo "argv[0]=$0"
|
||||||
|
if [[ ! -f $0 ]]; then
|
||||||
|
echo "directly execute the scripts on shell.";
|
||||||
|
work_dir=`pwd`
|
||||||
|
else
|
||||||
|
echo "execute scripts in file: $0";
|
||||||
|
work_dir=`dirname $0`; work_dir=`(cd ${work_dir} && pwd)`
|
||||||
|
fi
|
||||||
|
work_dir=`(cd ${work_dir}/.. && pwd)`
|
||||||
|
product_dir=$work_dir
|
||||||
|
build_objs=${work_dir}/objs
|
||||||
|
package_dir=${build_objs}/package
|
||||||
|
|
||||||
|
log="${build_objs}/logs/package.`date +%s`.log" && . ${product_dir}/scripts/_log.sh && check_log
|
||||||
|
ret=$?; if [[ $ret -ne 0 ]]; then exit $ret; fi
|
||||||
|
|
||||||
|
# check os version
|
||||||
|
os_name=`lsb_release --id|awk '{print $3}'` &&
|
||||||
|
os_release=`lsb_release --release|awk '{print $2}'` &&
|
||||||
|
os_major_version=`echo $os_release|awk -F '.' '{print $1}'`
|
||||||
|
ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "lsb_release get os info failed."; exit $ret; fi
|
||||||
|
ok_msg "target os is ${os_name}-${os_major_version} ${os_release}"
|
||||||
|
|
||||||
|
# build srs
|
||||||
|
# @see https://github.com/winlinvip/simple-rtmp-server/wiki/Build
|
||||||
|
ok_msg "start build srs"
|
||||||
|
(
|
||||||
|
cd $work_dir &&
|
||||||
|
./configure --with-ssl --with-hls --with-nginx --with-ffmpeg --with-http-callback --prefix=$INSTALL &&
|
||||||
|
make && rm -rf $package_dir && make DESTDIR=$package_dir install
|
||||||
|
) >> $log 2>&1
|
||||||
|
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "build srs failed"; exit $ret; fi
|
||||||
|
ok_msg "build srs success"
|
||||||
|
|
||||||
|
# copy extra files to package.
|
||||||
|
ok_msg "start copy extra files to package"
|
||||||
|
(
|
||||||
|
cp $work_dir/scripts/install.sh $package_dir/INSTALL &&
|
||||||
|
sed -i "s|^INSTALL=.*|INSTALL=${INSTALL}|g" $package_dir/INSTALL &&
|
||||||
|
mkdir -p $package_dir/scripts &&
|
||||||
|
cp $work_dir/scripts/_log.sh $package_dir/scripts/_log.sh &&
|
||||||
|
chmod +x $package_dir/INSTALL
|
||||||
|
) >> $log 2>&1
|
||||||
|
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "copy extra files failed"; exit $ret; fi
|
||||||
|
ok_msg "copy extra files success"
|
||||||
|
|
||||||
|
# zip package.
|
||||||
|
ok_msg "start zip package"
|
||||||
|
(
|
||||||
|
srs_version=`${build_objs}/srs -v 2>/dev/stdout 1>/dev/null` &&
|
||||||
|
zip_dir="SRS-${os_name}${os_major_version}-${srs_version}" &&
|
||||||
|
mv $package_dir ${build_objs}/${zip_dir} &&
|
||||||
|
cd ${build_objs} && zip -q -r ${zip_dir}.zip ${zip_dir} &&
|
||||||
|
mv ${build_objs}/${zip_dir} $package_dir
|
||||||
|
) >> $log 2>&1
|
||||||
|
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "zip package failed"; exit $ret; fi
|
||||||
|
ok_msg "zip package success"
|
||||||
|
|
||||||
|
ok_msg "srs package success"
|
||||||
|
|
||||||
|
exit 0
|
|
@ -639,7 +639,7 @@ int SrsConfig::parse_options(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_version) {
|
if (show_version) {
|
||||||
printf("%s\n", RTMP_SIG_SRS_VERSION);
|
fprintf(stderr, "%s\n", RTMP_SIG_SRS_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_help || show_version) {
|
if (show_help || show_version) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue