From da60ec8c8b140675ab4c905cac4241328abb6239 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Thu, 8 Apr 2021 20:06:55 -0400 Subject: [PATCH] chore: Add script to fix dev container root issues --- fix_root.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 fix_root.sh diff --git a/fix_root.sh b/fix_root.sh new file mode 100755 index 0000000..b786395 --- /dev/null +++ b/fix_root.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Currently, the build container still used root. This results in files owned by root that interfere with running things outside of the container. Pending additional tooling work, this script is a stop gap that searches and chowns all files in the proeject tree owned by root + +if [[ $(whoami) == "root" ]]; then + echo "Should not be run as root" + exit 1 +fi + +# Uses your host username and its primary associated group +username="$(whoami)" +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)