Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions DebugMenu/README.md
Original file line number Diff line number Diff line change
@@ -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 <usr>@<ip> diagnostics.sh`
3) If transfering a file use SCP. i.e. `scp localFile <usr>@<ip> /tmp/`
67 changes: 67 additions & 0 deletions DebugMenu/diagnostics.sh
Original file line number Diff line number Diff line change
@@ -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 <user>@<ip>:/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