fix(): chown performance improvement
parent
9bb72c451f
commit
2c9e124660
|
@ -25,7 +25,7 @@ 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}" composer require "$package"
|
COMPOSER_CACHE_DIR="${CACHE_DIR}" su-exec "${UID}:${GID}" 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}"
|
||||||
|
@ -37,7 +37,7 @@ case "${action}" in
|
||||||
;;
|
;;
|
||||||
# Remove a flarum extension
|
# Remove a flarum extension
|
||||||
"remove")
|
"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
|
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}"
|
||||||
|
@ -50,7 +50,7 @@ case "${action}" in
|
||||||
;;
|
;;
|
||||||
# Other composer action
|
# Other composer action
|
||||||
*)
|
*)
|
||||||
COMPOSER_CACHE_DIR="${CACHE_DIR}" composer "${@}"
|
COMPOSER_CACHE_DIR="${CACHE_DIR}" su-exec "${UID}:${GID}" composer "${@}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -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/<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
|
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
|
for folder in /services /var/log /var/lib/nginx; do
|
||||||
find ${folder} ! -user "${UID}" -exec chown -h "${UID}:${GID}" {} \;
|
find ${folder} ! -user "${UID}" -exec chown -h "${UID}:${GID}" {} \+
|
||||||
find ${folder} ! -group "${GID}" -exec chown -h "${UID}:${GID}" {} \;
|
find ${folder} ! -group "${GID}" -exec chown -h "${UID}:${GID}" {} \+
|
||||||
done
|
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)
|
# Set log output to STDOUT if wanted (LOG_TO_STDOUT=true)
|
||||||
if [ "${LOG_TO_STDOUT}" = true ]; then
|
if [ "${LOG_TO_STDOUT}" = true ]; then
|
||||||
echo "[INFO] Logging to stdout activated"
|
echo "[INFO] Logging to stdout activated"
|
||||||
|
@ -36,13 +40,13 @@ if [ -n "${PHP_EXTENSIONS}" ]; then
|
||||||
for php_extension in ${PHP_EXTENSIONS}; do
|
for php_extension in ${PHP_EXTENSIONS}; do
|
||||||
PACKAGES="php7-${php_extension} ${PACKAGES}"
|
PACKAGES="php7-${php_extension} ${PACKAGES}"
|
||||||
done
|
done
|
||||||
|
echo "[INFO] Adding php extensions"
|
||||||
apk add --no-progress --no-cache ${PACKAGES}
|
apk add --no-progress --no-cache ${PACKAGES}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /flarum/app
|
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
|
if [ "${GITHUB_TOKEN_AUTH}" != false ]; then
|
||||||
echo "[INFO] Adding github token authentication"
|
echo "[INFO] Adding github token authentication"
|
||||||
composer config github-oauth.github.com "${GITHUB_TOKEN_AUTH}"
|
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)"
|
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"
|
||||||
composer config repositories."${repository}" "${json}"
|
composer config repositories."${repository}" --json "${json}"
|
||||||
done < /flarum/app/extensions/composer.repositories.txt
|
done < /flarum/app/extensions/composer.repositories.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -79,7 +83,7 @@ if [ -e '/flarum/app/public/assets/rev-manifest.json' ]; then
|
||||||
-e "s|<DB_PREF>|${DB_PREF}|g" \
|
-e "s|<DB_PREF>|${DB_PREF}|g" \
|
||||||
-e "s|<FORUM_URL>|${FORUM_URL}|g" /flarum/app/config.php.sample
|
-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
|
su-exec "${UID}:${GID}" php /flarum/app/flarum cache:clear
|
||||||
|
|
||||||
# Composer cache dir and packages list paths
|
# Composer cache dir and packages list paths
|
||||||
|
@ -93,7 +97,7 @@ if [ -e '/flarum/app/public/assets/rev-manifest.json' ]; then
|
||||||
extension="${extension}${line} "
|
extension="${extension}${line} "
|
||||||
done < /flarum/app/extensions/list
|
done < /flarum/app/extensions/list
|
||||||
cmd="composer require ${extension}"
|
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."
|
echo "[INFO] Install extra bundled extensions: DONE."
|
||||||
else
|
else
|
||||||
echo "[INFO] No installed extensions"
|
echo "[INFO] No installed extensions"
|
||||||
|
@ -123,16 +127,9 @@ else
|
||||||
-e "s|<FLARUM_TITLE>|${FLARUM_TITLE}|g" /flarum/app/config.yml
|
-e "s|<FLARUM_TITLE>|${FLARUM_TITLE}|g" /flarum/app/config.yml
|
||||||
|
|
||||||
# Install flarum
|
# 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
|
su-exec "${UID}:${GID}" php /flarum/app/flarum install --file=/flarum/app/config.yml
|
||||||
echo "[INFO] End of flarum installation"
|
echo "[INFO] End of flarum installation"
|
||||||
fi
|
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."
|
echo "[Info] End of startup script. Forum is starting."
|
||||||
exec su-exec "${UID}:${GID}" /bin/s6-svscan /services
|
exec su-exec "${UID}:${GID}" /bin/s6-svscan /services
|
||||||
|
|
Loading…
Reference in New Issue