mirror of
https://github.com/wickedyoda/public-setupfiles.git
synced 2026-11-16 13:31:56 -06:00
Merge pull request #23 from wickedyoda/codex/fix-errors-in-kali-updates.sh
Enhance Kali updates script with Purple options
This commit is contained in:
1 file changed
+95
-61
@@ -1,20 +1,21 @@
|
||||
# ...existing code...
|
||||
sudo apt update
|
||||
sudo apt upgrade -y
|
||||
sudo apt full-upgrade -y
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Prompt for Kali tool categories to install (supports numbers, comma-separated, or 'all'/'a')
|
||||
echo
|
||||
echo "Select Kali tool categories to install (comma-separated, numbers, or 'all'):"
|
||||
echo " 1) Identify -> kali-tools-identify"
|
||||
echo " 2) Protect -> kali-tools-protect"
|
||||
echo " 3) Detect -> kali-tools-detect"
|
||||
echo " 4) Respond -> kali-tools-respond"
|
||||
echo " 5) Recover -> kali-tools-recover"
|
||||
echo " Enter numbers (e.g. 1,3), 'all' or 'a' to install all. Leave empty to skip."
|
||||
read -p "Selection: " selection
|
||||
SUDO=""
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
SUDO="sudo "
|
||||
else
|
||||
echo "This script must be run as root or have sudo installed."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
declare -A map=(
|
||||
${SUDO}apt update
|
||||
${SUDO}apt upgrade -y
|
||||
${SUDO}apt full-upgrade -y
|
||||
|
||||
declare -A TOOL_MAP=(
|
||||
[1]=kali-tools-identify
|
||||
[2]=kali-tools-protect
|
||||
[3]=kali-tools-detect
|
||||
@@ -22,55 +23,88 @@ declare -A map=(
|
||||
[5]=kali-tools-recover
|
||||
)
|
||||
|
||||
pkgs=()
|
||||
if [[ -n "$selection" ]]; then
|
||||
selection="${selection,,}" # lowercase
|
||||
# direct all options
|
||||
if [[ "$selection" == "all" || "$selection" == "a" ]]; then
|
||||
pkgs=(kali-tools-identify kali-tools-protect kali-tools-detect kali-tools-respond kali-tools-recover)
|
||||
else
|
||||
IFS=',' read -ra choices <<< "$selection"
|
||||
for c in "${choices[@]}"; do
|
||||
# trim whitespace
|
||||
c="${c//[[:space:]]/}"
|
||||
if [[ -z "$c" ]]; then
|
||||
continue
|
||||
fi
|
||||
if [[ "$c" == "all" || "$c" == "a" ]]; then
|
||||
pkgs=(kali-tools-identify kali-tools-protect kali-tools-detect kali-tools-respond kali-tools-recover)
|
||||
break
|
||||
fi
|
||||
if [[ -n "${map[$c]}" ]]; then
|
||||
pkgs+=("${map[$c]}")
|
||||
else
|
||||
echo "Warning: invalid choice '$c' ignored."
|
||||
fi
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo "No tools selected. Skipping Kali tool installation."
|
||||
fi
|
||||
|
||||
# deduplicate packages and install if any
|
||||
if [[ ${#pkgs[@]} -gt 0 ]]; then
|
||||
declare -A seen=()
|
||||
final_pkgs=()
|
||||
for p in "${pkgs[@]}"; do
|
||||
if [[ -z "${seen[$p]}" ]]; then
|
||||
final_pkgs+=("$p")
|
||||
seen[$p]=1
|
||||
add_packages() {
|
||||
local pkg
|
||||
for pkg in "$@"; do
|
||||
if [[ -z "${PACKAGE_SEEN[$pkg]:-}" ]]; then
|
||||
INSTALL_PKGS+=("$pkg")
|
||||
PACKAGE_SEEN[$pkg]=1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
echo "Installing: ${final_pkgs[*]}"
|
||||
sudo apt update
|
||||
sudo apt install -y "${final_pkgs[@]}"
|
||||
echo "Selected Kali tool packages installed."
|
||||
INSTALL_PKGS=()
|
||||
declare -A PACKAGE_SEEN=()
|
||||
|
||||
echo
|
||||
echo "Select Kali tool categories to install (comma-separated numbers, or 'all'):"
|
||||
echo " 1) Identify -> kali-tools-identify"
|
||||
echo " 2) Protect -> kali-tools-protect"
|
||||
echo " 3) Detect -> kali-tools-detect"
|
||||
echo " 4) Respond -> kali-tools-respond"
|
||||
echo " 5) Recover -> kali-tools-recover"
|
||||
echo " Enter numbers (e.g. 1,3), 'all' or 'a' to install all. Leave empty to skip."
|
||||
read -r -p "Selection: " selection
|
||||
|
||||
selection="${selection,,}"
|
||||
selection="${selection//[[:space:]]/}"
|
||||
|
||||
if [[ -z "$selection" ]]; then
|
||||
echo "No tools selected. Skipping Kali tool installation."
|
||||
elif [[ "$selection" == "all" || "$selection" == "a" ]]; then
|
||||
add_packages "${TOOL_MAP[@]}"
|
||||
else
|
||||
IFS=',' read -ra choices <<< "$selection"
|
||||
for c in "${choices[@]}"; do
|
||||
if [[ "$c" == "all" || "$c" == "a" ]]; then
|
||||
add_packages "${TOOL_MAP[@]}"
|
||||
break
|
||||
elif [[ -n "${TOOL_MAP[$c]:-}" ]]; then
|
||||
add_packages "${TOOL_MAP[$c]}"
|
||||
else
|
||||
echo "Warning: invalid choice '$c' ignored."
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# ...existing code...
|
||||
sudo apt autoremove -y
|
||||
sudo apt clean -y
|
||||
sudo apt purge -y
|
||||
echo
|
||||
echo "Kali Purple installation options:"
|
||||
echo " 1) Kali Purple tools (identify/protect/detect/respond/recover)"
|
||||
echo " 2) Kali Purple experience (kali-themes-purple, kali-menu, kali-wallpapers-legacy)"
|
||||
echo " 3) All Kali Purple options"
|
||||
echo " 4) Continue without Kali Purple installation"
|
||||
read -r -p "Selection [4]: " purple_selection
|
||||
|
||||
purple_selection="${purple_selection,,}"
|
||||
purple_selection="${purple_selection//[[:space:]]/}"
|
||||
|
||||
case "$purple_selection" in
|
||||
1)
|
||||
add_packages ${TOOL_MAP[@]}
|
||||
;;
|
||||
2)
|
||||
add_packages kali-themes-purple kali-menu kali-wallpapers-legacy
|
||||
;;
|
||||
3|all|a)
|
||||
add_packages ${TOOL_MAP[@]} kali-themes-purple kali-menu kali-wallpapers-legacy
|
||||
;;
|
||||
""|4|skip)
|
||||
echo "Skipping Kali Purple installation."
|
||||
;;
|
||||
*)
|
||||
echo "Unrecognized choice. Skipping Kali Purple installation."
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ ${#INSTALL_PKGS[@]} -gt 0 ]]; then
|
||||
echo "Installing selected packages: ${INSTALL_PKGS[*]}"
|
||||
${SUDO}apt install -y "${INSTALL_PKGS[@]}"
|
||||
echo "Selected packages installed."
|
||||
else
|
||||
echo "No optional Kali packages selected for installation."
|
||||
fi
|
||||
|
||||
${SUDO}apt autoremove -y
|
||||
${SUDO}apt clean -y
|
||||
|
||||
echo "System update and cleanup complete!"
|
||||
# ...existing code...
|
||||
Reference in new issue
Block a user