1
0
mirror of synced 2025-12-17 04:52:15 +01:00
Files
hassio-addons/tvheadend/root/etc/cont-init.d/30-config
2022-12-07 09:01:53 +01:00

48 lines
1.1 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/with-contenv bash
# make folders
mkdir -p \
/config/comskip
# copy config
[[ ! -e /config/dvr/config ]] && \
(mkdir -p /config/dvr/config && cp /defaults/7a5edfbe189851e5b1d1df19c93962f0 /config/dvr/config/7a5edfbe189851e5b1d1df19c93962f0)
[[ ! -e /config/comskip/comskip.ini ]] && \
cp /defaults/comskip.ini.org /config/comskip/comskip.ini
[[ ! -e /config/config ]] && \
(cp /defaults/config /config/config)
# extract picons on first run
[[ -f /picons.tar.bz2 ]] && \
mkdir -p /picons
tar xf \
/picons.tar.bz2 -C \
/picons &&
rm -f /picons.tar.bz2
# function to randomly sample 5 files for their owner and only chown if not abc
chowner () {
files=(${1}/*)
for i in {1..5}; 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