Skip to content

Commit

Permalink
add PATH-PREFIX env and updare config-site.php
Browse files Browse the repository at this point in the history
  • Loading branch information
th-2021 committed Aug 22, 2024
1 parent bfa60d7 commit 4313d6c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@ fix_configs() {
fi

# Fix for PATH_PREFIX
HAS_PREFIX=`grep --invert-match '^[[:blank:]]*#[^!]' $CONFIG_SITE_PHP | grep PATH_PREFIX || true`
if [[ ! -z "$HAS_PREFIX" ]];
if [[ ! -z "$PATH_PREFIX" ]];
then
PATH_PRFIX=`echo $HAS_PREFIX | awk 'BEGIN { FS="="}{ print $2 }' | awk '{$1=$1};1' | tr ";" ","`
log "PATH_PREFIX set $PATH_PRFIX"
sed -i -e "s#location.origin\ +\ .*#location.origin\ +\ $PATH_PRFIX#" /var/piler/www/assets/js/piler.js
log "PATH_PREFIX set $PATH_PREFIX"
sed -i -e "s#location.origin\ +\ .*#location.origin\ +\ $PATH_PREFIX,#" /var/piler/www/assets/js/piler.js
if ! grep "'PATH_PREFIX'" "$CONFIG_SITE_PHP"; then
echo "\$config['PATH_PREFIX'] = '${PATH_PREFIX}';" >> "$CONFIG_SITE_PHP"
fi
fi
}

Expand Down

1 comment on commit 4313d6c

@jsuto
Copy link
Owner

@jsuto jsuto commented on 4313d6c Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost perfect! One refinement would be great though. Instead of if [[ ! -z "$PATH_PREFIX" ]]; I'd prefer if [[ -v PATH_PREFIX ]]; AKA the positive logic.

Also I wonder, if we fix the path in piler.js no matter what the previous value might be, shouldn't it be done with $config['PATH_PREFIX'], too? That is to run sed on $CONFIG_SITE_PHP after the if - fi block when you append it the PATH_PREFIX. Or we may just skip this, and let's hope that the user won't change the PATH_PREFIX more than once.

Please sign in to comment.