fix(): chown performance improvement

pull/72/head
Magicalex 2020-11-19 18:13:36 +01:00
parent 9bb72c451f
commit 2c9e124660
No known key found for this signature in database
GPG Key ID: A89B48B1788C3CB5
2 changed files with 15 additions and 18 deletions

View File

@ -25,7 +25,7 @@ su-exec "${UID}:${GID}" touch "${LIST_FILE}"
case "${action}" in
# Install a flarum extension
"require")
COMPOSER_CACHE_DIR="${CACHE_DIR}" composer require "$package"
COMPOSER_CACHE_DIR="${CACHE_DIR}" su-exec "${UID}:${GID}" composer require "${package}"
if [ $? -eq 0 ]; then
echo "${package}" >> "${LIST_FILE}"
echo -e "\n${CGREEN}${package} added to flarum.${CEND}"
@ -37,7 +37,7 @@ case "${action}" in
;;
# Remove a flarum extension
"remove")
COMPOSER_CACHE_DIR="$CACHE_DIR" composer remove "${package}"
COMPOSER_CACHE_DIR="$CACHE_DIR" su-exec "${UID}:${GID}" composer remove "${package}"
if [ $? -eq 0 ]; then
sed -i "\|${package}|d" "$LIST_FILE"
echo -e "\n${CGREEN}${package} removed from flarum${CEND}"
@ -50,7 +50,7 @@ case "${action}" in
;;
# Other composer action
*)
COMPOSER_CACHE_DIR="${CACHE_DIR}" composer "${@}"
COMPOSER_CACHE_DIR="${CACHE_DIR}" su-exec "${UID}:${GID}" composer "${@}"
;;
esac

View File

@ -17,12 +17,16 @@ sed -i "s/<UPLOAD_MAX_SIZE>/${UPLOAD_MAX_SIZE}/g" /etc/nginx/nginx.conf /etc/php
sed -i "s/<PHP_MEMORY_LIMIT>/${PHP_MEMORY_LIMIT}/g" /etc/php7/php-fpm.conf
sed -i "s/<OPCACHE_MEMORY_LIMIT>/${OPCACHE_MEMORY_LIMIT}/g" /etc/php7/conf.d/00_opcache.ini
# Set permissions
# Set permissions for /flarum folder
echo "[INFO] Setting folder permissions"
for folder in /services /var/log /var/lib/nginx; do
find ${folder} ! -user "${UID}" -exec chown -h "${UID}:${GID}" {} \;
find ${folder} ! -group "${GID}" -exec chown -h "${UID}:${GID}" {} \;
find ${folder} ! -user "${UID}" -exec chown -h "${UID}:${GID}" {} \+
find ${folder} ! -group "${GID}" -exec chown -h "${UID}:${GID}" {} \+
done
find /flarum ! -user "${UID}" -exec chown "${UID}:${GID}" {} \+
find /flarum ! -group "${GID}" -exec chown "${UID}:${GID}" {} \+
# Set log output to STDOUT if wanted (LOG_TO_STDOUT=true)
if [ "${LOG_TO_STDOUT}" = true ]; then
echo "[INFO] Logging to stdout activated"
@ -36,13 +40,13 @@ if [ -n "${PHP_EXTENSIONS}" ]; then
for php_extension in ${PHP_EXTENSIONS}; do
PACKAGES="php7-${php_extension} ${PACKAGES}"
done
echo "[INFO] Adding php extensions"
apk add --no-progress --no-cache ${PACKAGES}
fi
cd /flarum/app
# add github token authentication (eg. for privates extensions)
# Add github token authentication (eg. for privates extensions)
if [ "${GITHUB_TOKEN_AUTH}" != false ]; then
echo "[INFO] Adding github token authentication"
composer config github-oauth.github.com "${GITHUB_TOKEN_AUTH}"
@ -54,7 +58,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"
composer config repositories."${repository}" "${json}"
composer config repositories."${repository}" --json "${json}"
done < /flarum/app/extensions/composer.repositories.txt
fi
@ -79,7 +83,7 @@ if [ -e '/flarum/app/public/assets/rev-manifest.json' ]; then
-e "s|<DB_PREF>|${DB_PREF}|g" \
-e "s|<FORUM_URL>|${FORUM_URL}|g" /flarum/app/config.php.sample
cp /flarum/app/config.php.sample /flarum/app/config.php
cp -p /flarum/app/config.php.sample /flarum/app/config.php
su-exec "${UID}:${GID}" php /flarum/app/flarum cache:clear
# Composer cache dir and packages list paths
@ -93,7 +97,7 @@ if [ -e '/flarum/app/public/assets/rev-manifest.json' ]; then
extension="${extension}${line} "
done < /flarum/app/extensions/list
cmd="composer require ${extension}"
COMPOSER_CACHE_DIR="${CACHE_DIR}" eval "${cmd}"
COMPOSER_CACHE_DIR="${CACHE_DIR}" su-exec "${UID}:${GID}" eval "${cmd}"
echo "[INFO] Install extra bundled extensions: DONE."
else
echo "[INFO] No installed extensions"
@ -123,16 +127,9 @@ else
-e "s|<FLARUM_TITLE>|${FLARUM_TITLE}|g" /flarum/app/config.yml
# Install flarum
find /flarum ! -user "${UID}" -exec chown "${UID}:${GID}" {} \;
find /flarum ! -group "${GID}" -exec chown "${UID}:${GID}" {} \;
su-exec "${UID}:${GID}" php /flarum/app/flarum install --file=/flarum/app/config.yml
echo "[INFO] End of flarum installation"
fi
# Set permissions for /flarum folder
echo "[INFO] Setting folder permissions"
find /flarum ! -user "${UID}" -exec chown "${UID}:${GID}" {} \+
find /flarum ! -group "${GID}" -exec chown "${UID}:${GID}" {} \+
echo "[Info] End of startup script. Forum is starting."
exec su-exec "${UID}:${GID}" /bin/s6-svscan /services