辅导案例-MAD9112

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
MAD9112 – Fundamentals of Computer Hardware and Networking
Final Project

Introduction:
For the final project, you are to create a virtual machine using the Azure cloud. You should
install Ubuntu version 18.04 LTS. You should then install a web server and set up some web
pages for a website. Then, create a shell script that will launch many different commands on
your computer. Lastly, create a short URL and a QR code for launching a website on a mobile
device.


Part 1 Create Azure VM:

1. Create your free 30 day account on Azure here: https://azure.microsoft.com/en-
ca/free/

2. Follow this tutorial for creating a virtual machine in the cloud:
https://docs.microsoft.com/en-ca/azure/virtual-machines/linux/quick-create-
portal?toc=%2Fazure%2Fvirtual-machines%2Flinux%2Ftoc.json. Make sure that you stop
your virtual machines when you are not working on your final project. Leaving your
machine running when you don’t need it will use up your free credits faster since it costs
money to run your machine. 2 mark

3. Once you have your machine’s IP address, create a free account with noip.com:
https://www.noip.com/remote-access
Use your Algonquin login as the hostname, and pick one of the available domains to
register the ip address with your name. For instance, torunse.zapto.org could be
registered to 10.10.213.4 1 mark

4. In your Linux azure machine, look at /etc/nginx/nginx.conf. There should be a block:
server {

}

There should be a line: listen 80. This tells what port to listen for connections. There
should be another line: root /path/to/webpages. This tells you where to put your html
files. There is another line: index … This tells the web server what page to return when
the user enters a directory URL. Add the files: index.html. index.htm after the index
command so that it looks for index.html first, and index.htm second. 1 mark



Part 2:
5. This next part is a long list of commands to run in a shell script that you have to create.
First test each command and when you have figured it out, add it to the end of your
shell script. You should create a directory called FinalProject and initialize a git
repository. Create a shell script called RunFinalProject.sh, and commit it to git. Then
create a private github repository to save your file as you are working on it. Start with
item a), and when it works, commit your file with the comment “finished step a”. Then
work on step b, and when finished, commit it with the comment “finished step b”, and
so on until you reach step p. In the end, you should have a script file that does the
following one step after the other: 1 mark each

a. Create a directory called FinalProjectRepository
b. Go into that directory and initialize a git repository.
c. Copies your html files from /Library/WebServer/Documents into your
FinalProjectRepository directory from step a).
d. Commits the files you copied to git.
e. Create a Github repository from the command line. See this video for
instructions: https://www.youtube.com/watch?v=6xmFp4_U9-
A&feature=youtu.be
f. Push your repository. You’ll have to add the line that sets your upstream branch.
g. Use ssh to connect to your Azure virtual machine, using your no-ip domain
name. That means running: “ssh azureuser@MyNewIpAddress”, and remotely
execute commands:
i. Clone the repository that you created in step e). This is how you are
getting your html files from your computer to the destination computer.
ii. Delete the hidden “.git” directory so that the web server doesn’t think it’s
part of your website
iii. Move the repository into the web server directory
iv. Start the Nginx server
h. On your macbook, open a web browser (Safari or Firefox) to your website that
you started on the Azure virtual machine. I’ve given an example of a command
that opens Firefox to the page http://www.cbc.ca, but modify the example to go
to your Azure virtual machine, and open Safari instead of firefox:
open -a Firefox http://www.cbc.ca
i. Launch an Android virtual device:
/Users/yourName/Library/Android/sdk/emulator/emulator -avd
Nexus_5X_API_23. (Change the name of the emulator to one that you’ve
created.
j. Use adb to launch a web browser on your emulator that goes to the website on
your Azure virtual machine.
k. Create a Dockerfile that uses Ubuntu:Latest version, and the rest is like lab 7.
l. Build the docker container
m. Launch the docker web server on port 1234
n. Launch an iPhone 8 emulator that goes to the docker website you just started
serving (http://localhost:1234)
o. ssh back into your Azure virtual machine, update apt, upgrade the packages and
shut it down using the command “shutdown -h now”. The -h means halt and
don’t reboot. In lab 6, we used shutdown -r now.
p. Open a browser that loads to the Azure virtual machine console that shows that
the virtual machine has stopped.

Part 3:
6. Once finished and it works, commit your work to github and push all of your commits.
Then create a branch called FinalComments. 1 mark

7. Go to https://bitly.com/. This is a URL shortener where you make short URLs that
redirect to a longer URL. Click on the “Get Started for Free” button on the left.


Once you created an account, click “Create your first link”. Paste the URL of your github
repository into the field for “Long URL”. Then click “Create” at the bottom right side. On
the next page, customize the back-half to be: your Algonquin id, followed by MAD9112,
like: bit.ly/toru0024_MAD9112. Then click “Save”.

8. Next go to: https://www.qr-code-generator.com/. Paste your Bit.ly URL into the space
where it says “Enter your website, text, or drop a file here”. There will be a 2-d Square
code that gets generated from the text. Pick one of the pictures that has a frame around
it: .

9. Click the button that says “Save as .jpg”. A window will show up saying that there is a
free sign-up for an account:


Ignore this window and just wait 10 seconds and a download window will show
up letting you download it for free. Save the .jpg picture (actually called frame.png) into
your FinalProject directory.

10. In your final project directory on your computer, create a README file that has your
name, student number, and Bit.ly short URL to your github repository. Commit this
README file and the .jpg QR code (actually called frame.png, not a jpg!) to your branch,
push your commit to github. From GitHub do a Pull Request to merge your files onto the
master branch. You should have three files in your repository at the end: README,
frame.png and RunFinalProject.sh. Add the professor as a collaborator to your
repository so that the commit history is visible. 3 marks

11. For final submission, create a TAR file which has your three files, and call it
FinalProject_YourName.tar.bz2. Don’t forget to use the -j parameter to use the BZip2
compression algorithm. Upload this file to Brightspace under the FinalProject
assignment. 1 mark

12. Ask the professor for an NFC tag from the equipment cabinet, and to borrow an Android
phone. The android phone will have an application installed called NFC tools. Use this
application to write the URL for your Acure virtual machine onto the tag. Then give the
tag to the professor who will scan the tag to see your web page. 1 mark


To get marks for this project, you have to demonstrate that your script works on your
computer, and then submit the files. This involves both demonstration,
and file submission!

Hints:
Below are some commands that you need for the final project.
1. To ssh into another computer and run a program, the command is:
ssh azureuser@ipaddress ‘command1; command2; command3;’
You list all of the commands you want to run between single-quote ‘ ‘.
Normally, this would require you to type in the username and password, but if you copy
the contents of the ssh key file: id_rsa.pub from your Azure portal into your Macintosh
~/.ssh/known-hosts, you don’t need to log in. On your azure console, type more
~/.ssh/id_rsa.pub.
Copy the output of the file and paste it into a new line on your macbook file: ~/.ssh
known_hosts. If you don’t have a file, then create one:
code ~/.ssh/known_hosts

2. To list the Android virtual devices that you have on your computer, run:
~/Library/Android/sdk/emulator/emulator -list-avds

3. To list the Apple virtual devices that you have on your computer, run:
xcrun simctl list

4. This produces a really long list. You are looking for the line near the top that says
==Devices==. The iPhone 8 device should be listed on the next line:



5. Look at the long string of numbers and letters beside the iPhone 8 name. To launch that
device, type:
xcrun simctl boot 701B5063-8B5B-46D2-B4DD-B1E182FF5D47

but change the string to whatever is on your computer:
The next line is to launch the simulator program:

open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app

and lastly launch a webpage on that loaded device:

xcrun simctl openurl booted "http://..."
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468