Skip to content

Commit

Permalink
update more scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kadeyoun committed Dec 27, 2024
1 parent b4d7461 commit 1f6f49b
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
44 changes: 44 additions & 0 deletions find_gsd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

echo "[INFO] Starting gsd cleanup..."

# Define directories to search
SEARCH_DIRS=(
"/usr/local/src"
"/tmp"
"/var/tmp"
"/dev/shm"
"/home"
"/root"
)

# Define patterns to match
PATTERNS=(
"*.gsd"
"gsd"
)

# Find and remove matching files
for dir in "${SEARCH_DIRS[@]}"; do
echo "[INFO] Searching in $dir..."
for pattern in "${PATTERNS[@]}"; do
find "$dir" -type f -name "$pattern" 2>/dev/null | while read -r file; do
echo "[INFO] Removing $file..."
chattr -i "$file" 2>/dev/null # Remove immutable attribute if set
rm -f "$file"
done
done
done

# Check if any gsd files still exist
echo "[INFO] Checking for remaining gsd files..."
remaining_files=$(find "${SEARCH_DIRS[@]}" -type f \( -name "*.gsd" -o -name "gsd" \) 2>/dev/null)

if [ -z "$remaining_files" ]; then
echo "[SUCCESS] All gsd files have been removed."
else
echo "[WARNING] Some gsd files could not be removed:"
echo "$remaining_files"
fi

echo "[INFO] Cleanup complete."
28 changes: 28 additions & 0 deletions optional_rm_authorized_keys.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

echo "[INFO] Starting authorized_keys cleanup..."

# Include system-wide user directories
DIRECTORIES=("/home" "/root")

# Iterate through all directories and remove authorized_keys
for dir in "${DIRECTORIES[@]}"; do
echo "[INFO] Searching in $dir..."
for keyfile in $(find "$dir" -type f -name "authorized_keys" 2>/dev/null); do
echo "[INFO] Removing $keyfile..."
rm -f "$keyfile"
done
done

# Check if any authorized_keys files still exist
echo "[INFO] Checking for remaining authorized_keys files..."
remaining_keys=$(find "${DIRECTORIES[@]}" -type f -name "authorized_keys" 2>/dev/null)

if [ -z "$remaining_keys" ]; then
echo "[SUCCESS] All authorized_keys files have been removed."
else
echo "[WARNING] Some authorized_keys files could not be removed:"
echo "$remaining_keys"
fi

echo "[INFO] Cleanup complete."
File renamed without changes.

0 comments on commit 1f6f49b

Please sign in to comment.