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

Merge pull request #43 from YunoHost-Apps/polytan02-composer-from-opt

Polytan02 composer from opt
This commit is contained in:
polytan02 2017-03-05 21:12:13 +00:00 committed by GitHub
commit 4fe9296d4e
5 changed files with 68 additions and 30 deletions

View file

@ -249,3 +249,4 @@ php_value[max_input_time] = 600
;php_value[memory_limit] = 256M ;php_value[memory_limit] = 256M
;php_value[short_open_tag] = On ;php_value[short_open_tag] = On
env[COMPOSER_HOME]= /opt/YNH_WWW_APP_composer'

View file

@ -16,7 +16,7 @@ ynh_backup "/var/www/${app}" "sources"
# Backup of composer # Backup of composer
# #
# TO BE VALIDATED AND TESTED # TO BE VALIDATED AND TESTED
ynh_backup "/opt/flarum_composer" "flarum_composer" ynh_backup "/opt/${app}_composer" "flarum_composer"
### MySQL ### ### MySQL ###
# If a MySQL database is used: # If a MySQL database is used:

View file

@ -81,23 +81,25 @@ sudo chown -R www-data:www-data $tmp
sudo chmod -R 755 $tmp sudo chmod -R 755 $tmp
# Prepare composer and cache directories # Prepare composer and cache directories
sudo mkdir -p /opt/flarum_composer/cache compo=/opt/${app}_composer
sudo chown -R www-data:www-data /opt/flarum_composer sudo mkdir -p $compo/cache
sudo chmod -R 755 /opt/flarum_composer sudo chown -R www-data:www-data $compo
sudo chmod -R 755 $compo
### composer ### ### composer ###
if ! type "composer" > /dev/null; then #if ! type "composer" > /dev/null; then
# Install composer (https://getcomposer.org) # Install composer (https://getcomposer.org)
EXPECTED_SIGNATURE=$(wget https://composer.github.io/installer.sig -O - -q) EXPECTED_SIGNATURE=$(wget https://composer.github.io/installer.sig -O - -q)
sudo su - www-data -s /bin/bash -c "php -r \"copy('https://getcomposer.org/installer', '$tmp/composer-setup.php');\"" sudo php -r "copy('https://getcomposer.org/installer', '$compo/composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', '$tmp/composer-setup.php');") ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', '$compo/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/pool.d/${app}.conf || sudo echo 'env[COMPOSER_HOME]= /opt/flarum_composer' >> /etc/php5/fpm/pool.d/${app}.conf" # sudo grep -q -F 'env[COMPOSER_HOME]= $compo' /etc/php5/fpm/pool.d/${app}.conf || sudo echo 'env[COMPOSER_HOME]= /opt/flarum_c$
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" # echo "php reload"
sudo mv $tmp/composer /usr/local/bin sudo php $compo/composer-setup.php --install-dir=$compo --filename=composer
sudo chown root:root /usr/local/bin/composer # sudo mv /opt/flarum_composer/composer /usr/local/bin
# sudo chown root:root /usr/local/bin/composer
RESULT=$? RESULT=$?
else else
>&2 echo 'ERROR: Invalid installer signature' >&2 echo 'ERROR: Invalid installer signature'
@ -105,10 +107,9 @@ if ! type "composer" > /dev/null; then
fi fi
if [ $RESULT != 0 ] if [ $RESULT != 0 ]
then then
sudo rm -rf $final_path ynh_die
exit $RESULT
fi
fi fi
#fi
### composer end ### ### composer end ###
### Install flarum ### Install flarum

View file

@ -6,22 +6,61 @@ app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers # Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
SECURE_REMOVE () { # Suppression de dossier avec vérification des variables
chaine="$1" # L'argument doit être donné entre quotes simple '', pour éviter d'interpréter les variables.
no_var=0
while (echo "$chaine" | grep -q '\$') # Boucle tant qu'il y a des $ dans la chaine
do
no_var=1
global_var=$(echo "$chaine" | cut -d '$' -f 2) # Isole la première variable trouvée.
only_var=\$$(expr "$global_var" : '\([A-Za-z0-9_]*\)') # Isole complètement la variable en ajoutant le $ au début et en gardant uniquement le nom de la variable. Se débarrasse surtout du / et d'un éventuel chemin derrière.
real_var=$(eval "echo ${only_var}") # `eval "echo ${var}` permet d'interpréter une variable contenue dans une variable.
if test -z "$real_var" || [ "$real_var" = "/" ]; then
echo "Variable $only_var is empty, suppression of $chaine cancelled." >&2
return 1
fi
chaine=$(echo "$chaine" | sed "s@$only_var@$real_var@") # remplace la variable par sa valeur dans la chaine.
done
if [ "$no_var" -eq 1 ]
then
if [ -e "$chaine" ]; then
echo "Delete directory $chaine"
sudo rm -r "$chaine"
fi
return 0
else
echo "No detected variable." >&2
return 1
fi
}
REMOVE_NGINX_CONF () { # Suppression de la configuration nginx
if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config
echo "Delete nginx config"
sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf"
fi
}
REMOVE_FPM_CONF () { # Suppression de la configuration du pool php-fpm
if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then # Delete fpm config
echo "Delete fpm config"
sudo rm "/etc/php5/fpm/pool.d/$app.conf"
fi
}
# Retrieve app settings # Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get "$app" domain)
# Remove sources # Remove sources
sudo rm -rf /tmp/composerinstall SECURE_REMOVE "/tmp/composerinstall"
sudo rm -rf /var/www/$app SECURE_REMOVE "/var/www/$app"
sudo rm -rf /opt/flarum_composer SECURE_REMOVE "/opt/${app}_composer"
# Remove nginx configuration file # Remove nginx and PHP-FPM files and restart services
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf REMOVE_NGINX_CONF
REMOVE_FPM_CONF
### PHP ### sudo service nginx reload
# If a dedicated php-fpm process is used:
sudo rm -f /etc/php5/fpm/pool.d/$app.conf
sudo service php5-fpm reload sudo service php5-fpm reload
### PHP end ###
### MySQL ### ### MySQL ###
# If a MySQL database is used: # If a MySQL database is used:
@ -31,6 +70,3 @@ dbuser=$app
ynh_mysql_drop_db "$dbname" || true ynh_mysql_drop_db "$dbname" || true
ynh_mysql_drop_user "$dbuser" || true ynh_mysql_drop_user "$dbuser" || true
### MySQL end ### ### MySQL end ###
# Reload nginx service
sudo service nginx reload

View file

@ -28,8 +28,8 @@ sudo cp -a ./sources "$src_path"
# #
# TO BE TESTED AND VALIDATED # TO BE TESTED AND VALIDATED
# #
cp -a ./flarum_composer /opt/flarum_composer cp -a ./flarum_composer /opt/${app}_composer
cp -a ./local_composer /usr/local/bin/composer #cp -a ./local_composer /usr/local/bin/composer
# Restore permissions to app files # Restore permissions to app files
# you may need to make some file and/or directory writeable by www-data (nginx user) # you may need to make some file and/or directory writeable by www-data (nginx user)