Skip to content
Find file
4d93d65 Jul 23, 2012
executable file 272 lines (198 sloc) 8.84 KB
#!/bin/bash -e
if [[ $EUID -ne 0 ]]; then
echo "Please run as root user."
exit 1
mach=`uname -m`
if [[ "$mach" != "x86_64" ]]; then
echo "64-bit installer only"
locale | grep "LANG" | grep -i "UTF.*8"
if [[ "$status" != "0" ]]; then
echo "Invalid locale. Must be UTF-8. Exiting.."
exit 1
function randpass() {
[ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]"
cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-32}
function uninstall() {
set +e
#python /tmp/airtime-2.1.3/python_apps/media-monitor/install/
#python /tmp/airtime-2.1.3/python_apps/media-monitor/install/
#python /tmp/airtime-2.1.3/python_apps/pypo/install/
#python /tmp/airtime-2.1.3/python_apps/pypo/install/
echo "Uninstalling Zend"
pear uninstall zend/zend
echo "Uninstalling virtualenv"
pip -q uninstall virtualenv
pear channel-logout
pear channel-delete
echo "* Removing pypo user"
userdel pypo
userdel airtime
echo "* Removing Airtime database"
sudo -u postgres dropdb airtime
sudo -u postgres dropuser airtime
echo "Removing $path"
rm -rf "$path"
echo "Removing $path"
rm -rf "$path"
echo "Removing $path"
rm -rf "$path"
echo "Removing $path"
rm -rf "$path"
echo "Packages installed via yum will need to be removed manually."
echo "Media library at /srv/airtime/stor must be removed manually."
set -e
function install() {
echo "Installing PHP package dependencies"
yum -y install tar gzip curl php-pear postgresql python patch lsof sudo \
postgresql-server httpd php-pgsql php-gd php wget
echo "* Installing PHP Zend package"
pear channel-discover
pear install zend/zend
echo "* Initializing Postgresql"
set +e
service postgresql initdb
set -e
service postgresql start
#Allow remote access to httpd
#iptables -I INPUT 5 -m tcp -p tcp --dport 80 -j ACCEPT
echo "* Installing python-pip"
curl | python
curl | python
echo "* Installing python virtualenv"
pip install virtualenv
echo "* Downloading Airtime 2.1.3"
wget -O /tmp/airtime-2.1.3.tar.gz
cd /tmp
tar xzf airtime-2.1.3.tar.gz
echo "* Creating Airtime virtualenv"
#web files
echo "* Configuring httpd"
cp /tmp/airtime-2.1.3/install_full/apache/airtime-vhost /etc/httpd/conf.d/airtime.conf
sed -i 's#DocumentRoot.*$#DocumentRoot /var/www/html/airtime/public#g' /etc/httpd/conf.d/airtime.conf
sed -i 's#<Directory .*$#<Directory /var/www/html/airtime/public>#g' /etc/httpd/conf.d/airtime.conf
echo "* Copying Airtime web files"
mkdir -p /var/www/html/airtime
cp -R /tmp/airtime-2.1.3/airtime_mvc/* /var/www/html/airtime
mkdir -p /etc/airtime
mkdir -p /srv/airtime/stor
echo "* Creating Airtime Database"
cp /tmp/airtime-2.1.3/airtime_mvc/build/airtime.conf /etc/airtime/airtime.conf
echo "* Creating airtime user"
adduser --system --user-group airtime
rand=`cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-32}`
sed -i "s/api_key = .*$/api_key = $rand/g" /etc/airtime/airtime.conf
sudo -u postgres psql -c "CREATE USER airtime ENCRYPTED PASSWORD 'airtime' LOGIN CREATEDB NOCREATEUSER;"
sudo -u postgres createdb -O airtime --encoding UTF8 airtime
cd /tmp/airtime-2.1.3/airtime_mvc/build/sql
sudo -u airtime psql --file schema.sql airtime
sudo -u airtime psql --file sequences.sql airtime
sudo -u airtime psql --file views.sql airtime
sudo -u airtime psql --file triggers.sql airtime
sudo -u airtime psql --file defaultdata.sql airtime
sudo -u airtime psql -c "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.1.3');"
sudo -u airtime psql -c "INSERT INTO cc_music_dirs (directory, type) VALUES ('/srv/airtime/stor', 'stor');"
sudo -u airtime psql -c "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', 'UTC')"
unique_id=`php -r "echo md5(uniqid('', true));"`
sudo -u airtime psql -c "INSERT INTO cc_pref (keystr, valstr) VALUES ('uniqueId', '$unique_id')"
sudo -u airtime psql -c "INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0')"
echo "* Allowing httpd to connect to postgresql (SELinux)"
set +e
setsebool -P httpd_can_network_connect_db 1
set -e
#change /var/lib/pgsql/data/pg_hba.conf
#Change auth type to md5:
echo "* Modifying /var/lib/pgsql/data/pg_hba.conf"
sed -i 's#host.*$#host all all md5#g' /var/lib/pgsql/data/pg_hba.conf
sed -i 's#host.*$#host all all ::1/128 md5#g' /var/lib/pgsql/data/pg_hba.conf
echo "* Creating pypo user"
adduser --system --user-group pypo
echo "* Installing monit"
wget -O /tmp/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
set +e
rpm --import
set -e
rpm -K /tmp/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm -i /tmp/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm || true
yum -y install monit
mkdir -p /etc/monit.d/
mkdir -p /etc/monit/conf.d
echo "include /etc/monit/conf.d/*" > /etc/monit.d/monitrc
echo "* Installing RabbitMQ"
rpm -Uvh || true
yum -y install erlang
rpm -Uvh
#service rabbitmq-server start
locale | grep "LANG" > /etc/default/locale
echo "* Installing Airtime services"
python /tmp/airtime-2.1.3/python_apps/api_clients/install/
cp -R /tmp/airtime-2.1.3/python_apps/std_err_override /usr/lib/airtime
python /tmp/airtime-2.1.3/python_apps/media-monitor/install/
python /tmp/airtime-2.1.3/python_apps/media-monitor/install/
python /tmp/airtime-2.1.3/python_apps/pypo/install/
#TODO remove dependency on debian liquidsoap
python /tmp/airtime-2.1.3/python_apps/pypo/install/ || true
echo "* Installing Liquidsoap"
yum -y install ocaml ocaml-findlib.x86_64 libao libao-devel libmad libmad-devel taglib taglib-devel lame lame-devel libvorbis libvorbis-devel libtheora libtheora-devel pcre.x86_64 ocaml-camlp4 ocaml-camlp4-devel.x86_64 pcre pcre-devel gcc-c++ libX11 libX11-devel flac vorbis-tools vorbinsgain.x86_64 mp3gain.x86_64
wget -O /tmp/pcre-ocaml-6.2.5.tar.gz
cd /tmp
tar xzf pcre-ocaml-6.2.5.tar.gz
cd pcre-ocaml-6.2.5
sudo -u pypo make
make install || true
wget -O /tmp/liquidsoap-1.0.1-full.tar.bz2
cd /tmp
tar xjf liquidsoap-1.0.1-full.tar.bz2
chown -R pypo:pypo /tmp/liquidsoap-1.0.1-full
cd /tmp/liquidsoap-1.0.1-full
sed -i 's/ocaml-flac/#ocaml-flac/g' PACKAGES
sudo -u pypo ./configure --disable-camomile
sudo -u pypo ./bootstrap
sudo -u pypo make
make install || true
echo "Installing icecast2"
yum -y install libxslt-devel.x86_64
wget -O /tmp/icecast-2.3.3.tar.gz
cd /tmp
tar xzf icecast-2.3.3.tar.gz
chown -R pypo:pypo /tmp/icecast-2.3.3
cd /tmp/icecast-2.3.3
sudo -u pypo ./configure
sudo -u pypo make
make install || true
echo "* Setting up init.d scripts"
#chkconfig --levels 235 monit on
#chkconfig rabbitmq-server on
echo "* Installing Airtime utils"
echo "* Successful install of Airtime on CentOS!"
if [[ "$1" == "install" ]]; then
elif [[ "$1" == "uninstall" ]]; then
echo "install/uninstall parameter required"
Something went wrong with that request. Please try again.