diff --git a/conf/nginx.conf b/conf/nginx.conf index eded69c..7a2ff02 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -16,7 +16,7 @@ location __PATH__ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; # If you don't use a dedicated fpm config for your app, # use a general fpm pool. diff --git a/manifest.json b/manifest.json index f494929..c4b3781 100644 --- a/manifest.json +++ b/manifest.json @@ -19,7 +19,7 @@ "multi_instance": true, "services": [ "nginx", - "php-fpm" + "php7.0-fpm" ], "arguments": { "install" : [ diff --git a/scripts/backup b/scripts/backup index 708b3c2..e8b2422 100644 --- a/scripts/backup +++ b/scripts/backup @@ -48,8 +48,8 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_backup "/etc/php/fpm/pool.d/$app.conf" -ynh_backup "/etc/php/fpm/conf.d/20-$app.ini" +ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_backup "/etc/php/7.0/fpm/conf.d/20-$app.ini" # Backup directory location for the app from where the script is executed and # which will be compressed afterward diff --git a/scripts/install b/scripts/install index 8df465c..1bbd556 100644 --- a/scripts/install +++ b/scripts/install @@ -55,7 +55,7 @@ ynh_app_setting_set $app is_public $is_public if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php-sqlite3 + ynh_install_app_dependencies php7.0-sqlite3 else ynh_install_app_dependencies php5-sqlite fi diff --git a/scripts/remove b/scripts/remove index 8df465c..079d4d3 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,109 +10,47 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE SCRIPT FAILURE +# LOAD SETTINGS #================================================= -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# Retrieve arguments -#================================================= - -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC - app=$YNH_APP_INSTANCE_NAME -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= - -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" - -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - -# Check web path availability -ynh_webpath_available $domain $path_url -# Register (book) web path -ynh_webpath_register $app $domain $path_url +domain=$(ynh_app_setting_get $app domain) +final_path=$(ynh_app_setting_get $app final_path) #================================================= -# STORE SETTINGS FROM MANIFEST +# REMOVE DEPENDENCIES #================================================= -ynh_app_setting_set $app path_url $path_url -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app is_public $is_public +# Remove metapackage and its dependencies +ynh_remove_app_dependencies #================================================= -# Install dependency to convert tracks to a readable format for the browser +# REMOVE APP MAIN DIR #================================================= -if [ "$(lsb_release --codename --short)" != "jessie" ] -then - ynh_install_app_dependencies php-sqlite3 -else - ynh_install_app_dependencies php5-sqlite -fi +# Remove the app directory securely +ynh_secure_remove "$final_path" #================================================= -# CREATE DEDICATED USER +# REMOVE NGINX CONFIGURATION #================================================= -# Create a system user -ynh_system_user_create $app +# Remove the dedicated nginx config +ynh_remove_nginx_config #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE +# REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_app_setting_set $app final_path $final_path -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +# Remove the dedicated php-fpm config +ynh_remove_fpm_config #================================================= -# Files owned by user app +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER #================================================= -sudo chown $app:$app $final_path -R -sudo chmod 755 $final_path -R - -#================================================= -# NGINX CONFIGURATION -#================================================= - -# Create a dedicated nginx config -ynh_add_nginx_config - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= - -# Create a dedicated php-fpm config -ynh_add_fpm_config - -#================================================= -# SETUP SSOWAT -#================================================= - -if [ $is_public -eq 0 ] -then # Remove the public access - ynh_app_setting_delete $app skipped_uris -fi -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set $app unprotected_uris "/" -fi - -#================================================= -# RELOAD NGINX -#================================================= - -systemctl reload nginx \ No newline at end of file +# Delete a system user +ynh_system_user_delete $app \ No newline at end of file diff --git a/scripts/restore b/scripts/restore index 46203de..61e3b2a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,11 @@ # IMPORT GENERIC HELPERS #================================================= +if [ ! -e _common.sh ]; then + # Get the _common.sh file if it's not in the current directory + cp ../settings/scripts/_common.sh ./_common.sh + chmod a+rx _common.sh +fi source _common.sh source /usr/share/yunohost/helpers @@ -17,102 +22,86 @@ source /usr/share/yunohost/helpers ynh_abort_if_errors #================================================= -# Retrieve arguments +# LOAD SETTINGS #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC - app=$YNH_APP_INSTANCE_NAME -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= - -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" - -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - -# Check web path availability -ynh_webpath_available $domain $path_url -# Register (book) web path -ynh_webpath_register $app $domain $path_url +domain=$(ynh_app_setting_get $app domain) +path_url=$(ynh_app_setting_get $app path) +final_path=$(ynh_app_setting_get $app final_path) #================================================= -# STORE SETTINGS FROM MANIFEST +# CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_app_setting_set $app path_url $path_url -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app is_public $is_public +ynh_webpath_available $domain $path_url \ + || ynh_die "Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die "There is already a directory: $final_path " #================================================= -# Install dependency to convert tracks to a readable format for the browser +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= + +ynh_restore_file "$final_path" + +#================================================= +# RECREATE THE DEDICATED USER +#================================================= + +# Create the dedicated user (if not existing) +ynh_system_user_create $app + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R $app:$app $final_path + +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +if [ "$(lsb_release --codename --short)" != "jessie" ] +then + ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" + ynh_restore_file "/etc/php/7.0/fpm/conf.d/20-$app.ini" +else + ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" + ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" +fi + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES #================================================= if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php-sqlite3 + ynh_install_app_dependencies php7.0-sqlite3 else ynh_install_app_dependencies php5-sqlite fi #================================================= -# CREATE DEDICATED USER +# GENERIC FINALIZATION #================================================= - -# Create a system user -ynh_system_user_create $app - +# RELOAD NGINX AND PHP-FPM #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= - -ynh_app_setting_set $app final_path $final_path -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" - -#================================================= -# Files owned by user app -#================================================= - -sudo chown $app:$app $final_path -R -sudo chmod 755 $final_path -R - -#================================================= -# NGINX CONFIGURATION -#================================================= - -# Create a dedicated nginx config -ynh_add_nginx_config - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= - -# Create a dedicated php-fpm config -ynh_add_fpm_config - -#================================================= -# SETUP SSOWAT -#================================================= - -if [ $is_public -eq 0 ] -then # Remove the public access - ynh_app_setting_delete $app skipped_uris -fi -# Make app public if necessary -if [ $is_public -eq 1 ] +if [ "$(lsb_release --codename --short)" != "jessie" ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set $app unprotected_uris "/" + systemctl reload php7.0-fpm +else + systemctl reload php5-fpm fi - -#================================================= -# RELOAD NGINX -#================================================= - systemctl reload nginx \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 46203de..3b5972a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,7 +55,7 @@ ynh_app_setting_set $app is_public $is_public if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php-sqlite3 + ynh_install_app_dependencies php7.0-sqlite3 else ynh_install_app_dependencies php5-sqlite fi