diff --git a/Vagrantfile b/Vagrantfile index e7558db8d..08ece0a1c 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -3,10 +3,8 @@ Vagrant.configure("2") do |config| - config.vm.box = "ubuntu/trusty64" - # libretime web interface - config.vm.network "forwarded_port", guest: 9080, host:9080 + config.vm.network "forwarded_port", guest: 8080, host:8080 # icecast2 config.vm.network "forwarded_port", guest: 8000, host:8000 # liquidsoap input harbors for instreaming (ie. /master) @@ -14,6 +12,11 @@ Vagrant.configure("2") do |config| # mkdics documentation config.vm.network "forwarded_port", guest: 8888, host:8888 + # make sure we are using nfs (doesn't work out of the box with debian) + config.vm.synced_folder ".", "/vagrant", type: "nfs" + # private network for nfs + config.vm.network "private_network", ip: "192.168.10.100" + config.vm.provider "virtualbox" do |v| # to run without OOMing we need at least 1GB of RAM v.memory = 1024 @@ -29,21 +32,33 @@ Vagrant.configure("2") do |config| end end - # ubuntu/trusty64 alsa setup - # slightly modernized from https://github.com/naomiaro/vagrant-alsa-audio - # https://wiki.ubuntu.com/Audio/UpgradingAlsa/DKMS - config.vm.provision "shell", inline: <<-SHELL - alsa_deb="oem-audio-hda-daily-dkms_0.201703070301~ubuntu14.04.1_all.deb" - wget -nv https://code.launchpad.net/~ubuntu-audio-dev/+archive/ubuntu/alsa-daily/+files/${alsa_deb} - sudo dpkg -i ${alsa_deb} - rm ${alsa_deb} - sudo DEBIAN_FRONTEND=noninteractive apt-get -y -m --force-yes install alsa - sudo usermod -a -G audio vagrant - # liquidsoap runs as apache - sudo usermod -a -G audio www-data - SHELL - config.vm.provision "shell", inline: "cd /vagrant; ./install -fIiapv --web-port=9080" - config.vm.provision "shell", path: "docs/scripts/install.sh" - config.vm.provision "shell", path: "docs/scripts/serve.sh" + # default installer args used for all distros + installer_args="--force --in-place --verbose --postgres --apache --icecast " + + # define all the OS boxes we support + config.vm.define "ubuntu" do |os| + os.vm.box = "ubuntu/trusty64" + provision_libretime(os, "ubuntu.sh", installer_args + "--distribution=ubuntu --release=trusty") + end + config.vm.define "debian" do |os| + os.vm.box = "debian/jessie64" + provision_libretime(os, "debian.sh", installer_args + "--distribution=debian --release=jessie") + end + config.vm.define "centos" do |os| + os.vm.box = 'centos/7' + provision_libretime(os, "centos.sh", installer_args + "--ignore-dependencies --distribution=centos --web-user=apache") + end + + def provision_libretime(config, prepare_script, installer_args) + # Prepare OS + config.vm.provision "prepare", type: "shell", path: "installer/vagrant/%s" % prepare_script + + # Provision LibreTime + config.vm.provision "install", type: "shell", inline: "cd /vagrant; ./install %s --web-port=8080" % installer_args + + # Provision docs + config.vm.provision "install-mkdocs", type: "shell", path: "docs/scripts/install.sh" + config.vm.provision "start-mkdocs", type: "shell", path: "docs/scripts/serve.sh" + end end diff --git a/airtime_mvc/application/services/PodcastService.php b/airtime_mvc/application/services/PodcastService.php index dd3dd5d78..73039f863 100644 --- a/airtime_mvc/application/services/PodcastService.php +++ b/airtime_mvc/application/services/PodcastService.php @@ -91,7 +91,8 @@ class Application_Service_PodcastService $podcastArray["language"] = htmlspecialchars($rss->get_language()); $podcastArray["copyright"] = htmlspecialchars($rss->get_copyright()); - $name = empty($rss->get_author()) ? "" : $rss->get_author()->get_name(); + $author = $rss->get_author(); + $name = empty($author) ? "" : $author->get_name(); $podcastArray["creator"] = htmlspecialchars($name); $categories = array(); diff --git a/docs/index.md b/docs/index.md index e2b68d733..df47c30d6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -20,10 +20,10 @@ The easiest way to check out LibreTime for yourself is to run a local instance i ```bash git clone https://github.com/libretime/libretime.git cd libretime -vagrant up +vagrant up ubuntu ``` -If everything works out, you will find LibreTime on [port 9080](http://localhost:9080), icecast on [port 8000](http://localhost:8000) and the docs on [port 8888](http://localhost:8888). +If everything works out, you will find LibreTime on [port 8080](http://localhost:8080), icecast on [port 8000](http://localhost:8000) and the docs on [port 8888](http://localhost:8888). Of course, this setup isn't appropriate for production use. For that, check out our [installation instructions](install.md). More information on the vagrant setup are in [the docs](vagrant.md). diff --git a/docs/manual/preparing-the-server/index.md b/docs/manual/preparing-the-server/index.md index 6e7ba5660..d9c613ef3 100644 --- a/docs/manual/preparing-the-server/index.md +++ b/docs/manual/preparing-the-server/index.md @@ -4,7 +4,7 @@ These Airtime instructions are outdated, see [install.md](../../install.md) for The following instructions assume that you have root access (**sudo** on Ubuntu) to a GNU/Linux server, and are familiar with basic command line tasks. Experienced system administrators may prefer to skip to the *Expert install* chapter in the appendix of this book after preparing the server as shown in the steps below. -The recommended Airtime server platform is Debian 7.2 'wheezy'. Ubuntu 12.04 LTS 'Precise Pangolin' is also supported. Users of other GNU/Linux distributions may be able to adapt these instructions to suit their needs. +The recommended Airtime server platform is Debian 8 'jessie'. Ubuntu 14.04 LTS 'Trusty Tahir' is also supported. Users of other GNU/Linux distributions may be able to adapt these instructions to suit their needs. The server should have at least a 1GHz processor and 1GB of RAM, preferably 2GB RAM or more. If you are using a desktop environment and web browser directly on the server you should install at least 2GB RAM, to avoid swapping to disk. diff --git a/docs/vagrant.md b/docs/vagrant.md index b004d49d8..004cffd08 100644 --- a/docs/vagrant.md +++ b/docs/vagrant.md @@ -20,13 +20,25 @@ To get started you clone the repo and run `vagrant up`. ```bash git clone https://github.com/libretime/libretime.git cd libretime -vagrant up +vagrant up ubuntu ``` -If everything works out, you will find LibreTime on [port 9080](http://localhost:9080), icecast on [port 8000](http://localhost:8000) and the docs on [port 8888](http://localhost:8888). +If everything works out, you will find LibreTime on [port 8080](http://localhost:8080), icecast on [port 8000](http://localhost:8000) and the docs on [port 8888](http://localhost:8888). -Once you reach the web setup GUI you can click through it using the default values. To connect to the vagrant machine you can run `vagrant ssh` in the libretime directory. +Once you reach the web setup GUI you can click through it using the default values. To connect to the vagrant machine you can run `vagrant ssh ubuntu` in the libretime directory. + +## Alternative OS installations + +With the above instructions LibreTime is installed on Ubuntu Trusty Tahir. The Vagrant setup offers the option to choose a different operation system according to you needs. + +| OS | Command | Comment | +| ------ | ------------------- | ------- | +| Ubuntu | `vagrant up ubuntu` | Current default install since it was used by legacy upstream, based on Trusty Tahir . | +| Debian | `vagrant up debian` | Recommended install on Jessie as per the docs. | +| CentOS | `vagrant up centos` | Experimental install on 7.3 with native systemd support and activated SELinux. | ## Troubleshooting If anything fails during the initial provisioning step you can try running `vagrant provision` to rerun the installer. + +If you only want to re-run parts of the installer, use `--provision-with install`. The supported steps are `prepare`, `install`, `install-mkdocs` and `start-mkdocs`. diff --git a/install b/install index efacf83a1..ed68ab322 100755 --- a/install +++ b/install @@ -1,4 +1,5 @@ #!/bin/bash -e + #-e Causes bash script to exit if any of the installers #return with a non-zero return value. @@ -75,6 +76,8 @@ _q=0 upgrade="f" dist="" code="" +apache_bin="apache2" + function verbose() { if [[ ${_v} -eq 1 ]]; then @@ -299,6 +302,9 @@ echo "| |___| || \_\ \ | \/\ ___/| | | | Y Y \ ___/ " echo "|_______ \__||___ /__| \___ >____| |__|__|_| /\___ >" echo -e " \/ \/ \/ \/ \/\n" +if [ "$dist" = "centos" ]; then + apache_bin="httpd" +fi if [ "$ignore_dependencies" = "f" ]; then set +e @@ -324,7 +330,7 @@ if [ "$ignore_dependencies" = "f" ]; then fi set -e else - checkCommandExists "apache2" + checkCommandExists "${apache_bin}" checkCommandExists "rabbitmqctl" checkCommandExists "psql" if [ "$in_place" = "t" ]; then @@ -338,8 +344,10 @@ eval hash "composer" 2>/dev/null commandFound=$? set -e if [[ ! ${commandFound} -eq 0 ]]; then - curl -sS https://getcomposer.org/installer | php - mv composer.phar /usr/local/bin/composer + curl -sS https://getcomposer.org/installer > get-composer.php + php ./get-composer.php --install-dir=/usr/local/bin --filename=composer + rm get-composer.php + PATH="${PATH}:/usr/local/bin" fi # Run composer (install PHP dependencies) and create a VERSION file @@ -414,9 +422,13 @@ if [ "$apache" = "t" ]; then loud "\n-----------------------------------------------------" loud " * Configuring Apache * " loud "-----------------------------------------------------" + apache_sitedir="/etc/apache2/sites-available/" + if [ "$dist" = "centos" ]; then + apache_sitedir="/etc/httpd/conf.d/" + fi set +e - apache2 -v | grep "2\.4" > /dev/null + $apache_bin -v | grep "2\.4" > /dev/null apacheversion=$? set -e @@ -432,7 +444,7 @@ if [ "$apache" = "t" ]; then # install apache, we should overwrite any existing configuration. If we don't do this, doing # an in-place installation over an old Airtime install (which installs to /usr/share by default) # will fail - if [ "$upgrade" = "t" -o ! -f /etc/apache2/sites-available/${airtimeconfigfile} ]; then + if [ "$upgrade" = "t" -o ! -f ${apache_sitedir}${airtimeconfigfile} ]; then verbose "\n * Creating Apache config for Airtime..." listen_port="" if [ "$web_port" != "80" ]; then @@ -448,15 +460,19 @@ if [ "$apache" = "t" ]; then -e "s@WEB_PORT_LISTEN@${listen_port}@g" \ -e "s@WEB_PORT@${web_port}@g" \ -e "s@WEB_ROOT@${web_root}@g" \ - ${apache_template_file} > /etc/apache2/sites-available/${airtimeconfigfile} + ${apache_template_file} > ${apache_sitedir}${airtimeconfigfile} - loudCmd "a2dissite 000-default" + if [ "$dist" != "centos" ]; then + loudCmd "a2dissite 000-default" + fi # If Airtime was previously installed with apt, the vhost file name is different, # so we need to specifically disable it. if [ -f "/etc/apache2/sites-available/${oldconfigfile}" ]; then loudCmd "a2dissite airtime-vhost" fi - loudCmd "a2ensite airtime" + if [ "$dist" != "centos" ]; then + loudCmd "a2ensite airtime" + fi else verbose "\nApache config for Airtime already exists, skipping" fi @@ -476,9 +492,15 @@ if [ "$icecast" = "t" ]; then loud "-----------------------------------------------------" verbose "\n * Enabling Icecast 2..." - sed -i 's/ENABLE=false/ENABLE=true/g' /etc/default/icecast2 + icecast_unit_name="icecast2" + if [ "$dist" != "centos" ]; then + sed -i 's/ENABLE=false/ENABLE=true/g' /etc/default/icecast2 + else + icecast_unit_name="icecast" + fi set +e - loudCmd "service icecast2 start" + # restart in case icecast was already started (like is the case on debian) + loudCmd "service ${icecast_unit_name} restart" set -e verbose "...Done" fi @@ -491,13 +513,17 @@ verbose "\n * Installing necessary python services..." loudCmd "pip install setuptools --upgrade" verbose "...Done" - - -if [[ `lsb_release -rs` == "14.04" ]] # Ubuntu trusty needs a workaround for python version SSL downloads -then -loudCmd "pip install pyOpenSSL cryptography idna certifi --upgrade" +# Ubuntu trusty needs a workaround for python version SSL downloads +# This affects all python installs where python < 2.7.9 +use_pyopenssl="" +if [ "$dist" != "debian" ] || [ "$code" = "wheezy" ]; then + use_pyopenssl="t" +fi +if [ "$use_pyopenssl" = "t" ]; then + verbose "\n * Installing pyOpenSSL and ca db for SNI support..." + loudCmd "pip install pyOpenSSL cryptography idna certifi --upgrade" + verbose "...Done" fi - verbose "\n * Creating /run/airtime..." mkdir -p /run/airtime @@ -519,11 +545,29 @@ verbose "...Done" verbose "\n * Installing airtime-celery..." loudCmd "python ${AIRTIMEROOT}/python_apps/airtime-celery/setup.py install" +# Make the airtime log directory group-writable +loudCmd "chmod 775 /var/log/airtime" +# Create the Celery user +if [ "$dist" = "centos" ]; then + loudCmd "id celery || adduser --no-create-home -c 'LibreTime Celery' -r celery || true" + loudCmd "systemctl enable airtime-celery" +else + loudCmd "id celery || adduser --no-create-home --gecos 'LibreTime Celery' --disabled-login --firstuid 1 --lastuid 999 celery" + loudCmd "update-rc.d airtime-celery defaults" +fi +# Add celery to the www-data group +loudCmd "usermod -G ${web_user} -a celery" + +if [ "$dist" = "ubuntu" ]; then + loudCmd "initctl reload-configuration" +fi verbose "...Done" verbose "\n * Installing airtime_analyzer..." loudCmd "python ${AIRTIMEROOT}/python_apps/airtime_analyzer/setup.py install --install-scripts=/usr/bin" -loudCmd "initctl reload-configuration" +if [ "$dist" = "ubuntu" ]; then + loudCmd "initctl reload-configuration" +fi verbose "...Done" for i in /etc/init/airtime*.template; do @@ -533,20 +577,31 @@ for i in /etc/init/airtime*.template; do done set +e -loudCmd "initctl reload-configuration" +if [ "$dist" = "ubuntu" ]; then + loudCmd "initctl reload-configuration" +fi # airtime-celery only has an init.d startup script -loudCmd "update-rc.d airtime-celery defaults" # Start at bootup, on Debian +if [ "$dist" = "centos" ]; then + loudCmd "systemctl enable airtime-celery" +else + loudCmd "update-rc.d airtime-celery defaults" # Start at bootup, on Debian +fi # On Ubuntu, we already have the upstart configs, so this is redundant # and causes multiple processes to spawn on startup -if [ "$dist" != "ubuntu" ]; then +if [ "$dist" = "debian" ]; then loudCmd "systemctl daemon-reload" #systemd hipsters loudCmd "update-rc.d airtime-playout defaults" # Start at bootup, on Debian loudCmd "update-rc.d airtime-liquidsoap defaults" # Start at bootup, on Debian loudCmd "update-rc.d airtime_analyzer defaults" # Start at bootup, on Debian fi +if [ "$dist" = "centos" ]; then + loudCmd "systemctl enable airtime-playout" + loudCmd "systemctl enable airtime-liquidsoap" + loudCmd "systemctl enable airtime_analyzer" +fi set -e if [ ! -d /var/log/airtime ]; then @@ -571,15 +626,21 @@ chmod -R a+x /var/tmp/airtime chown -R ${web_user}:${web_user} /var/tmp/airtime/ # PHP Config File for Apache -if [ ! -f "/etc/php5/apache2/conf.d/airtime.ini" ]; then - verbose "\n * Creating Airtime PHP config for Apache..." - cp ${SCRIPT_DIR}/installer/php/airtime.ini /etc/php5/apache2/conf.d/airtime.ini +libretime_phpini="/etc/php5/apache2/conf.d/airtime.ini" +if [ "$dist" = "centos" ]; then + libretime_phpini="/etc/php.d/airtime.ini" +fi +if [ ! -f "${libretime_phpini}" ]; then + verbose "\n * Creating LibreTime PHP config for Apache..." + cp ${SCRIPT_DIR}/installer/php/airtime.ini ${libretime_phpini} else verbose "\nAirtime PHP config for Apache already exists, skipping" fi # Enable Apache modules -loudCmd "a2enmod rewrite php5" +if [ "$dist" != "centos" ]; then + loudCmd "a2enmod rewrite php5" +fi loud "\n-----------------------------------------------------" loud " * Configuring PostgreSQL * " @@ -687,9 +748,18 @@ if [ "$ignore_dependencies" = "f" ]; then fi verbose "\n * Reloading apache..." -loudCmd "service apache2 reload 2>/dev/null" +if [ "$dist" != "centos" ]; then + loudCmd "service ${apache_bin} reload 2>/dev/null" + verbose "...Done" -IP=$(ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://') + IP=$(ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://') +else + verbose "systemctl restart ${apache_bin} 2>/dev/null" + loudCmd "systemctl restart ${apache_bin} 2>/dev/null" + verbose "...Done" + + IP=$(ip -o -4 address show dev eth0 | grep -Po 'inet \K[\d.]+') +fi echo -e "\n-----------------------------------------------------" echo " * Basic Setup DONE! * " diff --git a/installer/lib/requirements-debian-jessie.apt b/installer/lib/requirements-debian-jessie.apt index 666f2e34f..f7f7ea8c3 100644 --- a/installer/lib/requirements-debian-jessie.apt +++ b/installer/lib/requirements-debian-jessie.apt @@ -29,6 +29,7 @@ patch icecast2 +curl php5-curl mpg123 diff --git a/installer/lib/requirements-ubuntu-saucy.apt b/installer/lib/requirements-ubuntu-saucy.apt deleted file mode 100644 index e6f9954f8..000000000 --- a/installer/lib/requirements-ubuntu-saucy.apt +++ /dev/null @@ -1,68 +0,0 @@ -apache2 -libapache2-mod-php5 -php5 -php-pear -php5-gd -php5-json - -lsb-release - -rabbitmq-server - -postgresql -postgresql-client -php5-pgsql - -python -python-virtualenv -python-pip - -libsoundtouch-ocaml -libtaglib-ocaml -libao-ocaml -libmad-ocaml -ecasound -libportaudio2 -libsamplerate0 - -patch - -php5-curl -mpg123 - -icecast2 - -libcamomile-ocaml-data -libpulse0 -vorbis-tools -lsb-release -lsof -mp3gain -vorbisgain -flac -vorbis-tools -pwgen -libfaad2 -php-apc - -lame - -coreutils - -liquidsoap -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-portaudio -liquidsoap-plugin-pulseaudio -liquidsoap-plugin-taglib -liquidsoap-plugin-voaacenc -liquidsoap-plugin-vorbis - -silan -libopus0 \ No newline at end of file diff --git a/installer/lib/requirements-ubuntu-vivid.apt b/installer/lib/requirements-ubuntu-vivid.apt deleted file mode 100644 index dfcef4016..000000000 --- a/installer/lib/requirements-ubuntu-vivid.apt +++ /dev/null @@ -1,68 +0,0 @@ -apache2 -libapache2-mod-php5 -php5 -php-pear -php5-gd - -lsb-release - -rabbitmq-server - -postgresql -postgresql-client -php5-pgsql - -python -python-virtualenv -python-pip - -libsoundtouch-ocaml -libtaglib-ocaml -libao-ocaml -libmad-ocaml -ecasound -libportaudio2 -libsamplerate0 - -patch - -php5-curl -mpg123 - -icecast2 - -libcamomile-ocaml-data -libpulse0 -vorbis-tools -lsb-release -lsof -vorbisgain -flac -vorbis-tools -pwgen -libfaad2 -php-apc - -lame - -coreutils - -liquidsoap -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-portaudio -liquidsoap-plugin-pulseaudio -liquidsoap-plugin-taglib -liquidsoap-plugin-voaacenc -liquidsoap-plugin-vorbis - -silan -libopus0 - -sysvinit-utils diff --git a/installer/systemd/airtime-celery.service b/installer/systemd/airtime-celery.service new file mode 100644 index 000000000..59ae1ec3b --- /dev/null +++ b/installer/systemd/airtime-celery.service @@ -0,0 +1,13 @@ +[Unit] +Description=LibreTime Celery Service +After=network.target + +[Service] +User=celery +Group=celery +Environment=RMQ_CONFIG_FILE=/etc/airtime/airtime.conf +WorkingDirectory=/srv/airtime +ExecStart=/bin/celery worker -A airtime-celery.tasks:celery --time-limit=300 --concurrency=1 --config=celeryconfig -l INFO + +[Install] +WantedBy=multi-user.target diff --git a/installer/systemd/airtime-liquidsoap.service b/installer/systemd/airtime-liquidsoap.service new file mode 100644 index 000000000..07e8e6e4b --- /dev/null +++ b/installer/systemd/airtime-liquidsoap.service @@ -0,0 +1,10 @@ +[Unit] +Description=Airtime Liquidsoap Service + +[Service] +ExecStart=/usr/bin/airtime-liquidsoap +User=libretime-playout +Group=libretime-playout + +[Install] +WantedBy=multi-user.target diff --git a/installer/systemd/airtime-playout.service b/installer/systemd/airtime-playout.service new file mode 100644 index 000000000..af58c345b --- /dev/null +++ b/installer/systemd/airtime-playout.service @@ -0,0 +1,10 @@ +[Unit] +Description=Airtime Playout Service + +[Service] +ExecStart=/usr/bin/airtime-playout +User=libretime-pypo +Group=libretime-pypo + +[Install] +WantedBy=multi-user.target diff --git a/installer/systemd/airtime_analyzer.service b/installer/systemd/airtime_analyzer.service new file mode 100644 index 000000000..58743377a --- /dev/null +++ b/installer/systemd/airtime_analyzer.service @@ -0,0 +1,10 @@ +[Unit] +Description=LibreTime Media Analyzer Service + +[Service] +ExecStart=/usr/bin/airtime_analyzer +User=airtime-analyzer +Group=airtime-analyzer + +[Install] +WantedBy=multi-user.target diff --git a/installer/vagrant/centos.sh b/installer/vagrant/centos.sh new file mode 100644 index 000000000..199456273 --- /dev/null +++ b/installer/vagrant/centos.sh @@ -0,0 +1,154 @@ +#!/bin/bash + +# Additional Repos +yum install -y epel-release + +# Nux Dextop +yum install -y http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm + +# We are after PUIAS Unsupported where we get celery from +# the install needs forcing since springdale-core tries to replace centos-release +curl -O http://springdale.math.ias.edu/data/puias/6/x86_64/os/Packages/springdale-unsupported-6-2.sdl6.10.noarch.rpm +rpm -hiv --nodeps springdale-unsupported-6-2.sdl6.10.noarch.rpm +rm -f springdale-unsupported-6-2.sdl6.10.noarch.rpm +# we need to install the key manually since it is also part of springdale-core +curl -O http://puias.princeton.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias +rpm --import RPM-GPG-KEY-puias +rm -f RPM-GPG-KEY-puias + +# RaBe Liquidsoap Distribution (RaBe LSD) +curl -o /etc/yum.repos.d/home:radiorabe:liquidsoap.repo \ + http://download.opensuse.org/repositories/home:/radiorabe:/liquidsoap/CentOS_7/home:radiorabe:liquidsoap.repo + +# RaBe Audio Packages for Enterprise Linux (RaBe APEL) +curl -o /etc/yum.repos.d/home:radiorabe:audio.repo \ + http://download.opensuse.org/repositories/home:/radiorabe:/audio/CentOS_7/home:radiorabe:audio.repo + +# Update all the things (just to be sure we are on latest) +yum update -y + +# Database +yum install -y postgresql-server patch + +postgresql-setup initdb + +patch -f /var/lib/pgsql/data/pg_hba.conf << EOD +--- /var/lib/pgsql/data/pg_hba.conf.orig2016-09-01 20:45:11.364000000 -0400 ++++ /var/lib/pgsql/data/pg_hba.conf2016-09-01 20:46:17.939000000 -0400 +@@ -78,10 +78,11 @@ + + # "local" is for Unix domain socket connections only + local all all peer ++local all all md5 + # IPv4 local connections: +-host all all 127.0.0.1/32 ident ++host all all 127.0.0.1/32 md5 + # IPv6 local connections: +-host all all ::1/128 ident ++host all all ::1/128 md5 + # Allow replication connections from localhost, by a user with the + # replication privilege. + #local replication postgres peer +EOD + +systemctl enable postgresql +systemctl start postgresql +# create database user airtime with password airtime +useradd airtime +echo "airtime:airtime" | chpasswd + +su -l postgres bash -c 'createuser airtime' +su -l postgres bash -c 'createdb -O airtime airtime' + +echo "ALTER USER airtime WITH PASSWORD 'airtime';" | su -l postgres bash -c psql +echo "GRANT ALL PRIVILEGES ON DATABASE airtime TO airtime;" | su -l postgres bash -c psql + + +# RabbitMQ +yum install -y rabbitmq-server + +systemctl enable rabbitmq-server +systemctl start rabbitmq-server + +rabbitmqctl add_user airtime airtime +rabbitmqctl add_vhost /airtime +rabbitmqctl set_permissions -p /airtime airtime ".*" ".*" ".*" + +# LibreTime deps +yum install -y \ + git \ + php \ + php-xml \ + php-pdo \ + php-pgsql \ + php-bcmath \ + php-mbstring \ + httpd \ + liquidsoap \ + silan \ + icecast \ + python-pip \ + selinux-policy \ + policycoreutils-python \ + python-celery + +# for pip ssl install +yum install -y \ + python-devel \ + python-lxml \ + openssl-devel + + + +# SELinux Setup +setsebool -P httpd_can_network_connect 1 +setsebool -P httpd_can_network_connect_db 1 +setsebool -P httpd_execmem on # needed by liquidsoap to do stuff when called by php +setsebool -P httpd_use_nfs 1 # to get nfs mounted /vagrant +setsebool -P git_system_use_nfs 1 # same for git + +semanage port -a -t http_port_t -p tcp 9080 # default vagrant web port + +# Allow apache full access to /vagrant and /etc/airtime +semanage fcontext -a -t httpd_sys_rw_content_t "/vagrant(/.*)?" +semanage fcontext -a -t httpd_sys_rw_content_t "/etc/airtime(/.*)?" +semanage fcontext -a -t httpd_sys_rw_content_t "/srv/airtime(/.*)?" + +restorecon -Rv /vagrant /etc/airtime /srv/airtime + +# Disable default apache page +sed -i -e 's/^/#/' /etc/httpd/conf.d/welcome.conf + +# Quick and dirty systemd unit install (will be in package later) +unit_dir="/etc/systemd/system" +unit_src_dir="/vagrant/installer/systemd" +cp -rp ${unit_src_dir}/*.service ${unit_dir} + +# Overrides to use apache user for now (final packaging will have dedicated users) +for service in `ls ${unit_src_dir}/*.service`; do + unit_name=`basename ${service}` + if [ "$unit_name" = "airtime-celery.service" ]; then + continue + fi + sed -i \ + -e 's/User=.*/User=apache/' \ + -e 's/Group=.*/Group=apache/' \ + ${unit_dir}/${unit_name} +done + + +# for good measure, lets reload em +systemctl daemon-reload + +# celery will not run unless we install a specific version (https://github.com/pypa/setuptools/issues/942) +# this will need to be figured out later on and will get overriden by the docs installer anyhow :( +pip install setuptools==33.1.1 +pip freeze setuptools==33.1.1 + +# the web will fail badly if this is not set, using my personal default just because +echo 'date.timezone=Europe/Zurich' >> /etc/php.d/timezone.ini +systemctl restart httpd + +# icecast needs to be available to everyone +sed -i -e 's@127.0.0.1@0.0.0.0@' /etc/icecast.xml +systemctl enable --now icecast diff --git a/installer/vagrant/debian.sh b/installer/vagrant/debian.sh new file mode 100644 index 000000000..8789ed8d0 --- /dev/null +++ b/installer/vagrant/debian.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +DEBIAN_FRONTEND=noninteractive apt-get -y -m --force-yes install alsa-utils +usermod -a -G audio vagrant +usermod -a -G audio www-data diff --git a/installer/vagrant/ubuntu.sh b/installer/vagrant/ubuntu.sh new file mode 100644 index 000000000..2ea12abd5 --- /dev/null +++ b/installer/vagrant/ubuntu.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Install modern alsa module for snd-hda-intel +# slightly modernized from https://github.com/naomiaro/vagrant-alsa-audio +# https://wiki.ubuntu.com/Audio/UpgradingAlsa/DKMS +alsa_deb="oem-audio-hda-daily-dkms_0.201703070301~ubuntu14.04.1_all.deb" +wget -nv https://code.launchpad.net/~ubuntu-audio-dev/+archive/ubuntu/alsa-daily/+files/${alsa_deb} +dpkg -i ${alsa_deb} +rm ${alsa_deb} +DEBIAN_FRONTEND=noninteractive apt-get -y -m --force-yes install alsa + +usermod -a -G audio vagrant +# liquidsoap runs as apache +usermod -a -G audio www-data + diff --git a/python_apps/airtime-celery/setup.py b/python_apps/airtime-celery/setup.py index 58f92cdf0..c422acd51 100644 --- a/python_apps/airtime-celery/setup.py +++ b/python_apps/airtime-celery/setup.py @@ -31,18 +31,6 @@ def postinst(): # permissions for the defaults config file os.chmod('/etc/init.d/airtime-celery', 0755) os.chmod('/etc/default/airtime-celery', 0640) - # Make the airtime log directory group-writable - os.chmod('/var/log/airtime', 0775) - - # Create the Celery user - call(['adduser', '--no-create-home', '--gecos', '', '--disabled-login', '--firstuid', '1', '--lastuid', '999', 'celery']) - # Add celery to the www-data group - call(['usermod', '-G', 'www-data', '-a', 'celery']) - - print "Reloading initctl configuration" - call(['initctl', 'reload-configuration']) - print "Setting Celery to start on boot" - call(['update-rc.d', 'airtime-celery', 'defaults']) print "Run \"sudo service airtime-celery restart\" now." setup(name='airtime-celery', diff --git a/python_apps/airtime_analyzer/install/sysvinit/airtime_analyzer b/python_apps/airtime_analyzer/install/sysvinit/airtime_analyzer new file mode 100755 index 000000000..e341e4d0c --- /dev/null +++ b/python_apps/airtime_analyzer/install/sysvinit/airtime_analyzer @@ -0,0 +1,78 @@ +#!/bin/bash + +### BEGIN INIT INFO +# Provides: airtime_analyzer +# Required-Start: $local_fs $remote_fs $network $syslog $all +# Required-Stop: $local_fs $remote_fs $network $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Manage airtime_analyzer daemon +### END INIT INFO + +USERID=www-data +GROUPID=www-data +NAME=airtime_analyzer + +DAEMON=/usr/bin/$NAME +PIDFILE=/var/run/$NAME.pid + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Read configuration variable file if it is present +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.2-14) to ensure that this file is present +# and status_of_proc is working. +. /lib/lsb/init-functions + +start () { + start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \ + --make-pidfile --pidfile $PIDFILE --startas $DAEMON +} + +stop () { + # Send TERM after 5 seconds, wait at most 30 seconds. + start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE + rm -f $PIDFILE +} + +case "${1:-''}" in + 'start') + # start commands here + echo -n "Starting $NAME: " + start + echo "Done." + ;; + 'stop') + # stop commands here + echo -n "Stopping $NAME: " + stop + echo "Done." + ;; + 'restart') + # restart commands here + echo -n "Restarting $NAME: " + stop + start + echo "Done." + ;; + 'force-reload') + # reload commands here + echo -n "Reloading $NAME: " + stop + start + echo "Done." + ;; + 'status') + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + *) # no parameter specified + echo "Usage: $SELF start|stop|restart|status" + exit 1 + ;; +esac diff --git a/python_apps/airtime_analyzer/setup.py b/python_apps/airtime_analyzer/setup.py index 574b8e050..1d1ff773a 100644 --- a/python_apps/airtime_analyzer/setup.py +++ b/python_apps/airtime_analyzer/setup.py @@ -14,7 +14,8 @@ if '--no-init-script' in sys.argv: data_files = [] sys.argv.remove('--no-init-script') # super hax else: - data_files = [('/etc/init', ['install/upstart/airtime_analyzer.conf'])] + data_files = [('/etc/init', ['install/upstart/airtime_analyzer.conf']), + ('/etc/init.d', ['install/sysvinit/airtime_analyzer'])] print data_files setup(name='airtime_analyzer',