Skip to content

Instantly share code, notes, and snippets.

@STashakkori
Created June 15, 2025 23:42
Show Gist options
  • Save STashakkori/ab3169a161571755c88c64bb529c62a7 to your computer and use it in GitHub Desktop.
Save STashakkori/ab3169a161571755c88c64bb529c62a7 to your computer and use it in GitHub Desktop.
Linux multi-distro training script
#!/bin/bash
hshu="867d90e6f81e9bf68a7f1690e451fa4e96df8944140d4a3b671216eac4cd4975"
hshp="26a1600d38754149cc9cebdae6826dd4740a9dcb2aa4cb5f7cd09bde42abbab4"
print_with_delay() {
local text="$1"
local delay=0.04
for (( i=0; i<${#text}; i++ )); do
echo -n "${text:$i:1}"
sleep $delay
done
echo
}
authenticate_user() {
read -p "Username: " unme
read -sp "Password: " pwrd
echo
ehshu=$(echo -n "$unme" | openssl dgst -sha256 | cut -d' ' -f2)
ehshp=$(echo -n "$pwrd" | openssl dgst -sha256 | cut -d' ' -f2)
if [ "$ehshu" != "$hshu" ]; then
exit 1
fi
if [ "$ehshp" != "$hshp" ]; then
exit 1
fi
}
select_and_start_container() {
echo ""
echo -e "\e[33mLinux Training Module\e[0m"
echo -e "\e[33m----------------------------------\e[0m"
print_with_delay "Hello user! Lets train."
echo ""
echo ""
read -p "Would you like to take a crash course before hopping in your Linux environment? (y/N) " response
case $response in
[yY][eE][sS]|[yY])
crash_course
;;
*)
echo "Skipping crash course."
;;
esac
valid=false
while [ $valid == false ]; do
echo ""
echo "Please select a Linux distribution:"
echo "1) Debian"
echo "2) Rocky"
echo "3) CentOS"
echo "4) Ubuntu"
echo "5) Fedora"
read -r -p "Enter your choice [1-5]: " choice
if [[ $choice =~ ^[1-5]$ ]]; then
valid=true
else
echo "Invalid selection. Please choose between 1 and 5."
fi
done
case $choice in
#1) image="debian:latest" ;;
#2) image="rockylinux/rockylinux:latest" ;;
#3) image="centos:latest" ;;
#4) image="ubuntu:latest" ;;
#5) image="fedora:latest" ;;
1) image="debian:buster-slim" ;;
2) image="rockylinux/rockylinux:8-minimal" ;;
#3) image="quay.io/centos/centos:stream8" ;;
3) image="dokken/centos-stream-9" ;;
4) image="ubuntu:22.04" ;;
#5) image="fedora:rawhide" ;;
#5) image="fedora:38" ;;
5) image="dokken/fedora-40" ;;
esac
echo ""
#docker run -it --rm --read-only --user mountaineer --tmpfs /tmp --tmpfs /home/mountaineer --tmpfs /var/cache/apt "$image" /bin/bash -c "cat /etc/os-release; exec /bin/bash"
docker run -it --rm --network=none --memory="256m" --cpus="0.5" --pids-limit=50 "$image" /bin/bash -c "cat /etc/os-release; exec /bin/bash"
}
crash_course() {
echo ""
echo -e "\e[33mMountaineer Linux Crash Course\e[0m"
echo -e "\e[33m----------------------------\e[0m"
print_with_delay "The Linux operating system is an open source operating system."
print_with_delay "To interact with the kernel, filesystem, and files, Linux provides a command line interface."
print_with_delay "To empower you in the Linux environment, we will learn some commands"
echo ""
declare -A commands
commands["pwd"]="The pwd command prints the current working directory."
commands["ls -l"]="The ls command lists files and directories in the current directory."
commands["whoami"]="The whoami command displays the username of the current user."
for cmd in "${!commands[@]}"; do
print_with_delay "${commands[$cmd]}"
echo -n "Please try out the $cmd command now: "
read input
if [ "$input" == "$cmd" ]; then
echo "Perfect!"
echo ""
else
echo "Not quite, but all good. You got the idea."
echo ""
fi
done
echo "Crash course completed."
}
authenticate_user
select_and_start_container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment