Scripting Compatibility for Current OPS235 labs: (Week-by-week)

From CDOT Wiki
Revision as of 15:04, 4 February 2015 by Msaul (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Purpose of this Resource:

To match compatibility of scripting elements for current OPS235 labs. Emphasis will be placed on practicality, creativity, and listing scripting items that can be used to match and compare towards existing scripting course OPS435 to provide information for CNS / CTY curriculum discussions. This particular WIKI will concentrate on long-term "fits" (i.e. major structural changes to course from existing learning outcomes, topics and core skills on OPS335 and OPS435 courses as well as other courses in the OPS Stream).

Comparison Chart (Scripting Skills) by Course Outline

(pending OPS stream discussion meeting and consensus of all parties including chair and curriculum development committee):
Scripting Skills Match (course outlines for sample shell scripts shown below):
[ ULI101 ] OPS235 ] [ ops335 ] [ OPS435 ]

Lab 1:

Scripting for Lab1. Lab 1 could be modified to have students generate a report regarding the collection of Linux information after an install. Certainly command substitution could be taught and to reinforce redirection >> to add content to a filename (i.e. not over-ride). It would be interesting to expose students to the zenity command to allow a menu to give user choice of report elements to include in the generated report. Perhaps a link to a "fancy" Bash shell script to generate a web-page so students can view the contents in a nice format. This scripting element could easily be added to assignment #1.

It is recommended to add to lab1 a simple step-by-step procedure to generate a simple text-based report in a shell script (eg. text-report.bash), but also have students use wget command to download, set execute permissions and run more sophisticated shell scripts (eg. report.bash and report2.bash)
Script #1: Generate a Simple Report: [ text-report.bash ]
Sample output: [ /root/report.txt ]

Scripting Skills:
  • if statement
  • exit command
  • USER Environment Variable
  • redirection (both > and >>)
  • command substitution
Practical Consideration for scripting in lab1:
Students create simple bash shell script, add elements, then have them copy and paste, then run this script. Key elements related to the script is evaluated and provides basis for other scripting tasks in other labs? Should midterm and/or final exam contain a scripting question? (recommended)

When executed as root or using sudo command, script generates a basic text-based report in a file
Script #2 Generate Report Graphically: [ report.bash ]
Sample output: [ /root/report.txt ]

Scripting Skills:
  • if statement
  • exit command
  • USER Environment Variable
  • redirection (both > and >>)
  • zenity
  • for loop
  • command substitution
  • sed
  • set command (positional parameters)


Practical Consideration for scripting in lab1:
Students use wget to download existing shell script and run it to see what happens. Students are encouraged to view contents of more advanced shell script(s), to see where the commands are being used (from previous shell script), but are not required to understand more complex elements of these shell scripts.

When executed as root or using sudo command, provides VM status and opportunity to start VMs
When executed as root or using sudo command, provides VM status and opportunity to stop running VMs
Script #3: Generate Web-based Report:
Script: [ report3.bash ]
Result: [ installation_report.html ]

Scripting Skills:
  • if statement
  • exit command
  • USER Environment Variable
  • redirection (both > and >>)
  • for loop
  • Command Substitution
  • positional parameters
  • sed
  • zenity


Practical Consideration for scripting in lab1:
Students use wget to download existing shell script and run it to see what happens. Students are encouraged to view contents of more advanced shell script(s), to see where the commands are being used (from previous shell script), but are not required to understand more complex elements of these shell scripts.

When executed as root or using sudo command, generate HTML and JavaScript code and launches in Firefox
Note in web-browser, user can click "expandable" areas to view detail, or "collapse" to original form.

Lab 2:

Scripting for Lab2. Lab 2 could be modified to have students create or be exposed to shell scripts with use the virtual shell (virsh) to display in zenity available VMS in checkbox form to select and launch. Likewise, script can be launched to display in zenity VMs that are currently running in order to shutdown (perhaps in same fashion as a zenity dialog box).


