Skip to content

Instantly share code, notes, and snippets.

@frace
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save frace/9099536 to your computer and use it in GitHub Desktop.

Select an option

Save frace/9099536 to your computer and use it in GitHub Desktop.
Accidentally executed `busybox --install` on a Gentoo box?
#!/usr/bin/env bash
paths=(
"/bin"
"/sbin"
)
backup="/root/bbbackup"
if [[ ! -d "$backup" ]]; then
mkdir -p "$backup"
fi
for path in ${paths[@]}; do
for file in ${path}/*; do
if [[ -h "$file" ]]; then
printf "%s\n\n" "Skipping ${file}. File is symlink"
else
qfile -o "$file" &>/dev/null
qfile_exit=$?
fi
if (( $qfile_exit == 1 )); then
origin="$( "$file" --help 2>&1 | head -n1 | awk '{print $1}' )"
if [[ "$origin" == "BusyBox" ]]; then
printf "%s\n" "${file} owned by ${origin}"
# Ask me to remove the bb binary
while true; do
read -p ">> Do you want to move ${file} to ${backup}? [ Yes / No ]: " SELECTION
case "$SELECTION" in
[yY]|[Yy][Ee][Ss] )
mv "$file" "$backup"
printf "\n%s\n\n" "${file} moved to ${backup}."
break
;;
[nN]|[Nn][Oo] )
printf "\n%s\n\n" "Didn't move ${file}."
break
;;
* )
printf "\n%s\n\n" "Wrong answer Earthling!"
;;
esac
done
fi
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment