add update function
This commit is contained in:
parent
67c9510a8d
commit
a3debb2196
@ -6,6 +6,8 @@ For a better understanding about the functionality, take a look to the screensho
|
||||
|
||||
You can install it on a fresh debian/centos minimal like system with running `./install.sh` as root.
|
||||
|
||||
Updating is also possible with: `./install.sh update`
|
||||
|
||||
Or read the instruction [install.md](docs/install.md) for manual installation.
|
||||
|
||||
After installations you have to setup ssl for your **https** connections.
|
||||
|
372
install.sh
372
install.sh
@ -5,44 +5,49 @@ if [[ $(whoami) != 'root' ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "ffplayout gui domain name (like: example.org)"
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
if [[ "$(grep -Ei 'centos|fedora' /etc/*release)" ]]; then
|
||||
serviceUser="nginx"
|
||||
else
|
||||
serviceUser="www-data"
|
||||
fi
|
||||
|
||||
read -p "domain name :$ " domain
|
||||
# get sure that we have our correct PATH
|
||||
export PATH=$PATH:/usr/local/bin
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "path to media storage, default: /opt/ffplayout/media"
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
runInstall() {
|
||||
if [[ ! -f "/etc/ffplayout/ffplayout.yml" ]]; then
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "path to media storage, default: /opt/ffplayout/media"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
|
||||
read -p "media path :$ " mediaPath
|
||||
read -p "media path :$ " mediaPath
|
||||
|
||||
if [[ -z "$mediaPath" ]]; then
|
||||
if [[ -z "$mediaPath" ]]; then
|
||||
mediaPath="/opt/ffplayout/media"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "playlist path, default: /opt/ffplayout/playlists"
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "playlist path, default: /opt/ffplayout/playlists"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
|
||||
read -p "playlist path :$ " playlistPath
|
||||
read -p "playlist path :$ " playlistPath
|
||||
|
||||
if [[ -z "$playlistPath" ]]; then
|
||||
if [[ -z "$playlistPath" ]]; then
|
||||
playlistPath="/opt/ffplayout/playlists"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "compile and install (nonfree) ffmpeg:"
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
while true; do
|
||||
if [[ "$(which ffmpeg)" == *"/usr/bin/which"* ]]; then
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "compile and install (nonfree) ffmpeg:"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
while true; do
|
||||
read -p "Do you wish to compile ffmpeg? (Y/n) :$ " yn
|
||||
case $yn in
|
||||
[Yy]* ) compileFFmpeg="y"; break;;
|
||||
@ -53,14 +58,16 @@ while true; do
|
||||
echo ""
|
||||
);;
|
||||
esac
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "install and setup nginx:"
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
while true; do
|
||||
if [[ "$(which nginx)" == *"/usr/bin/which"* ]]; then
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "install and setup nginx:"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
while true; do
|
||||
read -p "Do you wish to install nginx? (Y/n) :$ " yn
|
||||
case $yn in
|
||||
[Yy]* ) installNginx="y"; break;;
|
||||
@ -71,14 +78,24 @@ while true; do
|
||||
echo ""
|
||||
);;
|
||||
esac
|
||||
done
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "install and srs rtmp/hls server:"
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
while true; do
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "ffplayout gui domain name (like: example.org)"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
|
||||
read -p "domain name :$ " domain
|
||||
fi
|
||||
|
||||
if [[ ! -d /usr/local/srs ]]; then
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "install and srs rtmp/hls server:"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
while true; do
|
||||
read -p "Do you wish to install srs? (Y/n) :$ " yn
|
||||
case $yn in
|
||||
[Yy]* ) installSRS="y"; break;;
|
||||
@ -89,14 +106,16 @@ while true; do
|
||||
echo ""
|
||||
);;
|
||||
esac
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "install ffplayout-engine:"
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
while true; do
|
||||
if [[ ! -d "/opt/ffplayout-engine" ]]; then
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "install ffplayout-engine:"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
while true; do
|
||||
read -p "Do you wish to install ffplayout-engine? (Y/n) :$ " yn
|
||||
case $yn in
|
||||
[Yy]* ) installEngine="y"; break;;
|
||||
@ -107,43 +126,73 @@ while true; do
|
||||
echo ""
|
||||
);;
|
||||
esac
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "install main packages"
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "install main packages"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
|
||||
if [[ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]]; then
|
||||
if [[ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]]; then
|
||||
packages=(sudo curl wget net-tools git python3-dev build-essential virtualenv
|
||||
python3-virtualenv mediainfo autoconf automake libtool pkg-config
|
||||
yasm cmake mercurial gperf)
|
||||
installedPackages=$(dpkg --get-selections | awk '{print $1}' | tr '\n' ' ')
|
||||
apt update
|
||||
|
||||
apt install -y sudo curl wget net-tools git python3-dev build-essential virtualenv python3-virtualenv mediainfo autoconf automake libtool pkg-config yasm cmake mercurial gperf
|
||||
if [[ "$installedPackages" != *"curl"* ]]; then
|
||||
apt install -y curl
|
||||
fi
|
||||
|
||||
if [[ "$installedPackages" != *"nodejs"* ]]; then
|
||||
curl -sL https://deb.nodesource.com/setup_12.x | bash -
|
||||
|
||||
apt install -y nodejs
|
||||
fi
|
||||
|
||||
if [[ $installNginx == 'y' ]]; then
|
||||
for pkg in ${packages[@]}; do
|
||||
if [[ "$installedPackages" != *"$pkg"* ]]; then
|
||||
apt install -y $pkg
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $installNginx == 'y' ]] && [[ "$installedPackages" != *"nginx"* ]]; then
|
||||
apt install -y nginx
|
||||
|
||||
rm /etc/nginx/sites-enabled/default
|
||||
fi
|
||||
|
||||
serviceUser="www-data"
|
||||
nginxConfig="/etc/nginx/sites-available"
|
||||
elif [[ "$(grep -Ei 'centos|fedora' /etc/*release)" ]]; then
|
||||
|
||||
elif [[ "$(grep -Ei 'centos|fedora' /etc/*release)" ]]; then
|
||||
packages=(libstdc++-static yasm mercurial libtool libmediainfo mediainfo
|
||||
cmake net-tools git python3 python36-devel wget python3-virtualenv
|
||||
gperf nano nodejs python3-policycoreutils policycoreutils-devel)
|
||||
installedPackages=$(dnf list --installed | awk '{print $1}' | tr '\n' ' ')
|
||||
activeRepos=$(dnf repolist enabled | awk '{print $1}' | tr '\n' ' ')
|
||||
|
||||
if [[ "$activeRepos" != *"epel"* ]]; then
|
||||
dnf -y install epel-release
|
||||
dnf repolist epel -v
|
||||
fi
|
||||
|
||||
if [[ "$activeRepos" != *"PowerTools"* ]]; then
|
||||
dnf -y config-manager --enable PowerTools
|
||||
dnf -y group install "Development Tools"
|
||||
dnf -y --enablerepo=PowerTools install libmediainfo mediainfo
|
||||
dnf -y install libstdc++-static yasm mercurial libtool cmake net-tools git python3 python36-devel wget python3-virtualenv gperf nano
|
||||
dnf -y install policycoreutils-{python3,devel}
|
||||
fi
|
||||
|
||||
if [[ "$activeRepos" != *"nodesource"* ]]; then
|
||||
curl -sL https://rpm.nodesource.com/setup_12.x | sudo -E bash -
|
||||
fi
|
||||
|
||||
dnf -y install nodejs
|
||||
for pkg in ${packages[@]}; do
|
||||
if [[ "$installedPackages" != *"$pkg"* ]]; then
|
||||
dnf -y install $pkg
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $installNginx == 'y' ]]; then
|
||||
if [[ ! $(dnf group list "Development Tools" | grep -i "install") ]]; then
|
||||
dnf -y group install "Development Tools"
|
||||
fi
|
||||
|
||||
if [[ $installNginx == 'y' ]] && [[ "$installedPackages" != *"nginx"* ]]; then
|
||||
dnf -y install nginx
|
||||
systemctl enable nginx
|
||||
systemctl start nginx
|
||||
@ -154,17 +203,18 @@ elif [[ "$(grep -Ei 'centos|fedora' /etc/*release)" ]]; then
|
||||
chcon -vR system_u:object_r:httpd_sys_content_t:s0 /var/www
|
||||
fi
|
||||
|
||||
if [[ $(alternatives --list | grep "no-python") ]]; then
|
||||
alternatives --set python /usr/bin/python3
|
||||
fi
|
||||
|
||||
serviceUser="nginx"
|
||||
nginxConfig="/etc/nginx/conf.d"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $compileFFmpeg == 'y' ]]; then
|
||||
if [[ $compileFFmpeg == 'y' ]]; then
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "compile and install ffmpeg"
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
cd /opt/
|
||||
|
||||
if [[ ! -d "ffmpeg-build" ]]; then
|
||||
@ -208,13 +258,13 @@ EOF
|
||||
./compile-ffmpeg.sh
|
||||
|
||||
\cp local/bin/ff* /usr/local/bin/
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $installSRS == 'y' ]] && [[ ! -d "/usr/local/srs" ]]; then
|
||||
if [[ $installSRS == 'y' ]] && [[ ! -d "/usr/local/srs" ]]; then
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "compile and install srs"
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
|
||||
cd /opt/
|
||||
git clone https://github.com/ossrs/srs.git
|
||||
@ -293,18 +343,23 @@ EOF
|
||||
|
||||
systemctl enable srs.service
|
||||
systemctl start srs.service
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [[ "$(grep -Ei 'centos|fedora' /etc/*release)" ]]; then
|
||||
if [[ "$(grep -Ei 'centos|fedora' /etc/*release)" ]]; then
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "creating selinux rules"
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
|
||||
if [[ $(getsebool httpd_can_network_connect | awk '{print $NF}') == "off" ]]; then
|
||||
setsebool httpd_can_network_connect on -P
|
||||
semanage port -a -t http_port_t -p tcp 8001
|
||||
fi
|
||||
|
||||
if [[ ! $(semanage port -l | grep http_port_t | grep "8001") ]]; then
|
||||
semanage port -a -t http_port_t -p tcp 8001
|
||||
fi
|
||||
|
||||
if [[ ! $(semodule -l | grep gunicorn) ]]; then
|
||||
cat <<EOF > gunicorn.te
|
||||
module gunicorn 1.0;
|
||||
|
||||
@ -337,8 +392,12 @@ EOF
|
||||
semodule_package -o gunicorn.pp -m gunicorn.mod
|
||||
semodule -i gunicorn.pp
|
||||
|
||||
cat <<EOF > conf.te
|
||||
module conf 1.0;
|
||||
rm -f gunicorn.*
|
||||
fi
|
||||
|
||||
if [[ ! $(semodule -l | grep "custom-http") ]]; then
|
||||
cat <<EOF > custom-http.te
|
||||
module custom-http 1.0;
|
||||
|
||||
require {
|
||||
type init_t;
|
||||
@ -353,12 +412,16 @@ allow init_t httpd_sys_content_t:file unlink;
|
||||
allow init_t httpd_sys_content_t:file { create lock write };
|
||||
EOF
|
||||
|
||||
checkmodule -M -m -o conf.mod conf.te
|
||||
semodule_package -o conf.pp -m conf.mod
|
||||
semodule -i conf.pp
|
||||
checkmodule -M -m -o custom-http.mod custom-http.te
|
||||
semodule_package -o custom-http.pp -m custom-http.mod
|
||||
semodule -i custom-http.pp
|
||||
|
||||
cat <<EOF > create.te
|
||||
module create 1.0;
|
||||
rm -f custom-http.*
|
||||
fi
|
||||
|
||||
if [[ ! $(semodule -l | grep "custom-fileop") ]]; then
|
||||
cat <<EOF > custom-fileop.te
|
||||
module custom-fileop 1.0;
|
||||
|
||||
require {
|
||||
type init_t;
|
||||
@ -381,20 +444,23 @@ allow init_t usr_t:file { rename unlink write };
|
||||
|
||||
EOF
|
||||
|
||||
checkmodule -M -m -o create.mod create.te
|
||||
semodule_package -o create.pp -m create.mod
|
||||
semodule -i create.pp
|
||||
fi
|
||||
checkmodule -M -m -o custom-fileop.mod custom-fileop.te
|
||||
semodule_package -o custom-fileop.pp -m custom-fileop.mod
|
||||
semodule -i custom-fileop.pp
|
||||
|
||||
if ! grep -q "ffplayout-engine.service" "/etc/sudoers"; then
|
||||
rm -f custom-fileop.*
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! grep -q "ffplayout-engine.service" "/etc/sudoers"; then
|
||||
echo "$serviceUser ALL = NOPASSWD: /bin/systemctl start ffplayout-engine.service, /bin/systemctl stop ffplayout-engine.service, /bin/systemctl reload ffplayout-engine.service, /bin/systemctl restart ffplayout-engine.service, /bin/systemctl status ffplayout-engine.service, /bin/systemctl is-active ffplayout-engine.service, /bin/journalctl -n 1000 -u ffplayout-engine.service" >> /etc/sudoers
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$installEngine" == "y" ]] && [[ ! -d "/opt/ffplayout-engine" ]]; then
|
||||
if [[ "$installEngine" == "y" ]] && [[ ! -d "/opt/ffplayout-engine" ]]; then
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "install ffplayout engine"
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
|
||||
cd /opt
|
||||
git clone https://github.com/ffplayout/ffplayout-engine.git
|
||||
@ -426,13 +492,13 @@ if [[ "$installEngine" == "y" ]] && [[ ! -d "/opt/ffplayout-engine" ]]; then
|
||||
systemctl enable ffplayout-engine.service
|
||||
|
||||
deactivate
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -d "/var/www/ffplayout" ]]; then
|
||||
if [[ ! -d "/var/www/ffplayout" ]]; then
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "install ffplayout gui"
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
|
||||
cd /var/www
|
||||
git clone https://github.com/ffplayout/ffplayout-gui.git ffplayout
|
||||
@ -495,17 +561,95 @@ EOF
|
||||
|
||||
sudo -H -u $serviceUser bash -c 'npm run build'
|
||||
systemctl start ffplayout-api.service
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $installNginx == 'y' ]]; then
|
||||
if [[ $installNginx == 'y' ]]; then
|
||||
systemctl restart nginx
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "installation done..."
|
||||
echo "------------------------------------------------------------------------------"
|
||||
|
||||
echo ""
|
||||
echo "add your ssl config to $nginxConfig/ffplayout.conf"
|
||||
echo ""
|
||||
}
|
||||
|
||||
runUpdate() {
|
||||
if [[ -d "/opt/ffmpeg-build" ]]; then
|
||||
cd "/opt/ffmpeg-build"
|
||||
|
||||
git pull
|
||||
|
||||
./compile-ffmpeg.sh
|
||||
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "updating ffmpeg-build done..."
|
||||
echo "------------------------------------------------------------------------------"
|
||||
fi
|
||||
|
||||
if [[ -d "/opt/ffplayout-engine" ]]; then
|
||||
cd "/opt/ffplayout-engine"
|
||||
git pull
|
||||
|
||||
source ./venv/bin/activate
|
||||
pip install --upgrade -r requirements-base.txt
|
||||
deactivate
|
||||
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "updating ffplayout-engine done..."
|
||||
echo "------------------------------------------------------------------------------"
|
||||
else
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "WARNING: no ffplayout-engine found..."
|
||||
echo "------------------------------------------------------------------------------"
|
||||
fi
|
||||
|
||||
if [[ -d "/var/www/ffplayout" ]]; then
|
||||
cd "/var/www/ffplayout"
|
||||
git pull
|
||||
|
||||
source ./venv/bin/activate
|
||||
pip install --upgrade -r requirements-base.txt
|
||||
deactivate
|
||||
|
||||
cd "ffplayout/frontend"
|
||||
|
||||
rm -rf node_modules
|
||||
sudo -H -u $serviceUser bash -c 'npm install'
|
||||
sudo -H -u $serviceUser bash -c 'npm run build'
|
||||
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "updating ffplayout-gui done..."
|
||||
echo "------------------------------------------------------------------------------"
|
||||
else
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "WARNING: no ffplayout-gui found..."
|
||||
echo "------------------------------------------------------------------------------"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "updating done..."
|
||||
echo "if there is a new ffmpeg version, run:"
|
||||
echo " systemctl stop ffplayout-engine"
|
||||
echo " cp /opt/ffmpeg-build/local/bin/ff* /usrlocal/bin"
|
||||
echo " systemctl start ffplayout-engine"
|
||||
echo ""
|
||||
echo "to apply update restart services:"
|
||||
echo " systemctl restart ffplayout-engine"
|
||||
echo " systemctl restart ffplayout-api"
|
||||
}
|
||||
|
||||
if [[ "$1" == "update" ]]; then
|
||||
runUpdate
|
||||
else
|
||||
runInstall
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
echo "installation done..."
|
||||
echo "-----------------------------------------------------------------------------------------------------"
|
||||
|
||||
echo ""
|
||||
echo "add your ssl config to $nginxConfig/ffplayout.conf"
|
||||
echo ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user