#!/bin/bash

# The intended use of this script is to install Apache and Unified Origin when launching an instance with Ubuntu 18.04 LTS on AWS. 

# Add the Unified Streaming repository to your APT sources
echo "deb [arch=amd64] http://stable.apt.unified-streaming.com bionic multiverse" > /etc/apt/sources.list.d/unified-streaming.list

# Add the Unified Streaming public key to your keyring
apt-key adv --fetch-keys http://stable.apt.unified-streaming.com/unifiedstreaming.pub

# Update APT, and install mp4split, Apache and Unified Streaming webserver module
apt-get update
apt-get install mp4split apache2 libapache2-mod-smooth-streaming -y

# Switch from event to worker MPM and enable headers and Unified Streaming module
a2dismod mpm_event
a2enmod mpm_worker headers mod_smooth_streaming

# Disable default virtual host and remove irrelevant directory
a2dissite 000-default
rm -r /var/www/html

# Restart Apache
systemctl restart apache2.service
