From d12fcb7d5abf56053e7bb73eb95d64e3de0ccf18 Mon Sep 17 00:00:00 2001 From: "calvin.house" Date: Mon, 30 Mar 2026 19:16:01 +0000 Subject: [PATCH] light changes to wireshark script --- bash/wireshark.sh | 68 +++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/bash/wireshark.sh b/bash/wireshark.sh index 8acab6f..ca962b1 100644 --- a/bash/wireshark.sh +++ b/bash/wireshark.sh @@ -1,48 +1,40 @@ #!/bin/bash #set -xv -clear -echo "This script will install Wireshark using the ID" -echo "found in the /etc/os-release file. Currently, Fedora," -echo "Ubuntu, Debian, and Arch are supported with this script." -echo "Feel free to edit it as needed." -DISTRO_ID=$(grep -i ^ID /etc/os-release | cut -c 4- | tr -d \") -read -p "Enter username: " USE +if [[ $EUID -ne 0 ]]; then + echo "This script needs to run as root." + exit 1 +fi -case "$DISTRO_ID" in - [uU]buntu|[dD]ebian) - - echo "Will now install and configure Wireshark" - echo "Press [Enter] to continue..." - apt install -y wireshark && gpasswd -a $USE wireshark +DISTRO_ID=$(grep -i '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"') + +echo "Detected OS: $DISTRO_ID" +echo "Installing Wireshark for the user $(logname)..." +case "$DISTRO_ID" in + ubuntu|debian|raspbian) + echo "wireshark-common wireshark-common/install-setuid boolean true" | debconf-set-selections + apt update && apt install -y debconf-utils wireshark + usermod -aG wireshark $(logname) chgrp wireshark /usr/bin/dumpcap - chmod 755 /usr/bin/dumpcap + chmod 750 /usr/bin/dumpcap setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap - echo "Rebooting to allow user to see network interfaces" + ;; - ;; + arch|manjaro) + pacman -Sy --noconfirm --needed wireshark-qt wireshark-cli + usermod -aG wireshark $(logname) + ;; - [aA]rch) - - echo "Will now install and configure Wireshark" - echo "Press [Enter] to continue..." - pacman -S wireshark-qt wireshark-cli && gpasswd -a $USE wireshark - echo "Rebooting to allow user to see network interfaces" - - ;; - - [fF]edora|[cC]entos|[rR]hel) - echo "Will now install and configure Wireshark" - echo "Press [Enter] to continue..." - dnf install wireshark -y && gpasswd -a $USE wireshark - echo "Rebooting to allow user to see network interfaces" - - ;; - *) - - echo "Unknown OS.." - exit 0 - - ;; + fedora|centos|rhel|rocky|almalinux) + dnf install wireshark -y + usermod -aG wireshark $(logname) + ;; + *) + echo "Error: ${DISTRO_ID} is not currently supported..." + exit 1 + ;; esac + +echo "Installation complete! Log out then log back in to ensure all interfaces to be available to Wireshark" +echo "If the interfaces are not available, then a reboot maybe required."