diff --git a/DebugMenu/README.md b/DebugMenu/README.md new file mode 100644 index 0000000..e31f567 --- /dev/null +++ b/DebugMenu/README.md @@ -0,0 +1,7 @@ +# Example Diagnostics Script + +This is an example diagnostics script. + +1) Start up a SSH server. i.e. `sudo wolfsshd -f sshd_config.txt` +2) Use an SSH client to connect and run the script. i.e. `ssh @ diagnostics.sh` +3) If transfering a file use SCP. i.e. `scp localFile @ /tmp/` diff --git a/DebugMenu/diagnostics.sh b/DebugMenu/diagnostics.sh new file mode 100755 index 0000000..266d54c --- /dev/null +++ b/DebugMenu/diagnostics.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +printf "===============================\n\r" +printf " Example SSH Diagnostics\n\r" +printf "===============================\n\r" +stty -a + +# Menu display +show_menu() { + printf "Select an option:\n\r" + printf "To transfer a file run scp localfile @:/tmp\n\r" + printf "1. Print a file to stdout\n\r" + printf "2. Run a simple program\n\r" + printf "3. Enter an interactive Bash shell\n\r" + printf "4. Exit\n\r" + printf "Enter your choice [1-4]: \n\r" +} + + +print_file() { + echo -n "Enter the file to print out: " + read file + if [[ -f "$file" ]]; then + echo "Contents of $file:" + cat "$file" + else + echo "File not found!" + fi +} + +# Function to run a simple program +run_program() { + printf "Running an example simple diagnostic program...\n\r" + printf "System Uptime:\n\r" + uptime + printf "Disk Usage:\n\r" + df -h + printf "Memory Usage:\n\r" + free -h +} + +# Main loop +while true; do + show_menu + read choice + case $choice in + 1) + print_file + ;; + 2) + run_program + ;; + 3) + printf "Entering interactive Bash shell. Type 'exit' to return to the menu.\n\r" + bash + ;; + 4) + printf "Exiting SSH Diagnostics Server. Goodbye!\n\r" + break + ;; + *) + printf "Invalid choice, please try again.\n\r" + ;; + esac +done + +exit 0