COP4342 - 2016 Fall
Web server assignment

Please visit http://45.56.74.139:33336/cgi-bin/COP4342.

Your assignment is to recreate the same sort of site on the machine 45.56.74.139.

Please use the following scheme for your port number: from the attendance roster, note which number is beside your name. Add 38000 to that number; for instance, if the number beside your name was 59, you would put your server on port 38059, and would access your service as http://45.56.74.139:38059/cgi-bin/COP4342.

You should create two BASH scripts to do this: a script called "~/bin/start-server", and a script called "~/cgi-bin/COP4342".

In your start-server script, please use busybox's built-in webserver. You can access this functionality by creating a soft-link in ~/bin to /bin/busybox.

I would suggest that your start-server script first try to kill any existing httpd processes using pkill. I would then suggest building a new run directory named "html" each time (I would do a "rm -rf ~/html" first, and then create it anew.) I would then copy the entire ~/cgi-bin into your new ~/html directory.

COP4342_test@(none):~$ ls -lR
.:
total 12
drwxr-xr-x 2 COP4342_test COP4342_test 4096 Sep 29 17:31 bin
drwxr-xr-x 2 COP4342_test COP4342_test 4096 Sep 29 17:31 cgi-bin
drwxr-xr-x 3 COP4342_test COP4342_test 4096 Sep 29 17:19 html

./bin:
total 4
lrwxrwxrwx 1 COP4342_test COP4342_test  12 Sep 29 17:19 httpd -> /bin/busybox
-rwxr-xr-x 1 COP4342_test COP4342_test 144 Sep 29 17:19 start-server

./cgi-bin:
total 4
-rwxr-xr-x 1 COP4342_test COP4342_test 219 Sep 28 19:22 COP4342

./html:
total 4
drwxr-xr-x 2 COP4342_test COP4342_test 4096 Sep 29 17:31 cgi-bin

./html/cgi-bin:
total 4
-rwxr-xr-x 1 COP4342_test COP4342_test 219 Sep 28 19:22 COP4342
COP4342_test@(none):~$ 
Finally, your start-server script should start up the server in a fashion that will allow you to log out but still keep the server going.

In your COP4342 script, this should be a simple Bash file that sends as output:

Content-type: text/html

<html>
<meta http-equiv="refresh" content="5">
<title>Fortunes</title>
<body>
<pre>

 [[[ output from fortune piped to cowsay ]]]

</pre>
</html>

The area in [[[ ]]] is not literal; instead, this should be invocation of the program /usr/games/fortune piped to /usr/games/cowsay.

Embellishment: yes, you may embellish your output; for instance, you could have your cow move to different areas of the screen, or use figlets. There are literally a host of ideas here.

Submission: Please tar up your ~/bin/ and ~/cgi-bin/ directories and submit the tar file on Blackboard.