adding first version of boilerplate code we can use for chowning

This commit is contained in:
thelamer
2019-03-26 11:58:04 -07:00
committed by Ryan Kuba
parent 54e59d820e
commit 2ce4be8c28

View File

@@ -39,8 +39,28 @@ done
# set queue driver to database
sed -i 's/QUEUE_DRIVER=sync/QUEUE_DRIVER=database/' /config/www/.env
# function to randomly sample 50 files for their owner and only chown if not abc
chowner () {
files=(${1}/*)
for i in {1..50}; do
user=$(stat -c '%U' $(printf "%s\n" "${files[RANDOM % ${#files[@]}]}"))
if [ "${user}" != "abc" ]; then
chown -R abc:abc ${1}
break
fi
done
}
# permissions
echo "Setting permissions"
chown -R abc:abc \
abc_dirs=( \
/config \
/var/www/localhost/heimdall
/var/www/localhost/heimdall \
)
for i in "${abc_dirs[@]}"; do
if [ "$(ls -A ${i})" ]; then
chowner ${i}
else
chown -R abc:abc ${i}
fi
done