Skip to content

Commit

Permalink
fix(chore): add missing sed_alternative command
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmandMeppa committed Dec 18, 2024
1 parent 50cc682 commit 915d0b9
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions scripts/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,33 @@ success_message() {
log "${GREEN}${BOLD}[SUCCESS]${NORMAL}" "$*"
}

# Function to ensure the script runs with appropriate privileges
# Check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Ensure root privileges, either directly or through sudo
maybe_sudo() {
if [ "$EUID" -ne 0 ]; then
if command -v sudo &>/dev/null; then
if [ "$(id -u)" -ne 0 ]; then
if command_exists sudo; then
sudo "$@"
else
error_message "Please run the script as root or install sudo."
error_message "This script requires root privileges. Please run with sudo or as root."
exit 1
fi
else
"$@"
fi
}

sed_alternative() {
if command_exists gsed; then
gsed "$@"
else
sed "$@"
fi
}

# Function to remove directories and files
remove_snort_dirs_files() {
local dirs=("$@")
Expand Down

0 comments on commit 915d0b9

Please sign in to comment.