#72 fix chowning (#125)

* #72 only chown once using new logic, rebase to alpine 3.9, increase make threads now that arm boxes are single threaded

* typo
This commit is contained in:
Ryan Kuba
2019-03-28 15:02:54 +08:00
committed by saarg
parent 753d0bbe38
commit 9d64ee4636
6 changed files with 52 additions and 28 deletions

View File

@@ -13,7 +13,29 @@ mkdir -p \
(cp /defaults/config /config/config)
# permissions
chown -R abc:abc \
/config \
/picons
# function to randomly sample 10 files for their owner and only chown if not abc
chowner () {
files=(${1}/*)
for i in {1..10}; 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"
abc_dirs=( \
/config \
/picons \
)
for i in "${abc_dirs[@]}"; do
if [ "$(ls -A ${i})" ]; then
chowner ${i}
else
chown -R abc:abc ${i}
fi
done