Open main menu

CDOT Wiki β

Changes

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

14,863 bytes added, 16:04, 4 February 2015
no edit summary
==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 resource particular WIKI will concentrate initially with shorton long-term "fits" (i.e. no major structural changes to course from existing learning outcomes, topics and core skillson 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):'''<br>[ [https://docs.google.com/document/d/1CvdVdzUljH3ubcPFc6diSD3fnlMvVF59IOwTs-uA_r0/edit?usp=sharing ULI101] ] [https://docs.google.com/document/d/1UkrR9Bi431BEyWz7iTUIlIg1ycdqJTwwzHfbLkBdYnQ/edit?usp=sharing OPS235] ] [ [https://docs.google.com/document/d/17nTZZEg6rPYZT-rGiC2MHrz7TVHTw8aIMIvE6tqHnUk/edit?usp=sharing ops335] ] [ [https://docs.google.com/document/d/1RP_1QjQkKrvV8BLGRoglVZAg4v8Y1Bquuo7aVkS8glg/edit?usp=sharing OPS435] ]<br><br>
== Lab 1:==
[[Image:lab1-script-1.png||right||thumb|275px|When executed as '''root''' or using '''sudo''' command, prompts for elements to include in report]][[Image:lab1-script-2.png||right|thumb|275px|Notifies completion of report and file pathname of report]]::'''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.<br><br>OPS435 ElementsIt 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'''){|cellpadding="15" width="100%"|-|'''Script #1: Generate a Simple Report:''' [ [https://scs.senecac.on.ca/~murray.saul/text-report.bash text-report.bash] ]<br>'''Sample output:''' [ [https://scs.senecac.on.ca/~murray.saul/report.txt /root/report.txt] ]<br><br>'''Scripting Skills:'''<blockquote><ul><li>'''if''' statement</li><li>'''exit'''command substitution</li><li>USER '''Environment Variable''' (shell grammar?)</li><li>'''redirection''' (both &gt; vs and &gt;&gt;)></li><li>'''IO Stream vs Graphical Interactioncommand substitution''' (eg. zenity)</li><li/ul></blockquote>'''Scripting Samples (View and adaptPractical Consideration for scripting in lab1:'''- don't "re-invent <br><blockquote> Students create simple bash shell script, add elements, then have them copy and paste, then run this script. Key elements related to the wheel completely"script is evaluated and provides basis for other scripting tasks in other labs? Should midterm and/or final exam contain a scripting question? (recommended)</libr><libr>Exposure to |[[Image:lab1-script-text-report.png|thumb|left|400px|When executed as '''forroot''' loop with or using '''positional parameterssudo''' (storing checkbox selections) for command, script generates a basic text-based report<in a file]]|}{|cellpadding="15" width="100%"|-|'''Script #2 Generate Report Graphically:''' [ [https://scs.senecac.on.ca/ul><~murray.saul/blockquote>report.bash report.bash] ]<br><br>Example of Shell script Demo'''Sample output: ''' [ [[lab1 Shell Script Demo|https://scs.senecac.on.ca/~murray.saul/report.txt /root/report.bash]txt] ]<br><br>Listing of '''Scripting Skills from Demo Listed Above:'''<blockquote><ul><li>'''if''' statement</li><li>'''exit''' command</li><li>USER '''Environment Variable'''</li><li>'''redirection''' (both &gt; and &gt;&gt;)</li><li>'''zenity'''</li><li>'''for''' loop</li><li>'''command substitution'''</li><li>'''sed'''</li><li>'''set''' command ('''positional parameters''')</li></ul></blockquote><br><br>Connection with ULI101 Scripting Skills '''Practical Consideration for scripting in lab1:<br><blockquote>''' 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 (Course Outlinefrom previous shell script), but are '''not required to understand more complex elements''' of these shell scripts.<br><br>|[[Image:lab1-script-1.png|thumb|left|175px|When executed as '''root''' or using '''sudo''' command, provides VM status and opportunity to '''start''' VMs]]|[[Image:lab1-script-2.png|thumb|left|175px|When executed as '''root''' or using '''sudo''' command, provides VM status and opportunity to stop '''running''' VMs]]|}{|cellpadding="15" width="100%"|-|'''Script #3: Generate Web-based Report''':<br>'''Script''': [ [https://scs.senecac.on.ca/~murray.saul/report3.bash report3.bash] ]<br>'''Result:''' [ [https://scs.senecac.on.ca/~murray.saul/installation_report.html installation_report.html] ]<br><br>Connection with OPS435 '''Scripting Skills :'''<blockquote><ul><li>'''if''' statement</li><li>'''exit''' command</li><li>USER '''Environment Variable'''</li><li>'''redirection''' (Course Outlineboth &gt; and &gt;&gt;):</li><li>'''for''' loop</li><li>'''Command Substitution'''</li><li>'''positional parameters'''</li><li>'''sed'''</li><li>'''zenity'''</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab1:<br><blockquote>''' Students use '''wget''' Do students create simple bash to download existing shell script and run it to see what happens. Students are '''encouraged to view contents of more advanced shell script(s)''', add elementsto see where the commands are being used (from previous shell script), then have them copy and paste, then run this but are '''not required to understand more complex script? Key elements ''' of scripting elements should be contained in information boxes in labthese shell scripts. Should midterm and/or final exam contain a scripting question? (recommended)<br><br>|[[Image:report3_1.png|thumb|left|275px|When executed as '''root''' or using '''sudo''' command, generate HTML and JavaScript code and launches in Firefox]]|[[Image:report3_2.png|thumb|left|275px|Note in web-browser, user can click "expandable" areas to view detail, or "collapse" to original form.]]|}
== Lab 2:==
[[Image:lab2-script-1.png||right||thumb|275px|When executed as '''root''' or using '''sudo''' command, provides VM status and opportunity to launch VMs]]::'''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).  {|cellpadding="15" width="100%"|-|<blockquote>'''Script #1: Backup VM images:''' [ [https://scs.senecac.on.ca/~elizabeth.kopiec/backupVM.bash backupVM.bash] ]<br>'''Sample output:''' [ [https://scs.senecac.on.ca/~elizabeth.kopiec/VMBackupOutput.png Output Image] ]<br><br>'''Scripting Skills:'''<blockquote><ul><li>If and Else If (elif) - With numerical and string comparisons in the test statement</li><li>User Input (read statement)</li><li>For loop with a hard coded list</li><li>Echoing a variable to grep to validate input</li><li>Checking exit status of previous command (should be a review from ULI101)</li><li>gzip command</li><li>Environment variables</li><li>x</li><li>x</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab 2:'''<br><blockquote> TBD<br><br>|[[Image:vm-backup-text.png|thumb|left|375px|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 #]]|} {|cellpadding="15" width="100%"|-|<blockquote>'''Script #2: Backup VM images (Graphical):'''<br>OPS435 Elements [ ] (to be created)<br><br>'''Scripting Demo ContentsSkills:'''<blockquote><ul><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>'''zenity'''</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab2:<br><blockquote>''' 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.<br><br></blockquote>|[[Image:lab2-backup-image-2.png|thumb|left|175px|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]]|} {|cellpadding="15" width="100%"|-|<blockquote>'''Script #3 :Start/Stop VMs (text-based):'''<br>[ [https://scs.senecac.on.ca/~murray.saul/vm-start-text.bash vm-start-text.bash] ] [ [https://scs.senecac.on.ca/~murray.saul/vm-stop-text.bash vm-stop-text.bash] ]<br><br>'''Scripting Skills:'''<blockquote><ul><li>'''if''' statement</li><li>'''for''' loop</li><li>'''Command Substitution'''</li><li>Advanced '''awk'''</li><li>'''positional parameters'''</li><li>The '''sed"Here" Document'''(redirection within command)</li><li>'''IO Stream vs Graphical Interactionvirsh''' (eg. zenity)command</li><li/ul></blockquote><br><br>'''Practical Consideration for scripting in lab2:<br><blockquote>'''Scripting Samples 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 (View from previous shell script), but are '''not required to understand more complex elements''' of these shell scripts.<br><br></blockquote>|[[Image:lab2_text_1.png|thumb|left|275px|When executed as '''root''' or using '''sudo''' command, provides VM status and adapt)opportunity to '''start'''VMs in a text-based interface]]|[[Image:Lab2- donbackup-image-1.png|thumb|left|275px|When executed as '''root''' or using '''sudo''' command, provides VM status and opportunity to stop '''running'''t VMs in a text-based interface]]|} {|cellpadding="re15" width="100%"|-|<blockquote>'''Script #4 :Start/Stop VMs (graphically):'''<br>[ [https://scs.senecac.on.ca/~murray.saul/vm-start.bash vm-start.bash] ] [ [https://scs.senecac.on.ca/~murray.saul/vm-stop.bash vm-invent the wheel completely"stop.bash] ]<br><br>'''Scripting Skills:'''<blockquote><ul><li>'''if''' statement</li><li>'''for''' loop</li><li>'''Command Substitution'''</li><li>Advanced '''awk'''</li><li>'''positional parameters'''</li><li>'''sed'''</li><li>'''IO Stream vs Graphical Interaction''' (eg. zenity)</li><li>'''virsh''' command</li></ul></blockquote><br><br>Example '''Practical Consideration for scripting in lab2:<br><blockquote>''' Students use '''wget''' to download existing shell script and run it to see what happens. Students are '''encouraged to view contents of Shell more advanced shell script Demo 1: [ (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.<br><br></blockquote>|[[Image:lab2 Shell Script Demo -script-1.png|thumb|left|vmstart.bash175px|When executed as '''root''' or using '''sudo''' command, provides VM status and opportunity to '''start''' VMs]] ]<br>Example of Shell script Demo 2: [ |[[Image:lab2 Shell Script Demo -script-2.png|thumb|left|175px|vmstop.bashWhen executed as '''root''' or using '''sudo''' command, provides VM status and opportunity to stop '''running''' VMs]] ]<br><br>|}  
== 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.<br><br>[[Image:lab3_monitor_1.png|thumb|right|375px|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):''' [ [[https://scs.senecac.on.ca/~murray.saul/monitor-disk-space.bash monitor-disk-space.bash]] ]<br>(Courtesy: http://bash.cyberciti.biz/monitoring/shell-script-monitor-unix-linux-diskspace/)<br><br>'''Scripting Skills:'''<blockquote><ul><li>'''df'''</li><li>'''grep'''</li><li>'''awk'''</li><li>'''command substitution'''</li><li>'''mail'''</li><li>'''cut'''</li><li>'''do-while''' loop</li><li>'''Cron Tables'''(crontab)</li></ul></blockquote><br>
 
::'''Practical Consideration for scripting in lab3:<br><br>''' 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)<br><br>
 
{|cellpadding="15" width="100%"
|-
|'''Script #2 User LVM Management:''' [ ] ??<br><br>'''Scripting Skills:'''<blockquote><ul><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab4:'''<br><blockquote>
'''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)<br><br>
|[[Image:lab3_2.png|thumb|left|375px|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:==
{|cellpadding="15" width="100%"|-|'''Script #1 User Account Management:''' [ [http://cs.senecac.on.ca/~murray.saul/create-users.bash create-users.bash] ]<br>Sample of new employee database: [ [https://scs.senecac.on.ca/~murray.saul/new-users.txt /root/new-users.txt] ]<br><br>'''Scripting Skills:'''<blockquote><ul><li>'''if''' statement</li><li>'''Testing for existence of regular file'''</li><li>'''Arrays'''</li><li>'''Math''' Expressions</li><li>'''exit''' command</li><li>USER '''Environment Variable'''</li><li>'''redirection''' (both &gt; and &gt;&gt;)</li><li>'''useradd'''</li><li>'''for''' loop</li><li>'''command substitution'''</li><li>'''mail'''</li><li>'''awk''' command ('''positional parameters''')</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab4:'''<br><blockquote>'''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)<br><br>|[[Image:lab4_1.png|thumb|left|375px|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. {|cellpadding="15" width="100%"|-|<blockquote>'''Script #1: Service Status (start and stop services - Text based):'''<br>[ [http://cs.senecac.on.ca/~murray.saul/service-start-text.bash service-start-text.bash] ] [ [http://cs.senecac.on.ca/~murray.saul/service-stop-text.bash service-stop-text.bash] ]<br><br>'''Scripting Skills:'''<blockquote><ul><li>'''if''' statement</li><li>'''Here document''' (redirection)</li><li>'''service''' utility</li><li>grep</li><li>'''exit''' command</li><li>USER '''Environment Variable'''</li><li>'''redirection''' (both &gt; and &gt;&gt;)</li><li>testing by true-false return of pipeline command</li><li>'''for''' loop</li><li>'''command substitution'''</li><li>'''awk''' command</li><li>'''positional parameters'''</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab2:<br><blockquote>''' 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.<br><br></blockquote>|[[Image:service_start_1.png|thumb|left|175px|When executed as '''root''' or using '''sudo''' command, provides Service status and opportunity to start '''non-running''' services]]|[[Image:service_stop_1.png|thumb|left|175px|When executed as '''root''' or using '''sudo''' command, provides Service status and opportunity to stop '''running''' services]]|} {|cellpadding="15" width="100%"|-|<blockquote>'''Script #2: Service Status (start and stop services: Graphical):'''<br>[ ] [ ] (to be completed)<br><br>'''Scripting Skills:'''<blockquote><ul><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab2:<br><blockquote>''' 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.<br><br></blockquote>|[[Image:service_start_graphical_1.png|thumb|left|175px|When executed as '''root''' or using '''sudo''' command, provides Service status and opportunity to start '''non-running''' services]]|[[Image:service_stop_graphical_1.png|thumb|left|175px|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:==
== Assignment 1:==
::Perhaps add *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.<br><br>::*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:==
:* [http://zenit.senecac.on.ca/wiki/index.php/OPS OPS Stream Discussion]\
:* [[OPS235 - Curriculum Discussion |OPS235 - Curriculum Discussion]]
:* [[CNS / CTY Curriculum Development]]
[[Category:Curriculum,OPS Stream,OPS235]]
13,420
edits