From daaf1005d5acf179e615385174a7bbf84b3cc277 Mon Sep 17 00:00:00 2001 From: Moul Date: Tue, 14 Jun 2016 14:09:29 +0200 Subject: [PATCH] =?UTF-8?q?[enh]=20create=20blocks=20for=20MySQL=20and=20P?= =?UTF-8?q?HP=C2=A0command=20lines=20which=20are=20optionnals.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/nginx.conf | 3 ++- scripts/backup | 6 ++++-- scripts/install | 9 +++++---- scripts/remove | 8 +++++--- scripts/restore | 6 ++++-- scripts/upgrade | 8 +++----- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 2033083..8c76342 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -3,7 +3,7 @@ location YNH_WWW_PATH { # Path to source alias YNH_WWW_ALIAS ; - # Example PHP configuration + # Example PHP configuration (remove if not used) index index.php; # Common parameter to increase upload size limit in conjuction with dedicated php-fpm file @@ -26,6 +26,7 @@ location YNH_WWW_PATH { fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; } + # PHP configuration end # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/scripts/backup b/scripts/backup index 0b907ab..d678ee2 100755 --- a/scripts/backup +++ b/scripts/backup @@ -13,19 +13,21 @@ app=$YNH_APP_INSTANCE_NAME # Note: the last argument is where to save this path, see the restore script. ynh_backup "/var/www/${app}" "sources" +### MySQL (remove if not used) ### # If a MySQL database is used: -# # # Dump the database # dbname=$app # dbuser=$app # dbpass=$(ynh_app_setting_get "$app" mysqlpwd) # mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql +### MySQL end ### # Copy NGINX configuration domain=$(ynh_app_setting_get "$app" domain) ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" +### PHP (remove if not used) ### # If a dedicated php-fpm process is used: -# # # Copy PHP-FPM pool configuration # ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf" +### PHP end ### diff --git a/scripts/install b/scripts/install index 3b3f328..d4f9039 100755 --- a/scripts/install +++ b/scripts/install @@ -43,6 +43,7 @@ sudo cp -a ../sources/. $src_path # you may need to make some file and/or directory writeable by www-data (nginx user) sudo chown -R root: $src_path +### MySQL (can be removed if not used) ### # If your app use a MySQL database you can use these lines to bootstrap # a database, an associated user and save the password in app settings. # @@ -56,6 +57,7 @@ sudo chown -R root: $src_path # # Load initial SQL into the new database # ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" \ # < "../sources/sql/mysql.init.sql" +### MySQL end ### # Modify Nginx configuration file and copy it to Nginx conf directory nginx_conf=../conf/nginx.conf @@ -63,10 +65,10 @@ sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf # If a dedicated php-fpm process is used: # Don't forget to modify ../conf/nginx.conf accordingly or your app will not work! -# # sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf +### PHP (can be removed if not used) ### # If a dedicated php-fpm process is used: # Don't forget to modify ../conf/php-fpm.conf accordingly or your app will not work! # @@ -77,6 +79,8 @@ sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf # sudo cp ../conf/php-fpm.conf $finalphpconf # sudo chown root: $finalphpconf # sudo chmod 644 $finalphpconf +# sudo service php5-fpm reload +### PHP end ### # If app is public, add url to SSOWat conf as skipped_uris if [[ $is_public -eq 1 ]]; then @@ -86,6 +90,3 @@ fi # Reload services sudo service nginx reload - -# If a dedicated php-fpm process is used: -# sudo service php5-fpm reload diff --git a/scripts/remove b/scripts/remove index 9be714b..fdbcc3f 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,21 +12,23 @@ domain=$(ynh_app_setting_get "$app" domain) # Remove sources sudo rm -rf /var/www/$app -# Remove configuration files +# Remove nginx configuration file sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf +### PHP (remove if not used) ### # If a dedicated php-fpm process is used: -# # sudo rm -f /etc/php5/fpm/pool.d/$app.conf # sudo service php5-fpm reload +### PHP end ### +### MySQL (remove if not used) ### # If a MySQL database is used: -# # # Drop MySQL database and user # dbname=$app # dbuser=$app # ynh_mysql_drop_db "$dbname" || true # ynh_mysql_drop_user "$dbuser" || true +### MySQL end ### # Reload nginx service sudo service nginx reload diff --git a/scripts/restore b/scripts/restore index 9dc6974..9acd9e6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -28,23 +28,25 @@ sudo cp -a ./sources "$src_path" # you may need to make some file and/or directory writeable by www-data (nginx user) sudo chown -R root: "$src_path" +### MySQL (remove if not used) ### # If a MySQL database is used: -# # # Create and restore the database # dbname=$app # dbuser=$app # dbpass=$(ynh_app_setting_get "$app" mysqlpwd) # ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" # ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql +### MySQL end ### # Restore NGINX configuration sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" +### PHP (remove if not used) ### # If a dedicated php-fpm process is used: -# # # Copy PHP-FPM pool configuration and reload the service # sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf" # sudo service php5-fpm reload +### PHP end ### # Restart webserver sudo service nginx reload diff --git a/scripts/upgrade b/scripts/upgrade index 138c2df..27742a9 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -37,8 +37,8 @@ sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf # sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf +### PHP (remove if not used) ### # If a dedicated php-fpm process is used: -# # # Modify PHP-FPM pool configuration and copy it to the pool directory # sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf # sed -i "s@YNH_WWW_ALIAS@$src_path/@g" ../conf/php-fpm.conf @@ -46,6 +46,8 @@ sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf # sudo cp ../conf/php-fpm.conf $finalphpconf # sudo chown root: $finalphpconf # sudo chmod 644 $finalphpconf +# sudo service php5-fpm restart +### PHP end ### # If app is public, add url to SSOWat conf as skipped_uris if [[ $is_public -eq 1 ]]; then @@ -53,9 +55,5 @@ if [[ $is_public -eq 1 ]]; then ynh_app_setting_set "$app" unprotected_uris "/" fi -# If a dedicated php-fpm process is used: -# -# sudo service php5-fpm restart - # Reload nginx service sudo service nginx reload