Skip to content

Commit

Permalink
put in install path checks for init.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
binhex committed Mar 20, 2018
1 parent e0aaeee commit 9f2ac0d
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions build/root/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF > /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

Expand Down

0 comments on commit 9f2ac0d

Please sign in to comment.