Script #1: Backup VM images: [ backupVM.bash ]
Sample output: [ Output Image ]

Scripting Skills:
  • If and Else If (elif) - With numerical and string comparisons in the test statement
  • User Input (read statement)
  • For loop with a hard coded list
  • Echoing a variable to grep to validate input
  • Checking exit status of previous command (should be a review from ULI101)
  • gzip command
  • Environment variables
  • x
  • x


Practical Consideration for scripting in lab 2:
TBD

When executed as root or using sudo command, allows for selection of VM images in /var/lib/libvirt/images directory and backs-up user's home directory (allow option to copy all or by vm #
Script #2: Backup VM images (Graphical):
[ ] (to be created)

Scripting Skills:
  • x
  • x
  • x
  • x
  • x
  • x
  • x
  • x
  • zenity


Practical Consideration for scripting in lab2:
Students use wget to download existing shell script and run it to see what happens. Students are encouraged to view contents of more advanced shell script(s), to see where the commands are being used (from previous shell script), but are not required to understand more complex elements of these shell scripts.

File:Lab2-backup-image-2.png
When executed as root or using sudo command, allows for selection of VM images in /var/lib/libvirt/images directory and backs-up to various media options
Script #3 :Start/Stop VMs (text-based):
[ vm-start-text.bash ] [ vm-stop-text.bash ]

Scripting Skills:
  • if statement
  • for loop
  • Command Substitution
  • Advanced awk
  • positional parameters
  • The "Here" Document (redirection within command)
  • virsh command


Practical Consideration for scripting in lab2:
Students use wget to download existing shell script and run it to see what happens. Students are encouraged to view contents of more advanced shell script(s), to see where the commands are being used (from previous shell script), but are not required to understand more complex elements of these shell scripts.

When executed as root or using sudo command, provides VM status and opportunity to start VMs in a text-based interface
When executed as root or using sudo command, provides VM status and opportunity to stop running VMs in a text-based interface
Script #4 :Start/Stop VMs (graphically):
[ vm-start.bash ] [ vm-stop.bash ]

Scripting Skills:
  • if statement
  • for loop
  • Command Substitution
  • Advanced awk
  • positional parameters
  • sed
  • IO Stream vs Graphical Interaction (eg. zenity)
  • virsh command


Practical Consideration for scripting in lab2:
Students use wget to download existing shell script and run it to see what happens. Students are encouraged to view contents of more advanced shell script(s), to see where the commands are being used (from previous shell script), but are not required to understand more complex elements of these shell scripts.

When executed as root or using sudo command, provides VM status and opportunity to start VMs
When executed as root or using sudo command, provides VM status and opportunity to stop running VMs


Lab 3:

This lab deals with software installation and introduction to LVM. Not certain shell scripting would benefit software installation with yum, since can use yum to install multiple instances of software. On the other hand, would be useful to expose students to shell scripts that manage LVM for practical situations (i.e. case scenarios - real world situations). Should consult with professors and industry SMEs to provide good examples of scripts involving LVM. LVM scripting example should be included in this lab since lab4 is a big lab and keeps students very involved.

