Mini Project #4
Shell Scripting (100 pts)
Script #1 (25 points – 5 minutes)
Create a directory in /home/ubuntu called Project1
Create a script file called script1.sh
Edit the script1.sh file to execute the following:
Prompt the user for their username
Display “Hello [username], welcome to your Virtual Machine.”
Test the script by running it with the username of TestUser
Run script1.sh again and send the outputs of the script to a file called login.txt
Username: Michael Jordan
In the Project1 dir create a file called script2.sh
Edit the script2.sh file to do the following:
Create the following prompt: “Please enter your first and last name: ”
Create the following prompt: “Hi [first and last name], please enter your student ID: ”
Create an if then statement that does the following:
Checks if the student ID equals 1234
Then display “Welcome [first and last name]. You are enrolled in the class.”
If not then display “Error: Invalid student ID [student ID], please try again.”
Run script2.sh with the following parameters
First and Last Name: Michelle Brown
Student ID: 1243
Re-Run script2.sh with the following parameters
First and Last Name: Michelle Brown
Student ID: 1234
Script #3 (25 points – 10 minutes)
In the Project1 directory create a file called script3.sh
Edit the script3.sh file to do the following:
Create a new file called example1.txt in Project1/
Add the following text “This file was created on [insert date and time].” to example1.txt
Run command Sleep for 30 secs
Add a variable called name and set it to your first name
Add “I am [name] and I added this line at [date and time above].” to example1.txt
Run script3.sh to test for functionality
Run the command that will stop your Apache2 server
Create a file called script4.sh inside Project1/ directory
Edit the script4.sh file to do the following:
Create a function called webserver
The webserver function should be able to do the following:
Create a file called webstart.log
Start apache2 and send the outputs to webstart.log
Check the status of the apache2 service and add outputs to webstart.log
Navigate to /var/www/html dir
Copy index.html to index.html.copy
Move index.html.copy to /home/ubuntu
Delete the index.html file
Create a new index.html file
Change ownership of index.html to ubuntu
Add the following to index.html “Hello World!”
Restart the apache2 service and add outputs to webstart.log
When you are finished do the following to verify your function worked:
Display the contents of your index.html file
Via Browser Navigate to your IP address (ask me for your public IP)