-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.