#!/bin/bash

#update and upgrade the server
 sudo apt update -y && sudo apt upgrade -y

#Install apache2
 sudo apt install apache2

#Start apache and check the status
 sudo service apache2 start
 sudo service apache2 status

#change owner of /var/www
 cd /var/www
 sudo chown -R $USER . && sudo chgrp -R $USER .

#remove symbolic html link
 rm -rf html

#clone github repository for lab-2b
git clone https://github.com/BYU-ITC-210-Students/Lab-2B-macienashif.git

#create symbolic html link for the cloned Github reop
 ln -s Lab-2B-macienashif/src html

#navigate to the sites-available directory
 cd /etc/apache2/sites-available

#copy 000-default.conf to it210_lab.conf
 sudo cp 000-default.conf it210_lab.conf

#execute the a2dissite and a2ensite command
 sudo a2dissite 000-default.conf
 sudo a2ensite it210_lab.conf

#reload apache2
 sudo service apache2 reload

#include all of the commands in step 2 of this lab
#TLS Certificate
sudo apt update -y && sudo apt upgrade -y
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --apache
sudo chown ubuntu -R /etc/letsencrypt
