diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66f1a4d --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +# ignore comments files +todo.txt +notes.txt + +# ignore mac generated files +.DS_Store + +# ignore pycharm ide +.idea + +# ignore compiled python scripts +*.pyc + +# ignore virtual env +venv diff --git a/build/root/install.sh b/build/root/install.sh index cd3b85b..7d88921 100644 --- a/build/root/install.sh +++ b/build/root/install.sh @@ -47,11 +47,32 @@ source /root/aur.sh # container perms #### -# create file with contets of here doc -cat <<'EOF' > /tmp/permissions_heredoc +# define comma separated list of paths +install_paths="/usr/lib/jackett,/var/lib/jackett,/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}" /usr/lib/jackett/ /var/lib/jackett/ /home/nobody -chmod -R 775 /usr/lib/jackett/ /var/lib/jackett/ /home/nobody +chown -R "\${PUID}":"\${PGID}" ${install_paths} +chmod -R 775 ${install_paths} EOF