fix(): composer permission

pull/43/head
Magicalex 2018-12-26 21:23:52 +01:00
parent fee3008f5a
commit 123ec01df7
No known key found for this signature in database
GPG Key ID: A89B48B1788C3CB5
2 changed files with 22 additions and 22 deletions

View File

@ -15,29 +15,29 @@ CACHE_DIR=/flarum/app/extensions/.cache
LIST_FILE=/flarum/app/extensions/list
# Cmd ARGS
action=$1
package=$2
action="${1}"
package="${2}"
# Create custom extensions cache folder and list file
su-exec $UID:$GID mkdir -p "$CACHE_DIR"
su-exec $UID:$GID touch "$LIST_FILE"
su-exec $UID:$GID mkdir -p "${CACHE_DIR}"
su-exec $UID:$GID touch "${LIST_FILE}"
case "$action" in
case "${action}" in
# Install a flarum extension
"require")
COMPOSER_CACHE_DIR="$CACHE_DIR" su-exec $UID:$GID composer require "$package"
COMPOSER_CACHE_DIR="${CACHE_DIR}" composer require "$package"
if [ $? -eq 0 ]; then
echo "$package" >> "$LIST_FILE"
echo "${package}" >> "${LIST_FILE}"
echo -e "\n${CGREEN}${package} added to flarum.${CEND}"
# Remove duplicate packages
sort -u -o "$LIST_FILE" "$LIST_FILE"
sort -u -o "${LIST_FILE}" "${LIST_FILE}"
else
echo -e "\n${CRED}/!\ An error has occurred...${CEND}"
fi
;;
# Remove a flarum extension
"remove")
COMPOSER_CACHE_DIR="$CACHE_DIR" su-exec $UID:$GID composer remove "$package"
COMPOSER_CACHE_DIR="$CACHE_DIR" composer remove "${package}"
if [ $? -eq 0 ]; then
sed -i "\|${package}|d" "$LIST_FILE"
echo -e "\n${CGREEN}${package} removed from flarum${CEND}"
@ -46,11 +46,11 @@ case "$action" in
fi
;;
"list")
cat "$LIST_FILE"
cat "${LIST_FILE}"
;;
# Other composer action
*)
COMPOSER_CACHE_DIR="$CACHE_DIR" su-exec $UID:$GID composer "$@"
COMPOSER_CACHE_DIR="${CACHE_DIR}" composer "${@}"
;;
esac

View File

@ -1,13 +1,13 @@
#!/bin/sh
# Default values
DB_HOST=${DB_HOST:-mariadb}
DB_USER=${DB_USER:-flarum}
DB_NAME=${DB_NAME:-flarum}
DB_PORT=${DB_PORT:-3306}
FLARUM_TITLE=${FLARUM_TITLE:-Docker-Flarum}
DEBUG=${DEBUG:-false}
LOG_TO_STDOUT=${LOG_TO_STDOUT:-false}
DB_HOST="${DB_HOST:-mariadb}"
DB_USER="${DB_USER:-flarum}"
DB_NAME="${DB_NAME:-flarum}"
DB_PORT="${DB_PORT:-3306}"
FLARUM_TITLE="${FLARUM_TITLE:-Docker-Flarum}"
DEBUG="${DEBUG:-false}"
LOG_TO_STDOUT="${LOG_TO_STDOUT:-false}"
# Required env variables
if [ -z "${DB_PASS}" ]; then
@ -45,7 +45,7 @@ if [ -f '/flarum/app/extensions/auth.token.txt' ]; then
token=$(echo $line | cut -d '|' -f2)
if [ $site = "github" ]; then
echo "[INFO] Adding ${site} token authentication"
su-exec $UID:$GID composer config github-oauth.github.com $token
composer config github-oauth.github.com $token
fi
done < /flarum/app/extensions/auth.token.txt
fi
@ -56,7 +56,7 @@ if [ -f '/flarum/app/extensions/composer.repositories.txt' ]; then
repository=$(echo $line | cut -d '|' -f1)
json=$(echo $line | cut -d '|' -f2)
echo "[INFO] Adding ${repository} composer repository"
su-exec $UID:$GID composer config repositories.$repository "${json}"
composer config repositories."${repository}" "${json}"
done < /flarum/app/extensions/composer.repositories.txt
fi
@ -93,8 +93,8 @@ if [ -e '/flarum/app/public/assets/installed.txt' ]; then
while read line; do
extension="${extension} ${line}"
done < /flarum/app/extensions/list
command="composer require ${extension}"
COMPOSER_CACHE_DIR="${CACHE_DIR}" su-exec $UID:$GID $command
command="require ${extension}"
COMPOSER_CACHE_DIR="${CACHE_DIR}" composer "${command}"
echo "[INFO] Install extra bundled extensions: DONE."
else
echo "[INFO] No installed extensions"