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

View File

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