1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/flarum_ynh.git synced 2024-09-03 18:36:24 +02:00

Use of dedicated php-fpm process for composer

This commit is contained in:
polytan02 2017-03-05 18:56:26 +00:00 committed by GitHub
parent 1b35be31bf
commit 8e0b56429f

View file

@ -47,11 +47,33 @@ ynh_app_setting_set "$app" admin "$admin"
ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set "$app" is_public "$is_public"
ynh_app_setting_set "$app" path "$path" ynh_app_setting_set "$app" path "$path"
# Check final_path availibility. Installation stops if it already exists # Check final_path availibility. Installation stops if it already exists
CHECK_FINALPATH CHECK_FINALPATH
sudo mkdir "$final_path" sudo mkdir "$final_path"
### Nginx ###
nginxconf="../conf/nginx.conf"
if [ $path = "/" ]; then
sed -i "s@YNH_WWW_ROOTPATH@@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ROOTAPP@/@g" ../conf/nginx.conf
else
sed -i "s@YNH_WWW_ROOTPATH@$path@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ROOTAPP@$path$path@g" ../conf/nginx.conf
fi
sed -i "s@YNH_WWW_PATH@$path@g" $nginxconf
sed -i "s@YNH_WWW_FINALPATH@$final_path@g" $nginxconf
sed -i "s@YNH_WWW_APP@$app@g" $nginxconf
sudo cp $nginxconf /etc/nginx/conf.d/$domain.d/$app.conf
### PHP ###
sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf
sed -i "s@YNH_WWW_ALIAS@$final_path@g" ../conf/php-fpm.conf
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
sudo cp ../conf/php-fpm.conf $finalphpconf
sudo chown root: $finalphpconf
sudo chmod 644 $finalphpconf
sudo service php5-fpm reload
tmp=/tmp/flaruminstall tmp=/tmp/flaruminstall
sudo rm -rf $tmp sudo rm -rf $tmp
sudo mkdir -p $tmp sudo mkdir -p $tmp
@ -71,7 +93,7 @@ if ! type "composer" > /dev/null; then
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', '$tmp/composer-setup.php');") ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', '$tmp/composer-setup.php');")
if [ "$EXPECTED_SIGNATURE" = "$ACTUAL_SIGNATURE" ] if [ "$EXPECTED_SIGNATURE" = "$ACTUAL_SIGNATURE" ]
then then
sudo su - root -c "grep -q -F 'env[COMPOSER_HOME]= /opt/flarum_composer' /etc/php5/fpm/php-fpm.conf || sudo echo 'env[COMPOSER_HOME]= /opt/flarum_composer' >> /etc/php5/fpm/php-fpm.conf" sudo su - root -c "grep -q -F 'env[COMPOSER_HOME]= /opt/flarum_composer' /etc/php5/fpm/pool.d/${app}.conf || sudo echo 'env[COMPOSER_HOME]= /opt/flarum_composer' >> /etc/php5/fpm/pool.d/${app}.conf"
sudo service php5-fpm reload sudo service php5-fpm reload
sudo su - www-data -s /bin/bash -c "php $tmp/composer-setup.php --install-dir=$tmp --filename=composer" sudo su - www-data -s /bin/bash -c "php $tmp/composer-setup.php --install-dir=$tmp --filename=composer"
sudo mv $tmp/composer /usr/local/bin sudo mv $tmp/composer /usr/local/bin
@ -104,29 +126,6 @@ dbpass=$(ynh_string_random 15)
ynh_app_setting_set "$app" mysqlpwd "$dbpass" ynh_app_setting_set "$app" mysqlpwd "$dbpass"
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
### Nginx ###
nginxconf="../conf/nginx.conf"
if [ $path = "/" ]; then
sed -i "s@YNH_WWW_ROOTPATH@@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ROOTAPP@/@g" ../conf/nginx.conf
else
sed -i "s@YNH_WWW_ROOTPATH@$path@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ROOTAPP@$path$path@g" ../conf/nginx.conf
fi
sed -i "s@YNH_WWW_PATH@$path@g" $nginxconf
sed -i "s@YNH_WWW_FINALPATH@$final_path@g" $nginxconf
sed -i "s@YNH_WWW_APP@$app@g" $nginxconf
sudo cp $nginxconf /etc/nginx/conf.d/$domain.d/$app.conf
### PHP ###
sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf
sed -i "s@YNH_WWW_ALIAS@$final_path@g" ../conf/php-fpm.conf
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
sudo cp ../conf/php-fpm.conf $finalphpconf
sudo chown root: $finalphpconf
sudo chmod 644 $finalphpconf
sudo service php5-fpm reload
# If app is public, add url to SSOWat conf as skipped_uris # If app is public, add url to SSOWat conf as skipped_uris
if [[ $is_public -eq 1 ]]; then if [[ $is_public -eq 1 ]]; then
# unprotected_uris allows SSO credentials to be passed anyway. # unprotected_uris allows SSO credentials to be passed anyway.