janus全编译脚本

分享下编译janus-视频会议系统(SFU)的脚本(三年前写的,新版本如果有变化可微调下):

#!/bin/bash

#CUR_DIR=`dirname $0`
CUR_DIR=`pwd`

sudo yum install -y epel-release \
   libmicrohttpd-devel jansson-devel \
   openssl-devel libsrtp-devel sofia-sip-devel glib2-devel \
   opus-devel libogg-devel libcurl-devel lua-devel \
   pkgconfig gengetopt libconfig-devel libtool autoconf automake \
   golang.x86_64 gtk-doc.x86_64 \
   doxygen graphviz
   #libnice-devel libunwind-devel.x86_64

#############################################################################

#如果出现No package sofia-sip-devel available
SOFIA_SIP_VERSION=1.12.11
SOFIA_SIP_DIR="${CUR_DIR}/sofia-sip-${SOFIA_SIP_VERSION}/"

if [ ! -d ${SOFIA_SIP_DIR} ]; then
  SOFIA_SIP_TAR=sofia-sip-${SOFIA_SIP_VERSION}.tar.gz
  wget https://sourceforge.net/projects/sofia-sip/files/sofia-sip/${SOFIA_SIP_VERSION}/${SOFIA_SIP_TAR}/download -O ${SOFIA_SIP_TAR}
  tar xvzf ${SOFIA_SIP_TAR}
fi

pushd ${SOFIA_SIP_DIR}
./configure --prefix=/usr && make && sudo make install
popd

#############################################################################

LIBNICE_DIR="${CUR_DIR}/libnice/"

if [ ! -d ${LIBNICE_DIR} ]; then
  git clone https://gitlab.freedesktop.org/libnice/libnice ${LIBNICE_DIR}
fi

pushd ${LIBNICE_DIR}
./autogen.sh
./configure --prefix=/usr && make && sudo make install
popd

#############################################################################

SRTP_VERSION=2.2.0
SRTP_DIR="${CUR_DIR}/libsrtp-${SRTP_VERSION}/"

if [ ! -d ${SRTP_DIR} ]; then
    wget https://github.com/cisco/libsrtp/archive/v${SRTP_VERSION}.tar.gz
    tar xfv v${SRTP_VERSION}.tar.gz
fi

pushd ${SRTP_DIR}
./configure --prefix=/usr --enable-openssl
make shared_library && sudo make install
popd

#############################################################################

# need cmake3, golang
BORINGSSL_DIR="${CUR_DIR}/boringssl/"

if [ ! -d ${BORINGSSL_DIR} ]; then
    #git clone https://boringssl.googlesource.com/boringssl ${BORINGSSL_DIR}
    git clone https://github.com/google/boringssl ${BORINGSSL_DIR}
fi

pushd ${BORINGSSL_DIR}
# Don't barf on errors
sed -i s/" -Werror"//g CMakeLists.txt
# Build
mkdir -p build
pushd build
#cmake -DCMAKE_CXX_FLAGS="-lrt" ..
cmake ..
make
popd
# Install
sudo mkdir -p /opt/boringssl
sudo cp -R include /opt/boringssl/
sudo mkdir -p /opt/boringssl/lib
sudo cp build/ssl/libssl.a /opt/boringssl/lib/
sudo cp build/crypto/libcrypto.a /opt/boringssl/lib/
popd

#############################################################################

# needed for Data Channels
USRSCTP_DIR="${CUR_DIR}/usrsctp/"

if [ ! -d ${USRSCTP_DIR} ]; then
  git clone https://github.com/sctplab/usrsctp ${USRSCTP_DIR}
fi

pushd ${USRSCTP_DIR}
./bootstrap
./configure --prefix=/usr && make && sudo make install
popd

#############################################################################

LIBWEBSOCKETS_DIR="${CUR_DIR}/libwebsockets/"

if [ ! -d ${LIBWEBSOCKETS_DIR} ]; then
    git clone git://git.libwebsockets.org/libwebsockets ${LIBWEBSOCKETS_DIR}
    #git clone https://libwebsockets.org/repo/libwebsockets ${LIBWEBSOCKETS_DIR}
    #git clone https://github.com/warmcat/libwebsockets.git
fi

pushd ${LIBWEBSOCKETS_DIR}
# If you want the stable version of libwebsockets, uncomment the next line
git checkout v3.0-stable
mkdir build
pushd build
# See https://github.com/meetecho/janus-gateway/issues/732 re: LWS_MAX_SMP
cmake -DLWS_MAX_SMP=1 -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" ..
make && sudo make install
popd
popd

#############################################################################

PAHO_MQTT_C_DIR="${CUR_DIR}/paho.mqtt.c/"

if [ ! -d ${PAHO_MQTT_C_DIR} ]; then
    git clone https://github.com/eclipse/paho.mqtt.c.git ${PAHO_MQTT_C_DIR}
fi
pushd ${PAHO_MQTT_C_DIR}
make && sudo prefix=/usr make install
popd

#############################################################################

RABBITMQ_DIR="${CUR_DIR}/rabbitmq-c/"

if [ ! -d ${RABBITMQ_DIR} ]; then
git clone https://github.com/alanxz/rabbitmq-c ${RABBITMQ_DIR}
fi

pushd ${RABBITMQ_DIR}
git submodule init
git submodule update
mkdir build
pushd build
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
make && sudo make install
popd
popd

#############################################################################

## install ffmpeg
## https://medium.com/@ShinobiSystems/how-to-install-ffmpeg-on-centos-7017f7647caf

#yum update -y

## for CentOS 7
#rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
#rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm

## for CentOS 6
#rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
#rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm

#yum install ffmpeg ffmpeg-devel -y

#############################################################################

# echo "export PKG_CONFIG_PATH=/usr/lib/pkgconfig/:$PKG_CONFIG_PATH" >> ~/.bashrc
# source ~/.bashrc
#
# or PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

JANUS_DIR="${CUR_DIR}/janus-gateway/"

if [ ! -d ${JANUS_DIR} ]; then
    git clone https://github.com/meetecho/janus-gateway.git ${JANUS_DIR}
fi

pushd ${JANUS_DIR}
sh autogen.sh
# defualt OpenSSL, so need --enable-boringss (defualt: /opt/boringssl), --enable-boringssl=/path/to/boringssl
./configure --prefix=/opt/janus --enable-docs --enable-post-processing --enable-libsrtp2 --enable-boringssl --enable-dtls-settimeout PKG_CONFIG_PATH=/usr/lib/pkgconfig --libdir=/usr/lib64
make && sudo make install
# TODO: run only once
#make configs
popd


#############################################################################

#run doc: https://janus.conf.meetecho.com/docs/auth.html
#/opt/janus/bin/janus -C /opt/janus/etc/janus/janus.jcfg --cert-pem=/etc/ssl/certs/cert.pem --cert-key=/etc/ssl/certs/privkey.pem -T -S stun4.l.google.com:19302 -A

#############################################################################
#############################################################################
#############################################################################

你可能感兴趣的:(janus全编译脚本)