When executed as root or using sudo command, allows for creation of many user accounts (stored in a user database in /root/new-users.txt
Shell Script #1 (monitor Disk Space): [ [monitor-disk-space.bash] ]
(Courtesy: http://bash.cyberciti.biz/monitoring/shell-script-monitor-unix-linux-diskspace/)

Scripting Skills:
  • df
  • grep
  • awk
  • command substitution
  • mail
  • cut
  • do-while loop
  • Cron Tables(crontab)

Practical Consideration for scripting in lab3:

Do students create simple bash shell script, add elements, then have them copy and paste, then run this more complex script? Is lab2 too long for scripting element to be included? Key elements of scripting elements should be contained in information boxes in lab. Should midterm and/or final exam contain a scripting question? (recommended)

Script #2 User LVM Management: [ ] ??

Scripting Skills:
  • x
  • x
  • x
  • x
  • x
  • x
  • x
  • x
  • x
  • x
  • x
  • x


Practical Consideration for scripting in lab4:

Practical Consideration for scripting in lab3: Possible "teachable area" to add as end of lab4 for students to learn manipulating data files for mass (batch) processing. Do students create simple bash shell script, add elements, then have them copy and paste, then run this more complex script? Is lab2 too long for scripting element to be included? Key elements of scripting elements should be contained in information boxes in lab. Should midterm and/or final exam contain a scripting question? (recommended)

File:Lab3 2.png
When executed as root or using sudo command, allows for creation of many user accounts (stored in a user database in /root/new-users.txt

Lab 4:

Script #1 User Account Management: [ create-users.bash ]
Sample of new employee database: [ /root/new-users.txt ]

Scripting Skills:
  • if statement
  • Testing for existence of regular file
  • Arrays
  • Math Expressions
  • exit command
  • USER Environment Variable
  • redirection (both > and >>)
  • useradd
  • for loop
  • command substitution
  • mail
  • awk command (positional parameters)


Practical Consideration for scripting in lab4:

Practical Consideration for scripting in lab3: Possible "teachable area" to add as end of lab4 for students to learn manipulating data files for mass (batch) processing. Do students create simple bash shell script, add elements, then have them copy and paste, then run this more complex script? Is lab2 too long for scripting element to be included? Key elements of scripting elements should be contained in information boxes in lab. Should midterm and/or final exam contain a scripting question? (recommended)

When executed as root or using sudo command, allows for creation of many user accounts (stored in a user database in /root/new-users.txt

Lab 5:

A shell script to graphically display status of services and start and stop them.
Script #1: Service Status (start and stop services - Text based):
[ service-start-text.bash ] [ service-stop-text.bash ]

Scripting Skills:
  • if statement
  • Here document (redirection)
  • service utility
  • grep
  • exit command
  • USER Environment Variable
  • redirection (both > and >>)
  • testing by true-false return of pipeline command
  • for loop
  • command substitution
  • awk command
  • positional parameters


Practical Consideration for scripting in lab2:
Students use wget to download existing shell script and run it to see what happens. Students are encouraged to view contents of more advanced shell script(s), to see where the commands are being used (from previous shell script), but are not required to understand more complex elements of these shell scripts.

When executed as root or using sudo command, provides Service status and opportunity to start non-running services
When executed as root or using sudo command, provides Service status and opportunity to stop running services
Script #2: Service Status (start and stop services: Graphical):
[ ] [ ] (to be completed)

Scripting Skills:
  • x
  • x
  • x
  • x
  • x
  • x
  • x


Practical Consideration for scripting in lab2:
Students use wget to download existing shell script and run it to see what happens. Students are encouraged to view contents of more advanced shell script(s), to see where the commands are being used (from previous shell script), but are not required to understand more complex elements of these shell scripts.

File:Service start graphical 1.png
When executed as root or using sudo command, provides Service status and opportunity to start non-running services
File:Service stop graphical 1.png
When executed as root or using sudo command, provides Service status and opportunity to stop running services

Lab 6:

Definitely a shell script to demonstrate the automation of IP tables (simpler example). I assume would be great benefit to OPS335 course that students be exposed to this to help automate their management of firewalls in OPS335.

Lab 7:

Lab 8:

Assignment 1:

  • Add element to existing assignment to develop an asset inventory for installed Linux system. Perhaps use html template to create nice-looking report based on required content.
  • Add element to create a shell script to backup VMs from /var/lib/libvirt/images to a USB device.

Assignment 2:

  • Add a shell script requirement to automate compilation of source code. For example: obtaining a zipped tarbar via url (wget), decompression zipped tarball, change to source directory, logic to see if ./configure command needs to be run, compile and run software or provide error or problems of failure to install software.

Quizzes:

Additional Comments

Additional Resources