diff --git a/.gitignore b/.gitignore index 783a4ae..8f144f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ *.sw[op] +.DS_Store diff --git a/conf/extra_php-fpm.conf b/conf/extra_php-fpm.conf deleted file mode 100644 index 940d2b8..0000000 --- a/conf/extra_php-fpm.conf +++ /dev/null @@ -1,4 +0,0 @@ -; Additional php.ini defines, specific to this pool of workers. - -php_admin_value[upload_max_filesize] = 10M -php_admin_value[post_max_size] = 10M diff --git a/conf/nginx.conf b/conf/nginx.conf index b8915c4..456a791 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -13,7 +13,7 @@ location __PATH__/ { try_files $uri $uri/ /index.php?$query_string; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock; fastcgi_index index.php; include fastcgi_params; diff --git a/manifest.toml b/manifest.toml index f12f2db..e9a4ab7 100644 --- a/manifest.toml +++ b/manifest.toml @@ -19,7 +19,8 @@ code = "https://github.com/LinkStackOrg/LinkStack" fund = "https://liberapay.com/LinkStack" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = true ldap = false @@ -77,6 +78,7 @@ ram.runtime = "50M" # This will provision/deprovision a unix system user [resources.install_dir] + group = "www-data:r-x" # This will create/remove the install dir as /var/www/$app # and store the corresponding setting $install_dir diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..3d7f008 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,17 +1,5 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 5242bf8..dbab68b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,19 +1,10 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." ### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs ### to be backuped and not an actual copy of any file. The actual backup that @@ -24,22 +15,22 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf" #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 86985d4..edaff8a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,22 +1,14 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # SPECIFIC MODIFICATIONS @@ -24,8 +16,6 @@ ynh_change_url_nginx_config # Nothing to do yet... -#================================================= -# GENERIC FINALISATION #================================================= # Nothing to do yet... @@ -34,4 +24,4 @@ ynh_change_url_nginx_config # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 1a15da6..cad0a8c 100755 --- a/scripts/install +++ b/scripts/install @@ -1,14 +1,10 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers +ynh_app_setting_set --key=php_upload_max_filesize --value=10M + admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) admin_fullname=$(ynh_user_get_info --username="$admin" --key=fullname) @@ -17,7 +13,7 @@ admin_fullname=$(ynh_user_get_info --username="$admin" --key=fullname) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression "Setting up source files..." ### `ynh_setup_source` is used to install an app from a zip or tar.gz file, ### downloaded from an upstream source, like a git repository. @@ -26,22 +22,23 @@ ynh_script_progression --message="Setting up source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" -# $install_dir will automatically be initialized with some decent +# $install_dir will automatically be initialized with some decent + # permission by default ... however, you may need to recursively reapply # ownership to all files such as after the ynh_setup_source step -chown -R $app:www-data "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" chmod o-rwx "$install_dir" -R #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated PHP-FPM config using the conf/php-fpm.conf or conf/extra_php-fpm.conf -ynh_add_fpm_config --usage=medium --footprint=low +ynh_config_add_phpfpm # Create a dedicated NGINX config using the conf/nginx.conf template -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # Automated installation process @@ -70,7 +67,7 @@ User::where('id', '1')->update(['role' => 'admin']); popd # End of installation -ynh_secure_remove $install_dir/INSTALLING +ynh_safe_rm $install_dir/INSTALLING ynh_write_var_in_file --file="$install_dir/.env" --key="APP_DEBUG" --value="false" ynh_write_var_in_file --file="$install_dir/.env" --key="APP_ENV" --value="production" ynh_write_var_in_file --file="$install_dir/.env" --key="NOTIFY_UPDATES" --value="false" @@ -79,4 +76,4 @@ ynh_write_var_in_file --file="$install_dir/.env" --key="NOTIFY_EVENTS" --value=" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 1d6d439..3b40290 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,27 +1,21 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." # This should be a symetric version of what happens in the install script -ynh_remove_nginx_config +ynh_config_remove_nginx -ynh_remove_fpm_config +ynh_config_remove_phpfpm #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index e52974e..5a2d71a 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -13,40 +7,38 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" +ynh_restore "$install_dir" + +# $install_dir will automatically be initialized with some decent -# $install_dir will automatically be initialized with some decent # permission by default ... however, you may need to recursively reapply # ownership to all files such as after the ynh_setup_source step -chown -R $app:www-data "$install_dir" - +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." # This should be a symetric version of what happens in the install script -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf" -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 +ynh_script_progression "Reloading NGINX web server and $app's service..." # Typically you only have either $app or php-fpm but not both at the same time... -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload +ynh_systemctl --service=php$php_version-fpm --action=reload -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 3805e3f..8e91a64 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,22 +1,14 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -upgrade_type=$(ynh_check_app_version_changed) +ynh_app_setting_set_default --key=php_upload_max_filesize --value=10M -#================================================= -# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -#ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +#ynh_script_progression "Ensuring downward compatibility..." # Nothing to do yet... @@ -26,25 +18,27 @@ upgrade_type=$(ynh_check_app_version_changed) # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] +# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed +if ynh_app_upstream_version_changed then # Enable maintenance mode while upgrading ynh_write_var_in_file --file="$install_dir/.env" --key="MAINTENANCE_MODE" --value="true" - ynh_script_progression --message="Upgrading source files..." --weight=1 + ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src # Keep .env and database.sqlite ! ynh_setup_source --dest_dir="$install_dir" --keep=".env database/database.sqlite" # Remove this file as the app is already installed - ynh_secure_remove $install_dir/INSTALLING + ynh_safe_rm $install_dir/INSTALLING fi -# $install_dir will automatically be initialized with some decent +# $install_dir will automatically be initialized with some decent + # permission by default ... however, you may need to recursively reapply # ownership to all files such as after the ynh_setup_source step -chown -R $app:www-data "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" chmod o-rwx "$install_dir" -R # Disable maintenance mode @@ -53,13 +47,13 @@ ynh_write_var_in_file --file="$install_dir/.env" --key="MAINTENANCE_MODE" --valu #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." # This should be a literal copypasta of what happened in the install's "System configuration" section -ynh_add_fpm_config --usage=medium --footprint=low +ynh_config_add_phpfpm -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) @@ -71,4 +65,4 @@ ynh_add_nginx_config # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed" diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/extra_files/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/patches/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op]