diff --git a/conf/nginx.conf b/conf/nginx.conf index 1b77e75..45d88b9 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,5 @@ -location PATHTOCHANGE { - alias ALIASTOCHANGE/; +location __PATH__ { + alias __FINALPATH__/; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } @@ -12,7 +12,7 @@ location PATHTOCHANGE { location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php5-fpm-NAMETOCHANGE.sock; + fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/scripts/install b/scripts/install index eea7b01..deb40d8 100644 --- a/scripts/install +++ b/scripts/install @@ -11,19 +11,19 @@ ynh_abort_if_errors # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN -path=$YNH_APP_ARG_PATH +path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME # Normalize the url path syntax -path=$(ynh_normalize_url_path "$path") +path=$(ynh_normalize_url_path "$path_url") # Check web path availability -ynh_webpath_available "$domain" "$path" +ynh_webpath_available "$domain" "$path_url" # Register (book) web path -ynh_webpath_register "$app" "$domain" "$path" +ynh_webpath_register "$app" "$domain" "$path_url" ynh_app_setting_set $app admin_user $admin @@ -73,18 +73,19 @@ ynh_replace_string "#DESTDIR#" "$final_path" "$phpfpm_conf" chown root: $phpfpm_conf chmod 644 $phpfpm_conf -finalnginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf" -cp ../conf/nginx.conf "$finalnginxconf" +#================================================= +# NGINX CONFIGURATION +#================================================= -# Modify Nginx configuration file and copy it to Nginx conf directory -ynh_replace_string "NAMETOCHANGE" "$app" "$finalnginxconf" -ynh_replace_string "PATHTOCHANGE" "$path" "$finalnginxconf" -ynh_replace_string "ALIASTOCHANGE" "$final_path" "$finalnginxconf" +# Create a dedicated nginx config +ynh_add_nginx_config -if [ "$path" == "/" ] +if [ "$path_url" == "/" ] then # ynh panel is only comptable with non-root installation ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf" + + ynh_store_file_checksum "$finalnginxconf" fi # Make app public or private diff --git a/scripts/restore b/scripts/restore index b43b5de..16eb6b2 100644 --- a/scripts/restore +++ b/scripts/restore @@ -17,12 +17,12 @@ dbuser=$app # Retrieve old app settings domain=$(ynh_app_setting_get "$app" domain) -path=$(ynh_app_setting_get "$app" path) +path_url=$(ynh_app_setting_get "$app" path) dbpass=$(ynh_app_setting_get "$app" mysqlpwd) final_path=$(ynh_app_setting_get "$app" final_path) # Check web path availability -ynh_webpath_available "$domain" "$path" +ynh_webpath_available "$domain" "$path_url" # Check destination directory test ! -e "$final_path" || ynh_die "This path already contains a folder" diff --git a/scripts/upgrade b/scripts/upgrade index a905bb6..023ba9c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,7 +20,7 @@ source /usr/share/yunohost/helpers # Retrieve settings domain=$(ynh_app_setting_get "$app" domain) -path=$(ynh_app_setting_get "$app" path) +path_url=$(ynh_app_setting_get "$app" path) admin=$(ynh_app_setting_get "$app" adminusername) email=$(ynh_user_get_info "$admin" mail) dbpass=$(ynh_app_setting_get "$app" mysqlpwd) @@ -80,18 +80,14 @@ ynh_replace_string "#DESTDIR#" "$final_path" "$phpfpm_conf" chown root: $phpfpm_conf chmod 644 $phpfpm_conf -finalnginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf" -cp ../conf/nginx.conf "$finalnginxconf" +ynh_add_nginx_config -# Modify Nginx configuration file and copy it to Nginx conf directory -ynh_replace_string "NAMETOCHANGE" "${app}" "$finalnginxconf" -ynh_replace_string "PATHTOCHANGE" "${path}" "$finalnginxconf" -ynh_replace_string "ALIASTOCHANGE" "${final_path}" "$finalnginxconf" - -if [ "$path" == "/" ] +if [ "$path_url" == "/" ] then # ynh panel is only comptable with non-root installation ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf" + + ynh_store_file_checksum "$finalnginxconf" fi # Make app public or private