From 8e027bb47e0aab981735ea8c26f30d763622a7fe Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 9 Apr 2021 10:28:23 -0400 Subject: [PATCH] chore: improve fix_root script --- fix_root.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fix_root.sh b/fix_root.sh index b786395..fc19bb7 100755 --- a/fix_root.sh +++ b/fix_root.sh @@ -6,6 +6,11 @@ if [[ $(whoami) == "root" ]]; then exit 1 fi +if [[ $(pwd) == "/" ]]; then + echo "Should not be run from root directory" + exit 1 +fi + # Uses your host username and its primary associated group username="$(whoami)" group="$(id -g -n "$username")" @@ -13,4 +18,4 @@ group="$(id -g -n "$username")" while read -r file; do echo sudo chown "$username":"$group" "$file" sudo chown "$username":"$group" "$file" -done < <(find ~+ -type f -user root) +done < <(find ~+ -type f,d -user root)