The creation of the menu will involve writing procedural code, using decision logic, writing a loop, and using the case statement. Although it is not required for grading, it is recommended that you flowchart and /or pseudo code your solution before coding.
General requirements
1. The script should contain a comment header as we discussed in class. Include comments / pseudo code in your script.
2. Include the 'shebang' line for the bash shell found on Ubuntu.
3. Redirect any errors to a separate error file.
4. Clear the screen, change directories to the directory and present the current directory to the screen.
5. Make your file read, write, executable for the owner (that's you), read and executable for group and no permissions for other. -rwxr-x---
6. Create all report files with read only permissions for owner and group and no permissions for other.
7. At top of the menu check for the existence of the subdirectory logs. If it does not exist, create it.
8. Store the program directory in a variable and use it to define the full file name.
9. For each report write the files to the new logs directory, add the time to make it unique for each instance, i.e. whoyymmddhhmm.rpt
10. After writing the report to the disk, display all of the reports to the screen. Look into using the awk program to 'pretty up' the report. See the examples in the exercises.
11. Create a separate error file for each of the menu selections, adding the date and time like the report file, i.e. whoyymmddhhmm.err
The menu
1. Create a menu with the following selections (Hint start out by just creating the menu and echoing a message on the screen when a selection is made:
a. Who is on system report
b. Process Report
c. Web server report
d. Disk Space Report
e. Backup reports
f. Quit
2. Who is on System Report --Create a new empty file to contain the first report.
a. Put the current date and time at the top of the file in this format: MM/DD/YY HH:DD (hint not default output - use formatting.)
b. List the users on the system and redirect the output from standard output to the file retaining the date and time you put in the file in task above.
c. Count the number of users on the system and add it to the end of the file.
d. Using one of the paginators, view the file you just created
3. User Process Report -- Create a second new file to contain report 2
a. Put the current date and time at the top of the file in this format: MM/DD/YY HH:DD (hint not default output - use formatting.)
b. List all of the processes associated with a tty into the file.
c. Sort the file by the process id.
d. Count the number of processes and put to the bottom of the file.
e. Using one of the paginators, view the file you just created
4. Web Server Report -- check for the program httpd. Print a message on the screen with the status. No files needed here.
5. Backup Reports -- Use the tar command and create a backup. The backup should have the following functionality:
a. In the new logs directory, check to see if a sub-directory of archive exists, if it does not create it.
b. Archive the files into a compressed tar ball in the logs/archive folder.
c. Check if the file to check if it was created and has size greater than zero.
d. Check the file counts in the tar ball valid (hint use a file size check and/or compare the file count from the tar tv command with the count of files from the ls command)
e. If the backup passed the validation, remove the report and error files.