@@ -47,17 +47,32 @@ source /root/aur.sh
4747# container perms
4848# ###
4949
50- # create file with contets of here doc
51- cat << 'EOF ' > /tmp/permissions_heredoc
52- # set permissions inside container
53- chown -R "${PUID}":"${PGID}" /usr/bin/tvheadend /run /home/nobody
54- chmod -R 775 /usr/bin/tvheadend /run /home/nobody
50+ # define comma separated list of paths
51+ install_paths=" /run,/home/nobody"
5552
56- # if dvb adapter(s) passed through then set permissions
57- if [[ -d /dev/dvb ]]; then
58- chown -R "${PUID}":"${PGID}" /dev/dvb
59- chmod -R 775 /dev/dvb
60- fi
53+ # split comma separated string into list for install paths
54+ IFS=' ,' read -ra install_paths_list <<< " ${install_paths}"
55+
56+ # process install paths in the list
57+ for i in " ${install_paths_list[@]} " ; do
58+
59+ # confirm path(s) exist, if not then exit
60+ if [[ ! -d " ${i} " ]]; then
61+ echo " [crit] Path '${i} ' does not exist, exiting build process..." ; exit 1
62+ fi
63+
64+ done
65+
66+ # convert comma separated string of install paths to space separated, required for chmod/chown processing
67+ install_paths=$( echo " ${install_paths} " | tr ' ,' ' ' )
68+
69+ # create file with contents of here doc, note EOF is NOT quoted to allow us to expand current variable 'install_paths'
70+ # we use escaping to prevent variable expansion for PUID and PGID, as we want these expanded at runtime of init.sh
71+ # note - do NOT double quote variable for install_paths otherwise this will wrap space separated paths as a single string
72+ cat << EOF > /tmp/permissions_heredoc
73+ # set permissions inside container
74+ chown -R "\$ {PUID}":"\$ {PGID}" ${install_paths}
75+ chmod -R 775 ${install_paths}
6176
6277EOF
6378
0 commit comments