#!/bin/bash
show_menu() {
    echo "=========Select A Number=========="
    echo "1. User and OS Information"
    echo "2. Home directory file list"
    echo "3. Create file with specified permissions"
    echo "4. Ping resource (3 packets)"
    echo "5. Exit"
    echo "=================================="
}

sysinfo() {
    echo "Current user: $(whoami)"
    echo "Home directory: $HOME"
    echo "UID: $(id -u)"
    echo "GID: $(id -g)"
    echo ""
    echo "OS Information:"
    if [ -f /etc/os-release ]; then
        . /etc/os-release
        echo "OS Name: $NAME"
        echo "Version: $VERSION"
    else
        echo "OS: $(uname -s)"
        echo "Kernel version: $(uname -r)"
    fi
    echo "Architecture: $(uname -m)"
}

lshome() {
    echo "Directory: $HOME"
    ls -la "$HOME"
}

create_file() {
    read -p "Enter full path to file: " file_path
    read -p "Enter permissions (e.g., 755): " permissions
    
    mkdir -p "$(dirname "$file_path")"
    touch "$file_path"
    chmod "$permissions" "$file_path"
    ls -l "$file_path"
}

ping_resource() {
    read -p "Enter address to ping: " address
    ping -c 3 "$address"
}

while true; do
    show_menu
    read -p "Select menu item (1-5): " choice
    
    case $choice in
        1) sysinfo ;;
        2) lshome ;;
        3) create_file ;;
        4) ping_resource ;;
        5) exit 0 ;;
        *) echo "Invalid choice." ;;
    esac
done