coursera
Hands-on Labs:
- Getting Started with the Linux Terminal
- Installing and working with text editors
Hands-on Labs:
- Informational Commands
- Navigating and Managing Files and Directories
- Access Control Commands
- Wrangling Text Files at the Command Line
- Working with Networking Commands
- Archiving and Compressing Files
Hands-on Labs:
- Getting Started with Shell Scripting
- Advanced Bash Scripting
- Scheduling Jobs using Crontab
Basic building blocks of programming are:
- Sequence: statements run in order, one after another (do x y z done)
- Repetition: blocks of statements can be iterated, or looped (while, for, until)
- Branching: logical flow controls through conditional statement evaluation (if, then, else)
Hands-on Labs:
- Historical Weather Forcast Comparison to Actuals
Hands-on Labs:
- Peer-Graded Final Project
- document linux commands to do something specific
- automation
- runs on all linux
- technical debt
- not ideal for applications
- some difficult syntax
I prefer Python for most scripting needs!
#!/usr/bin/env bash
# Shutdown and restart all nodes in OCP cluster
nodes=$(oc get nodes -o jsonpath='{.items[*].metadata.name}')
for node in ${nodes[@]}; do
echo "==== Restart $node ===="
ssh core@$node sudo shutdown -r now
done
#!/usr/bin/env bash
# Check the hostname and date on multiple machines
servers=( "10.0.0.1"
"10.0.0.2"
"10.0.0.3" )
for server in ${servers[@]}; do
ssh $server "hostname; date"
done
#!/usr/bin/env bash
# Get a list of
for proj in $(openstack --os-cloud cic-admin project list -f json | jq -r .[].ID); do
echo "Project: $proj"
openstack --os-cloud cic-admin --os-project-id $proj volume list -f csv
done
#!/usr/bin/env bash
DEL_ARTIFACTS=No
while true; do
read -p "Do you want to delete the installation artifacts (deployment directory)? (yes/no) " yn
case $yn in
[Yy]* ) DEL_ARTIFACTS=Yes; break;;
[Nn]* ) DEL_ARTIFACTS=No; break;;
* ) echo "Please answer yes or no.";;
esac
done
if [[ $DEL_ARTIFACTS == "Yes" ]]; then
rm -rf deployment
rm services_inventory.yaml
fi
ansible-playbook teardown.yaml
function check_rc {
local func_rc=$?
if [[ $func_rc -ne 0 ]] ; then
echo "ERROR: Exit code was $func_rc, exiting!"
exit
fi
}