diff --git a/README.md b/README.md index f06dca3..310b0fe 100644 --- a/README.md +++ b/README.md @@ -100,5 +100,8 @@ I tested the mininet emulation software to reproduce a real situation of a clust Using Docker as a sandbox offers a powerful solution for isolating and testing applications and services in a controlled environment. Docker containers provide a lightweight, reproducible way to create sandboxes for development, testing, or experimentation. By encapsulating an application and its dependencies within a container, developers can ensure consistency across different environments, making it easier to troubleshoot issues and prevent conflicts. Docker's sandboxing capabilities also enhance security by isolating processes and resources, reducing the risk of unintended interactions or vulnerabilities. Whether for development, QA, or exploring new software, Docker's sandboxing approach simplifies the management of isolated environments, fostering agility and reliability in software development workflows. ``` docker run -it --rm ubuntu /bin/sh -docker system prune --all --volumes --force #To clean after use +docker system prune --all --volumes --force #Remove unused data + # --all remove all unused images + # --volumes prune anonymous volumes + # --force does not prompt for confirmation ``` diff --git a/setupDocker.sh b/setupDocker.sh new file mode 100755 index 0000000..c0218fa --- /dev/null +++ b/setupDocker.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +#Colors +RED="\e[1;31m" +GREEN="\e[1;32m" +YELLOW="\e[1;33m" +BLUE="\e[1;34m" +DEFAULT="\e[0m" + +# Check if the script is run with root privileges +if [ "$EUID" -ne 0 ]; then + echo "Please run this script as root or using sudo." + exit 1 +fi + +echo -e "${YELLOW}Do you want to Update the system?: [Y/n]${DEFAULT}" +read -r confirmation +if [[ ! "$confirmation" =~ ^[Nn]|[Nn][Oo]$ ]]; then + echo "Updating..." + sudo apt-get update -y + sudo apt-get upgrade -y +else + echo "You choose no" +fi + +echo -e "${YELLOW}Do you want to Install Docker?: [Y/n]${DEFAULT}" +read -r confirmation +if [[ ! "$confirmation" =~ ^[Nn]|[Nn][Oo]$ ]]; then + echo "Installing..." + if [ $(dpkg -l | grep -c "docker-c" ) -eq 0 ]; then + sudo apt-get install -y \ + ca-certificates \ + curl \ + gnupg \ + lsb-release \ + make + + echo -e "${BLUE}Adding Docker's official GPG key${DEFAULT}" + sudo mkdir -m 0755 -p /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg + + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo $VERSION_CODENAME) stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + + sudo apt-get update -y + sudo apt-get install -y \ + docker-ce \ + docker-ce-cli \ + containerd.io \ + docker-compose-plugin \ + docker-compose + + echo -e "${BLUE}Test Docker installation${DEFAULT}" + sudo docker run hello-world + if [ $? -ne 0 ]; then + echo -e "${RED} \"Something went wrong with Docker Installation\"${DEFAULT}" + else + echo -e "${GREEN} \"All Docker dependencies Installed\"${DEFAULT}" + fi + + echo -e "${BLUE}Make Docker run as root${DEFAULT}" + sudo groupadd docker + sudo usermod -aG docker $USER + newgrp docker + + echo -e "${BLUE}Test Docker installation without sudo${DEFAULT}" + docker run hello-world + if [ $? -ne 0 ]; then + echo -e "${RED} \"Something went wrong with Docker run as root\"${DEFAULT}" + else + echo -e "${GREEN} \"Now docker runs as root\"${DEFAULT}" + fi + else + echo -e "${GREEN} \"Some packets like 'docker-c*' installed, seems Docker is already Installed\"${DEFAULT}" + fi +else + echo "You choose no" +fi + +echo -e "${YELLOW}Do you want to Remove Docker?: [y/N]${DEFAULT}" +read -r confirmation +if [[ "$confirmation" =~ ^[Yy]|[Yy][Ee][Ss]$ ]]; then + echo -e "${RED}Are you sure to Remove Docker?: [y/N]${DEFAULT}" + read -r confirmationagain + if [[ "$confirmationagain" =~ ^[Yy]|[Yy][Ee][Ss]$ ]]; then + echo "Removing..." + echo "TODO" +# Complete Clean-up(da controllare se va bene) e da aggiungere il resto +# echo -e "${BLUE}Doing a complete Cleanup${DEFAULT}" +# sudo apt remove docker-desktop +# rm -r $HOME/.docker/desktop +# sudo rm /usr/local/bin/com.docker.cli +# sudo apt purge docker-desktop + else + echo "Not Removing" + fi +else + echo "Not Removing" +fi + +exit 0 diff --git a/setupVirtualBox.sh b/setupVirtualBox.sh new file mode 100755 index 0000000..9173149 --- /dev/null +++ b/setupVirtualBox.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +#Colors +RED="\e[1;31m" +GREEN="\e[1;32m" +YELLOW="\e[1;33m" +BLUE="\e[1;34m" +DEFAULT="\e[0m" + +# Check if the script is run with root privileges +if [ "$EUID" -ne 0 ]; then + echo "Please run this script as root or using sudo." + exit 1 +fi + +echo -e "${YELLOW}Do you want to Update the system?: [Y/n]${DEFAULT}" +read -r confirmation +if [[ ! "$confirmation" =~ ^[Nn]|[Nn][Oo]$ ]]; then + echo "Updating..." + sudo apt-get update -y + sudo apt-get upgrade -y +else + echo "You choose no" +fi + +echo -e "${YELLOW}Do you want to Install VirtualBox-7.0?: [Y/n]${DEFAULT}" +read -r confirmation +if [[ ! "$confirmation" =~ ^[Nn]|[Nn][Oo]$ ]]; then + echo "Installing..." + if [ $(dpkg -l | grep -c "virtualbox" ) -eq 0 ]; then + sudo apt-get install -y \ + ca-certificates \ + wget \ + gnupg \ + lsb-release \ + + echo -e "${BLUE}Adding Docker's official GPG key${DEFAULT}" + wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --yes --dearmor -o /usr/share/keyrings/oracle-virtualbox-2016.gpg + + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian \ + $(. /etc/os-release && echo $VERSION_CODENAME) contrib" | \ + sudo tee /etc/apt/sources.list.d/virtualbox.list > /dev/null + + sudo apt-get update -y + sudo apt-get install -y \ + linux-headers-$(uname -r) \ + dkms \ + virtualbox-7.0 + + echo -e "${BLUE}Make VirtualBox run with Extension Pack${DEFAULT}" + wget https://download.virtualbox.org/virtualbox/7.0.14/Oracle_VM_VirtualBox_Extension_Pack-7.0.14.vbox-extpack + sudo vboxmanage extpack install --replace --accept-license=33d7284dc4a0ece381196fda3cfe2ed0e1e8e7ed7f27b9a9ebc4ee22e24bd23c Oracle_VM_VirtualBox_Extension_Pack-7.0.14.vbox-extpack + rm -f Oracle_VM_VirtualBox_Extension_Pack-7.0.14.vbox-extpack + + echo -e "${BLUE}Make VirtualBox run with admin privileges${DEFAULT}" + sudo groupadd vboxusers + sudo usermod -aG vboxusers $USER + newgrp vboxusers + else + echo -e "${GREEN} \"Some packet like 'virtualbox' installed, seems VirtualBox is already Installed\"${DEFAULT}" + fi +else + echo "You choose no" +fi + +echo -e "${YELLOW}Do you want Vagrant too?: [y/N]${DEFAULT}" +read -r confirmation +if [[ "$confirmation" =~ ^[Yy]|[Yy][Ee][Ss]$ ]]; then + echo -e "${BLUE}Adding Vagrant's official GPG key${DEFAULT}" + wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg + + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com \ + $(. /etc/os-release && echo $VERSION_CODENAME) main" | \ + sudo tee /etc/apt/sources.list.d/hashicorp.list + + sudo apt-get update -y + sudo apt-get install -y \ + vagrant +else + echo "You choose no" +fi +echo -e "${YELLOW}Do you want to Remove VirtualBox?: [y/N]${DEFAULT}" +read -r confirmation +if [[ "$confirmation" =~ ^[Yy]|[Yy][Ee][Ss]$ ]]; then + echo -e "${RED}Are you sure to Remove VirtualBox?: [y/N]${DEFAULT}" + read -r confirmationagain + if [[ "$confirmationagain" =~ ^[Yy]|[Yy][Ee][Ss]$ ]]; then + echo "Removing..." + echo "TODO" + # TODO + else + echo "Not Removing" + fi +else + echo "Not Removing" +fi + +exit 0 diff --git a/setupWireshark.sh b/setupWireshark.sh new file mode 100755 index 0000000..9b3d667 --- /dev/null +++ b/setupWireshark.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +#Colors +RED="\e[1;31m" +GREEN="\e[1;32m" +YELLOW="\e[1;33m" +BLUE="\e[1;34m" +DEFAULT="\e[0m" + +# Check if the script is run with root privileges +if [ "$EUID" -ne 0 ]; then + echo "Please run this script as root or using sudo." + exit 1 +fi + +echo -e "${YELLOW}Do you want to Update the system?: [Y/n]${DEFAULT}" +read -r confirmation +if [[ ! "$confirmation" =~ ^[Nn]|[Nn][Oo]$ ]]; then + echo "Updating..." + sudo apt-get update -y + sudo apt-get upgrade -y +else + echo "You choose no" +fi + +echo -e "${YELLOW}Do you want to Install Wireshark?: [Y/n]${DEFAULT}" +read -r confirmation +if [[ ! "$confirmation" =~ ^[Nn]|[Nn][Oo]$ ]]; then + echo "Installing..." + + if [ $(dpkg -l | grep -c "wireshark " ) -eq 0 ]; then + echo -e "${BLUE}Adding Wireshark's PPA stable${DEFAULT}" + sudo add-apt-repository -y ppa:wireshark-dev/stable + sudo apt-get update -y + + sudo apt-get install -y \ + wireshark \ + tshark + + echo -e "${BLUE}Adding User to wireshark group to run as root if in wireshark-common said ${DEFAULT}" + sudo groupadd wireshark + sudo usermod -aG wireshark $USER + newgrp wireshark + + else + echo -e "${GREEN} \"Some packet like 'wireshark ' installed, seems Wireshark is already Installed\"${DEFAULT}" + fi +else + echo "You choose no" +fi + +echo -e "${YELLOW}Do you want to Remove Wireshark?: [y/N]${DEFAULT}" +read -r confirmation +if [[ "$confirmation" =~ ^[Yy]|[Yy][Ee][Ss]$ ]]; then + echo -e "${RED}Are you sure to Remove Wireshark?: [y/N]${DEFAULT}" + read -r confirmationagain + if [[ "$confirmationagain" =~ ^[Yy]|[Yy][Ee][Ss]$ ]]; then + echo "Removing..." + echo "TODO" + # TODO + else + echo "Not Removing" + fi +else + echo "Not Removing" +fi + +exit 0