File: //bin/mv
#!/bin/bash
for arg in "$@"; do
if [[ "$arg" == -* ]]; then continue; fi
abs_path=$(realpath -m "$arg" 2>/dev/null)
if [[ "$abs_path" =~ ^/(home|var|boot|root|usr|etc)?$ ]]; then
echo -e "\033[0;31mDENIED: You cannot move/rename the core directory '$abs_path'.\033[0m"
exit 1
fi
if [[ "$abs_path" =~ ^(/var/www|/var/log|/var/local/enhance|/var/lib/docker)$ ]]; then
echo -e "\033[0;31mDENIED: You cannot move/rename this critical application directory ('$abs_path').\033[0m"
exit 1
fi
if [[ "$(basename "$abs_path")" == "safe_rm_dummy_do_not_delete" ]]; then
echo -e "\033[0;31mDENIED: Wildcard mass-move (*) detected. Command aborted.\033[0m"
exit 1
fi
if [[ "$abs_path" =~ ^/(var|usr|etc|root)/[^/]+$ ]]; then
echo -e "\033[0;31mDENIED: You cannot move/rename top-level system directories ('$abs_path').\033[0m"
exit 1
fi
done
exec /usr/bin/mv.original "$@"