From 347164c026fb8e06f0d69c8f225a7826725331e3 Mon Sep 17 00:00:00 2001 From: inrepublica Date: Wed, 25 May 2016 22:16:50 +0200 Subject: [PATCH] Error Correction --- conf/nginx.conf | 23 +++++++++++++++++++++++ scripts/install | 41 +++++++++++++++++++---------------------- 2 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 conf/nginx.conf diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..929d465 --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,23 @@ +location YNH_WWW_PATH { + + # Path to source + alias YNH_WWW_ALIAS ; + + # Example PHP configuration + index index.php; + + try_files $uri $uri/ index.php; + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + fastcgi_pass unix:/var/run/php5-fpm.sock; + + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; + } + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; +} diff --git a/scripts/install b/scripts/install index de2ce22..18e5056 100644 --- a/scripts/install +++ b/scripts/install @@ -6,26 +6,24 @@ set -eu # Define app app=phpsysinfo +# Retrieve arguments +domain=$YNH_APP_ARG_DOMAIN +path=$YNH_APP_ARG_PATH +admin=$YNH_APP_ARG_ADMIN +is_public=$YNH_APP_ARG_IS_PUBLIC + # Source YunoHost helpers . /usr/share/yunohost/helpers -# Retrieve arguments -domain=$1 -path=$2 -admin=$3 -is_public=$4 - # Save app settings -sudo yunohost app setting $app domain -v "$domain" -sudo yunohost app setting $app path -v "$path" -sudo yunohost app setting $app admin -v "$admin" -sudo yunohost app setting $app is_public -v "$is_public" +ynh_app_setting_set "$app" domain "$domain" +ynh_app_setting_set "$app" path "$path" +ynh_app_setting_set "$app" admin "$admin" +ynh_app_setting_set "$app" is_public "$is_public" # Check domain/path availability -sudo yunohost app checkurl $domain$path -a phpsysinfo -if [[ ! $? -eq 0 ]]; then - exit 1 -fi +sudo yunohost app checkurl "${domain}${path}" -a "$app" \ + || ynh_die "Path not available: ${domain}${path}" # Copy source files final_path=/var/www/$app @@ -39,17 +37,16 @@ cp $final_path/phpsysinfo.ini.new $final_path/phpsysinfo.ini sudo chown -R www-data: $final_path # Modify Nginx configuration file and copy it to Nginx conf directory -sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf -sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/phpsysinfo.conf +sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf +sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf # If app is public, add url to SSOWat conf as skipped_uris -if [ "$is_public" = "Yes" ]; +if [[ $is_public -eq 1 ]]; then # unprotected_uris allows SSO credentials to be passed anyway. - sudo yunohost app setting $app unprotected_uris -v "/" + ynh_app_setting_set "$app" unprotected_uris "/" fi -# Reload Nginx and regenerate SSOwat conf -sudo service nginx reload -sudo yunohost app ssowatconf +# Restart services +sudo service nginx reload \ No newline at end of file