diff --git a/build/root/install.sh b/build/root/install.sh index d0bd63c..50f3e55 100644 --- a/build/root/install.sh +++ b/build/root/install.sh @@ -32,17 +32,35 @@ aur_packages="sabnzbd" # call aur install script (arch user repo) source /root/aur.sh -# config -#### - # container perms #### -# create file with contets of here doc -cat <<'EOF' > /tmp/permissions_heredoc +# define comma separated list of paths +install_paths="/opt/sabnzbd,/etc/privoxy,/home/nobody" + +# split comma separated string into list for install paths +IFS=',' read -ra install_paths_list <<< "${install_paths}" + +# process install paths in the list +for i in "${install_paths_list[@]}"; do + + # confirm path(s) exist, if not then exit + if [[ ! -d "${i}" ]]; then + echo "[crit] Path '${i}' does not exist, exiting build process..." ; exit 1 + fi + +done + +# convert comma separated string of install paths to space separated, required for chmod/chown processing +install_paths=$(echo "${install_paths}" | tr ',' ' ') + +# create file with contents of here doc, note EOF is NOT quoted to allow us to expand current variable 'install_paths' +# we use escaping to prevent variable expansion for PUID and PGID, as we want these expanded at runtime of init.sh +# note - do NOT double quote variable for install_paths otherwise this will wrap space separated paths as a single string +cat < /tmp/permissions_heredoc # set permissions inside container -chown -R "${PUID}":"${PGID}" /opt/sabnzbd /usr/bin/privoxy /etc/privoxy /home/nobody -chmod -R 775 /opt/sabnzbd /usr/bin/privoxy /etc/privoxy /home/nobody +chown -R "\${PUID}":"\${PGID}" ${install_paths} +chmod -R 775 ${install_paths} EOF