libretime/install_full/ubuntu/airtime-full-install

219 lines
7.6 KiB
Bash
Executable File

#!/bin/bash -e
#
# Auto install script for airtime on Ubuntu
#
# NGINX changes are contributed by Eugene MechanisM
# Link to the post:
# http://forum.sourcefabric.org/discussion/13563/first-step-to-run-airtime-via-nginx-based-on-airtime-2.0-beta-files
exec > >(tee install_log.txt)
exec 2>&1
if [ "$(id -u)" != "0" ]; then
echo "Please run as root user."
exit 1
fi
server="$1"
#Current dir
# Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=`readlink -f $0`
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=`dirname $SCRIPT`
#Prerequisite
echo "----------------------------------------------------"
echo " 1. Install Packages"
echo "----------------------------------------------------"
dist=`lsb_release -is`
code=`lsb_release -cs`
#enable squeeze backports to get lame packages
if [ "$dist" = "Debian" -a "$code" = "squeeze" ]; then
set +e
grep -E "deb http://backports.debian.org/debian-backports squeeze-backports main" /etc/apt/sources.list
returncode=$?
set -e
if [ "$returncode" -ne "0" ]; then
echo "deb http://backports.debian.org/debian-backports squeeze-backports main" >> /etc/apt/sources.list
fi
fi
codename=`lsb_release -sc`
set +e
grep -E "deb +http://apt.sourcefabric.org/? +$codename +main" /etc/apt/sources.list
returncode=$?
set -e
if [ "$returncode" != "0" ]; then
echo "deb http://apt.sourcefabric.org/ $codename main" >> /etc/apt/sources.list
fi
apt-get update
# Updated package list
apt-get -y --force-yes install tar gzip curl php5-pgsql \
php-pear php5-gd postgresql odbc-postgresql python libsoundtouch-ocaml \
libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \
libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \
php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \
libpulse0 vorbis-tools lsb-release lsof sudo mp3gain vorbisgain flac vorbis-tools \
pwgen libfaad2 memcached php5-memcached php5-json
#install packages with --force-yes option (this is useful in the case
#of Debian, where these packages are unauthorized)
apt-get -y --force-yes install libmp3lame-dev lame icecast2
#Debian Squeeze only has zendframework package. Newer versions of Ubuntu have zend-framework package.
#Ubuntu Lucid has both zendframework and zend-framework. Difference appears to be that zendframework is for
#1.10 and zend-framework is 1.11
if [ "$dist" = "Debian" ]; then
apt-get -y --force-yes install zendframework
else
apt-get -y --force-yes install libzend-framework-php
fi
#get the "timeout" unix command
if [ "$code" = "lucid" ]; then
apt-get -y --force-yes install timeout
else
apt-get -y --force-yes install coreutils
fi
#install aac package only available in new distributions: (Debian Wheezy, Ubuntu Precise or newer)
if [ "$code" != "squeeze" -a "$code" != "lucid" ]; then
apt-get -y --force-yes install libvo-aacenc0
fi
#Install some plugin packages on Ubuntu Saucy.
if [ "$dist" = "Ubuntu" -a "$code" = "saucy" ]; then
apt-get -y --force-yes install php5-json
apt-get -y --force-yes install liquidsoap-plugin-alsa liquidsoap-plugin-ao liquidsoap-plugin-faad liquidsoap-plugin-flac liquidsoap-plugin-icecast liquidsoap-plugin-lame liquidsoap-plugin-mad liquidsoap-plugin-ogg liquidsoap-plugin-opus liquidsoap-plugin-portaudio liquidsoap-plugin-pulseaudio liquidsoap-plugin-taglib liquidsoap-plugin-voaacenc liquidsoap-plugin-vorbis
fi
#Install packages back-ported by Sourcefabric
apt-get -y --force-yes install sourcefabric-keyring
apt-get -y --force-yes install liquidsoap
apt-get -y --force-yes install silan
apt-get -y --force-yes install libopus0
if [ "$server" = "nginx" ]; then
apt-get -y --force-yes install nginx php5-fpm
# NGINX Config File
echo "----------------------------------------------------"
echo "2.1 NGINX Config File"
echo "----------------------------------------------------"
if [ ! -f /etc/nginx/sites-available/airtime ]; then
cp $SCRIPTPATH/../nginx/airtime-vhost /etc/nginx/sites-available/airtime
ln -s /etc/nginx/sites-available/airtime /etc/nginx/sites-enabled/airtime
service nginx reload
else
echo "NGINX config for Airtime already exists..."
fi
# php-fpm Airtime pool file
echo "----------------------------------------------------"
echo "2.2 Airtime php pool file"
echo "----------------------------------------------------"
if [ ! -f /etc/php5/fpm/pool.d/airtime.conf ]; then
cp $SCRIPTPATH/../php5-fpm/airtime.conf /etc/php5/fpm/pool.d/airtime.conf
service php5-fpm reload
else
echo "Airtime php pool file already exists..."
fi
else
apt-get -y --force-yes install apache2 libapache2-mod-php5
# Apache Config File
echo "----------------------------------------------------"
echo "2.1 Apache Config File"
echo "----------------------------------------------------"
vregex='(Apache\/2\.4)'
apachev=`apache2 -v | grep 'Server version'`
echo "$apachev"
if [[ "$apachev" =~ $vregex ]]
then
#Apache is version 2.4
if [ ! -f /etc/apache2/sites-available/airtime.conf ]; then
echo "Creating Apache config for Airtime..."
cp $SCRIPTPATH/../apache/2.4/airtime-vhost /etc/apache2/sites-available/airtime.conf
else
echo "Apache config for Airtime already exists..."
fi
else
#Apache is older, use 2.2 config.
if [ ! -f /etc/apache2/sites-available/airtime ]; then
echo "Creating Apache config for Airtime..."
cp $SCRIPTPATH/../apache/2.2/airtime-vhost /etc/apache2/sites-available/airtime
else
echo "Apache config for Airtime already exists..."
fi
fi
a2ensite airtime
if [ ! -d /usr/share/airtime/public ]; then
echo "Creating Apache web root directory..."
mkdir -p /usr/share/airtime/public/
else
echo "Airtime web root directory already exists..."
fi
# PHP Config File for Apache
echo "----------------------------------------------------"
echo "2.2 PHP Config File for Apache"
echo "----------------------------------------------------"
if [ ! -f /etc/php5/apache2/conf.d/airtime.ini ]; then
echo "Creating Airtime PHP config for Apache..."
cp $SCRIPTPATH/../php5/airtime.ini /etc/php5/apache2/conf.d/airtime.ini
else
echo "Airtime PHP config for Apache already exists..."
fi
# Enable modules and restart Apache to enable any configuration changes
echo "----------------------------------------------------"
echo "2.3 Enable Apache Modules and Restart Apache"
echo "----------------------------------------------------"
a2enmod rewrite php5
service apache2 restart
fi
# Enable Icecast
echo "----------------------------------------------------"
echo "3. Enable Icecast"
echo "----------------------------------------------------"
cd /etc/default/
sed -i 's/ENABLE=false/ENABLE=true/g' icecast2
set +e
service icecast2 start
set -e
echo ""
# Enable Monit
echo "----------------------------------------------------"
echo "4. Enable Monit"
echo "----------------------------------------------------"
cd /etc/default/
sed -i 's/startup=0/startup=1/g' monit
set +e
grep -q "include /etc/monit/conf.d" /etc/monit/monitrc
RETVAL=$?
set -e
if [ $RETVAL -ne 0 ] ; then
mkdir -p /etc/monit/conf.d
echo "include /etc/monit/conf.d/*" >> /etc/monit/monitrc
fi
# Run Airtime Install
echo "----------------------------------------------------"
echo "5. Run Airtime Install"
echo "----------------------------------------------------"
cd $SCRIPTPATH/../../install_minimal
./airtime-install