From bdbe0ac79e510958bd0d63119a6754d739e53d29 Mon Sep 17 00:00:00 2001 From: Moul Date: Mon, 13 Jun 2016 22:25:00 +0200 Subject: [PATCH] [enh] review, variables, typo, syntax, fixes - update yunohost package version dependency - use variable for $nginx_conf - rename $final_path to $src_path variable for data path - other small fixes --- README.md | 4 ++-- manifest.json | 2 +- scripts/install | 28 +++++++++++++--------------- scripts/remove | 2 +- scripts/restore | 6 +++--- scripts/upgrade | 24 ++++++++++++------------ 6 files changed, 32 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 27f7f34..6d6cb13 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# YunoHost example app # +# YunoHost example app -## Usage ## +## Usage - Add application source files into `sources` subfolder. - Edit `conf/nginx.conf` file to match application prerequisites. - Edit manifest with application specific information. diff --git a/manifest.json b/manifest.json index b327c3f..513d033 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "url": "http://example.com" }, "requirements": { - "yunohost": ">> 2.3.12.1" + "yunohost": ">> 2.4.0" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index 2c44b45..3b3f328 100755 --- a/scripts/install +++ b/scripts/install @@ -35,13 +35,13 @@ sudo yunohost app checkurl "${domain}${path}" -a "$app" \ || ynh_die "Path not available: ${domain}${path}" # Copy source files -final_path=/var/www/$app -sudo mkdir -p $final_path -sudo cp -a ../sources/. $final_path +src_path=/var/www/$app +sudo mkdir -p $src_path +sudo cp -a ../sources/. $src_path # Set permissions to app files # you may need to make some file and/or directory writeable by www-data (nginx user) -sudo chown -R root:root $final_path +sudo chown -R root: $src_path # 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. @@ -58,36 +58,34 @@ sudo chown -R root:root $final_path # < "../sources/sql/mysql.init.sql" # Modify Nginx configuration file and copy it to Nginx conf directory -sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf -sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf +nginx_conf=../conf/nginx.conf +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! # -# sudo sed -i "s@YNH_WWW_APP@$app@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf +# sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf +sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf # If a dedicated php-fpm process is used: # Don't forget to modify ../conf/php-fpm.conf accordingly or your app will not work! # # # 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@$final_path/@g" ../conf/php-fpm.conf +# sed -i "s@YNH_WWW_ALIAS@$src_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 # 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. ynh_app_setting_set "$app" unprotected_uris "/" fi +# Reload services +sudo service nginx reload # If a dedicated php-fpm process is used: -# # sudo service php5-fpm reload - -# Restart services -sudo service nginx reload diff --git a/scripts/remove b/scripts/remove index eb493bd..9be714b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -28,5 +28,5 @@ sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf # ynh_mysql_drop_db "$dbname" || true # ynh_mysql_drop_user "$dbuser" || true -# Restart services +# Reload nginx service sudo service nginx reload diff --git a/scripts/restore b/scripts/restore index 52280e4..9dc6974 100755 --- a/scripts/restore +++ b/scripts/restore @@ -21,12 +21,12 @@ sudo yunohost app checkurl "${domain}${path}" -a "$app" \ || ynh_die "Path not available: ${domain}${path}" # Restore sources & data -final_path="/var/www/${app}" -sudo cp -a ./sources "$final_path" +src_path="/var/www/${app}" +sudo cp -a ./sources "$src_path" # Restore permissions to app files # you may need to make some file and/or directory writeable by www-data (nginx user) -sudo chown -R root:root "$final_path" +sudo chown -R root: "$src_path" # If a MySQL database is used: # diff --git a/scripts/upgrade b/scripts/upgrade index 490a18d..138c2df 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,35 +20,35 @@ language=$(ynh_app_setting_get "$app" language) path=${path%/} # Copy source files -final_path=/var/www/$app -sudo mkdir -p $final_path -sudo cp -a ../sources/. $final_path +src_path=/var/www/$app +sudo mkdir -p $src_path +sudo cp -a ../sources/. $src_path # Set permissions to app files # you may need to make some file and/or directory writeable by www-data (nginx user) -sudo chown -R root:root $final_path +sudo chown -R root: $src_path # Modify Nginx configuration file and copy it to Nginx conf directory -sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf -sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf +nginx_conf=../conf/nginx.conf +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: # -# sudo sed -i "s@YNH_WWW_APP@$app@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf +# sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf +sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf # 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@$final_path/@g" ../conf/php-fpm.conf +# sed -i "s@YNH_WWW_ALIAS@$src_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 # If app is public, add url to SSOWat conf as skipped_uris -if [[ $is_public -eq 1 ]]; -then +if [[ $is_public -eq 1 ]]; then # See install script ynh_app_setting_set "$app" unprotected_uris "/" fi @@ -57,5 +57,5 @@ fi # # sudo service php5-fpm restart -# Restart services +# Reload nginx service sudo service nginx reload