#!/bin/bash

clear
echo "------------------------------------------------"
echo "|---- Task Managers (taskmgr for Linux) -------|"
echo "------------------------------------------------"
echo "| 1. CTOP           | Docker Task Manager      |"
echo "| 2. HTOP           | Linux Task Manager       |"
echo "| 3. BTOP           | Linux Task Manager       |"
echo "| 4. ATOP           | Linux Task Manager       |"
echo "| 5. TOP            | POSIX/UNIX Task Manager  |"
echo "| Q. QUIT / Ctrl+C  | Quitter ce menu          |"
echo "------------------------------------------------"
echo -n " Votre choix [1..5/Q]"
read ask
if [[ $ask = [2] ]]; then
    if command -v htop &> /dev/null
    then
        htop
    else
        sudo apt-get install htop -y
        htop
    fi
fi

if [[ $ask = [3] ]]; then
    if command -v btop &> /dev/null
    then
        btop
    else
        sudo apt-get install btop -y
        btop
    fi
fi

if [[ $ask = [4] ]]; then
    if command -v atop &> /dev/null
    then
        atop
    else
        sudo apt-get install atop -y
        atop
    fi
fi

if [[ $ask = [1] ]]; then
    if command -v ctop &> /dev/null
    then
        ctop
    else
        sudo wget https://github.com/bcicen/ctop/releases/download/v0.7.7/ctop-0.7.7-linux-amd64 -O /bin/ctop
        sudo chmod +x /bin/ctop
        ctop
    fi
fi

if [[ $ask = [5] ]]; then
    if command -v top &> /dev/null
    then
        top
    else
        sudo apt-get install top -y
        top
    fi
fi
exit