From 9edb0645ddafd5dbf1f929ac58cee04628427908 Mon Sep 17 00:00:00 2001 From: Alex Budurovici Date: Sun, 23 Jun 2019 01:19:50 +0200 Subject: [PATCH 01/45] Update version to 4.7.17 --- README.md | 8 ++++---- conf/app.src | 4 ++-- manifest.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 709dd07..c109b6a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@

-# Firefly III v4.7.8 for YunoHost +# Firefly III v4.7.17 for YunoHost -[![Integration level](https://dash.yunohost.org/integration/Firefly-III.svg)](https://ci-apps.yunohost.org/jenkins/job/firefly-iii%20%28Community%29/lastBuild/consoleFull) +[![Integration level](https://dash.yunohost.org/integration/Firefly-III.svg)](https://ci-apps.yunohost.org/jenkins/job/firefly-iii%20%28Community%29/lastBuild/consoleFull) [![Install Firefly III with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=firefly-iii)

@@ -74,7 +74,7 @@ Everything is organised: #### Register a new domain and add it to YunoHost Firefly III requires a dedicated (sub)domain, so obtain one and add it using the YunoHost admin panel. **Domains -> Add domain**. As Firefly III uses the full domain and is installed on the root, you can create a subdomain such as firefly.domain.tld. Don't forget to update your DNS if you manage them manually. - + #### Install the Firefly III application Use the YunoHost admin panel to install Firefly III by entering the GitHub repo address in the custom app URL: @@ -85,7 +85,7 @@ https://github.com/YunoHost-Apps/firefly-iii_ynh Or use the command line to install the Firefly III app: -``` +``` $ yunohost app install https://github.com/YunoHost-Apps/firefly-iii_ynh ``` diff --git a/conf/app.src b/conf/app.src index 44dee3a..37980ee 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/firefly-iii/firefly-iii/archive/4.7.8.tar.gz -SOURCE_SUM=01e4a2ed6286afc44a98f85588dcb5f96f68ba82e6c3c482b924f23332ed289a +SOURCE_URL=https://github.com/firefly-iii/firefly-iii/archive/4.7.17.tar.gz +SOURCE_SUM=f070089d89f2ac5f27c1c2adaadc911d0779533978226606c5f6d8d69cf5d1db SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index d2b45b2..eb8b715 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Firefly III is a self-hosted financial manager.", "fr": "Firefly III est un gestionnaire de finances personnelles." }, - "version": "4.7.8", + "version": "4.7.17", "url": "https://firefly-iii.org/", "license": "GPL v3", "maintainer": { From 2b023235f230d1c1c17cd8f2da4a3e028285e8a6 Mon Sep 17 00:00:00 2001 From: Alex Budurovici Date: Sun, 23 Jun 2019 01:20:28 +0200 Subject: [PATCH 02/45] Conf white space cleanup --- conf/nginx.conf | 14 ++++++++------ conf/php-fpm.conf | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 923c5cd..1356ce1 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,14 +1,18 @@ location ^~ __PATH__ { alias __FINALPATH__/public/; -try_files $uri $uri/ @firefly; -index index.php index.htm index.html; - # Force https + + index index.php index.htm index.html; + + # Force https if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } + + try_files $uri $uri/ @firefly; location ~ \.php { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php7.2-fpm-__NAME__.sock; + fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; @@ -17,8 +21,6 @@ index index.php index.htm index.html; } } - location @firefly { - rewrite /(.*)$ /index.php?/$1 last; + rewrite /(.*)$ /index.php?/$1 last; } - diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index e051293..9f3942f 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -38,13 +38,13 @@ listen = /var/run/php7.2-fpm-__NAMETOCHANGE__.sock ; Set permissions for unix socket, if one is used. In Linux, read/write ; permissions must be set in order to allow connections from a web server. Many -; BSD-derived systems allow connections regardless of permissions. +; BSD-derived systems allow connections regardless of permissions. ; Default Values: user and group are set as the running user ; mode is set to 0660 listen.owner = www-data listen.group = www-data ;listen.mode = 0660 - + ; List of ipv4 addresses of FastCGI clients which are allowed to connect. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address @@ -117,7 +117,7 @@ pm.max_spare_servers = 3 ; Note: Used only when pm is set to 'ondemand' ; Default Value: 10s ;pm.process_idle_timeout = 10s; - + ; The number of requests each child process should execute before respawning. ; This can be useful to work around memory leaks in 3rd party libraries. For ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. @@ -170,7 +170,7 @@ pm.max_requests = 500 ; ; By default the status page only outputs short status. Passing 'full' in the ; query string will also return status for each pool process. -; Example: +; Example: ; http://www.foo.bar/status?full ; http://www.foo.bar/status?json&full ; http://www.foo.bar/status?html&full @@ -283,7 +283,7 @@ pm.max_requests = 500 ; - .... ; %p: PID of the child that serviced the request ; %P: PID of the parent of the child that serviced the request -; %q: the query string +; %q: the query string ; %Q: the '?' character if query string exists ; %r: the request URI (without the query string, see %q and %Q) ; %R: remote IP address @@ -298,40 +298,40 @@ pm.max_requests = 500 ; ; Default: "%R - %u %t \"%m %r\" %s" ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" - + ; The log file for slow requests ; Default Value: not set ; Note: slowlog is mandatory if request_slowlog_timeout is set slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log - + ; The timeout for serving a single request after which a PHP backtrace will be ; dumped to the 'slowlog' file. A value of '0s' means 'off'. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Default Value: 0 request_slowlog_timeout = 5s - + ; The timeout for serving a single request after which the worker process will ; be killed. This option should be used when the 'max_execution_time' ini option ; does not stop script execution for some reason. A value of '0' means 'off'. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Default Value: 0 request_terminate_timeout = 1d - + ; Set open file descriptor rlimit. ; Default Value: system defined value ;rlimit_files = 1024 - + ; Set max core size rlimit. ; Possible Values: 'unlimited' or an integer greater or equal to 0 ; Default Value: system defined value ;rlimit_core = 0 - + ; Chroot to this directory at the start. This value must be defined as an ; absolute path. When this value is not set, chroot is not used. ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one ; of its subdirectories. If the pool prefix is not set, the global prefix ; will be used instead. -; Note: chrooting is a great security feature and should be used whenever +; Note: chrooting is a great security feature and should be used whenever ; possible. However, all PHP paths will be relative to the chroot ; (error_log, sessions.save_path, ...). ; Default Value: not set @@ -356,7 +356,7 @@ catch_workers_output = yes ; Note: set an empty value to allow all extensions. ; Default Value: .php ;security.limit_extensions = .php .php3 .php4 .php5 - + ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from ; the current environment. ; Default Value: clean env @@ -370,7 +370,7 @@ catch_workers_output = yes ; overwrite the values previously defined in the php.ini. The directives are the ; same as the PHP SAPI: ; php_value/php_flag - you can set classic ini defines which can -; be overwritten from PHP call 'ini_set'. +; be overwritten from PHP call 'ini_set'. ; php_admin_value/php_admin_flag - these directives won't be overwritten by ; PHP call 'ini_set' ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. From 6d41822eab56dd85496dedec1216d812f727e755 Mon Sep 17 00:00:00 2001 From: Alex Budurovici Date: Sun, 23 Jun 2019 01:21:32 +0200 Subject: [PATCH 03/45] Update the upgrade script to match newer YUNOHOST demo --- scripts/upgrade | 175 +++++++++++++++++++++++++++++------------------- 1 file changed, 105 insertions(+), 70 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index c70e90e..2d4d560 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,46 +12,61 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -admin=$(ynh_app_setting_get $app admin) -is_public=$(ynh_app_setting_get $app is_public) -final_path=$(ynh_app_setting_get $app final_path) -db_name=$(ynh_app_setting_get $app db_name) -db_pwd=$(ynh_app_setting_get $app mysqlpwd) -random_key=$(ynh_app_setting_get $app random_key) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +admin=$(ynh_app_setting_get --app=$app --key=admin) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +random_key=$(ynh_app_setting_get --app=$app --key=random_key) + +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set $app is_public 1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set $app is_public 0 - is_public=0 + ynh_app_setting_set --app=$app --key=is_public --value=1 + is_public=1 + elif [ "$is_public" = "No" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=0 + is_public=0 fi # If db_name doesn't exist, create it if [ -z $db_name ]; then - db_name=$(ynh_sanitize_dbid $app) - ynh_app_setting_set $app db_name $db_name + db_name=$(ynh_sanitize_dbid --db_name=$app) + ynh_app_setting_set --app=$app --key=db_name --value=$db_name +fi + +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup + # restore it if the upgrade fails + ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -61,13 +76,12 @@ ynh_abort_if_errors #================================================= # Normalize the URL path syntax -path_url=$(ynh_normalize_url_path $path_url) +path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= -# INSTALL DEPENDENCIES +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= - -ynh_install_php7 +ynh_script_progression --message="Upgrading source files..." --time --weight=1 # Create a temporary directory tmpdir="$(mktemp -d)" @@ -79,26 +93,12 @@ mkdir -p "$final_path/storage/export/" cp -a "$final_path/storage/upload/" "$tmpdir/storage/upload/" cp -a "$final_path/storage/export/" "$tmpdir/storage/export/" -# Remove the app directory securely -ynh_secure_remove "$final_path" - -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= - -# If final_path doesn't exist, create it -if [ -z $final_path ]; then - final_path=/var/www/$app - ynh_app_setting_set $app final_path $final_path -fi - # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +ynh_setup_source --dest_dir="$final_path" - -rm -rf "$final_path/bootstrap/cache/*" -cp -a "$tmpdir/storage/upload/" "$final_path/storage/upload/" -cp -a "$tmpdir/storage/export/" "$final_path/storage/export/" +rm -rf "$final_path/bootstrap/cache/*" +cp -a "$tmpdir/storage/upload/" "$final_path/storage/upload/" +cp -a "$tmpdir/storage/export/" "$final_path/storage/export/" #remove tmp dir sudo rm -Rf "$tmpdir" @@ -106,42 +106,79 @@ sudo rm -Rf "$tmpdir" #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 -# Create a system user -ynh_system_user_create $app +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app #================================================= -# PHP-FPM 7.2 CONFIGURATION +# PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1 + +# Create a dedicated php-fpm config +ynh_add_fpm_config --phpversion=7.2 + +#================================================= +# STORE THE CONFIG FILE CHECKSUM #================================================= -# Create a dedicated php-fpm7.1 config -ynh_add_fpm7.2_config +### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. +### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. +ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum --file="$final_path/CONFIG_FILE" + +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + +#================================================= +# GENERIC FINALIZATION +#================================================= +# UPGRADE FAIL2BAN +#================================================= +ynh_script_progression --message="Reconfiguring fail2ban..." --time --weight=1 + +# Create a dedicated fail2ban config +ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" #================================================= # SPECIFIC UPGRADE #================================================= # Get the admin email -email=$(ynh_user_get_info $admin 'mail') +email=$(ynh_user_get_info --username=$admin --key='mail') # setup application config sudo cp ../conf/.env $final_path/.env #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_replace_string "random_key" "$random_key" "$final_path/.env" -ynh_replace_string "yunouser" "$db_name" "$final_path/.env" -ynh_replace_string "yunopass" "$db_pwd" "$final_path/.env" -ynh_replace_string "yunobase" "$db_name" "$final_path/.env" -ynh_replace_string "yunomail" "$email" "$final_path/.env" -ynh_replace_string "yunodomain" "$domain" "$final_path/.env" - +ynh_replace_string --match_string"random_key" --replace_string="$random_key" --file="$final_path/.env" +ynh_replace_string --match_string"yunouser" --replace_string="$db_name" --file="$final_path/.env" +ynh_replace_string --match_string"yunopass" --replace_string="$db_pwd" --file="$final_path/.env" +ynh_replace_string --match_string"yunobase" --replace_string="$db_name" --file="$final_path/.env" +ynh_replace_string --match_string"yunomail" --replace_string="$email" --file="$final_path/.env" +ynh_replace_string --match_string"yunodomain" --replace_string="$domain" --file="$final_path/.env" init_composer $final_path cd $final_path && sudo /usr/bin/php7.2 artisan migrate --env=production --force @@ -151,10 +188,9 @@ cd $final_path && sudo /usr/bin/php7.2 artisan firefly:verify cd $final_path && sudo /usr/bin/php7.2 artisan passport:install # Verify the checksum and backup the file if it's different -ynh_backup_if_checksum_is_different "$final_path/.env" +ynh_backup_if_checksum_is_different --file="$final_path/.env" # Recalculate and store the config file checksum into the app settings -ynh_store_file_checksum "$final_path/.env" - +ynh_store_file_checksum --file="$final_path/.env" #================================================= # GENERIC FINALIZATION @@ -162,32 +198,31 @@ ynh_store_file_checksum "$final_path/.env" # SECURE FILES AND DIRECTORIES #================================================= -# Set right permissions +# Set right permissions chown -R $app: $final_path #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 -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 "/" + # unprotected_uris allows SSO credentials to be passed anyway + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi #================================================= # RELOAD NGINX #================================================= -systemctl reload php7.2-fpm -systemctl reload nginx -# Set default php to php5 or php7.2 -if [ "$(lsb_release --codename --short)" == "jessie" ]; then - update-alternatives --set php /usr/bin/php5 -else - update-alternatives --set php /usr/bin/php7.0 -fi +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name=php7.2-fpm --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --time --last From 5b3bad7dd867a4c9c00a04cf749303d9b6b06d9b Mon Sep 17 00:00:00 2001 From: Alex Budurovici Date: Sun, 23 Jun 2019 01:22:06 +0200 Subject: [PATCH 04/45] Update all script to match newer YUNOHOST standards and use native methods to install php7.2 --- check_process | 62 ++++++++++++----------- scripts/_common.sh | 105 ++++++++++++++++++++------------------ scripts/backup | 40 +++++++++++---- scripts/change_url | 44 +++++++++------- scripts/install | 124 +++++++++++++++++++++++++++++++++------------ scripts/remove | 62 ++++++++++++++++++++--- scripts/restore | 111 +++++++++++++++++++++++++--------------- 7 files changed, 362 insertions(+), 186 deletions(-) diff --git a/check_process b/check_process index 8f1cf5c..428726a 100644 --- a/check_process +++ b/check_process @@ -4,36 +4,40 @@ # Move this file from check_process.default to check_process when you have filled it. ;; Test complet - ; Manifest - domain="domain.tld" (DOMAIN) - admin="john" (USER) - is_public=1 (PUBLIC|public=1|private=0) - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - backup_restore=1 - multi_instance=1 - incorrect_path=1 - port_already_use=0 - change_url=0 + ; Manifest + domain="domain.tld" (DOMAIN) + admin="john" (USER) + is_public=1 (PUBLIC|public=1|private=0) + ; Checks + pkg_linter=1 + setup_sub_dir=0 + setup_root=1 + setup_nourl=0 + setup_private=1 + setup_public=1 + upgrade=1 + backup_restore=1 + multi_instance=1 + incorrect_path=1 + port_already_use=0 + change_url=0 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto -# Level 4: - Level 4=0 -# Level 5: - Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 + Level 1=auto + Level 2=auto + Level 3=auto +# Level 4: + Level 4=0 +# Level 5: + Level 5=auto + Level 6=auto + Level 7=auto + Level 8=0 + Level 9=0 + Level 10=0 ;;; Options Email=anmol@datamol.org Notification=change +;;; Upgrade options + ; commit=CommitHash + name=Name and date of the commit. + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&password=pass& diff --git a/scripts/_common.sh b/scripts/_common.sh index c67634c..772e721 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,12 @@ #!/bin/bash +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="php7.2 php7.2-zip php7.2-fpm php7.2-mysql php7.2-xml php7.2-intl php7.2-mbstring php7.2-gd php7.2-curl php7.2-bcmath php7.2-opcache php7.2-ldap" + # ============= FUTURE YUNOHOST HELPER ============= # Delete a file checksum from the app settings # @@ -15,44 +22,46 @@ ynh_delete_file_checksum () { # Create a dedicated php-fpm config # # usage: ynh_add_fpm_config -ynh_add_fpm7.2_config () { - # Configure PHP-FPM 7.1 by default - ynh_secure_remove "/etc/php/7.1/fpm/pool.d/$app.conf" 2>&1 - ynh_secure_remove "/etc/php/7.1/fpm/conf.d/20-$app.ini" 2>&1 - local fpm_config_dir="/etc/php/7.2/fpm" - local fpm_service="php7.2-fpm" - ynh_app_setting_set $app fpm_config_dir "$fpm_config_dir" - ynh_app_setting_set $app fpm_service "$fpm_service" - finalphpconf="$fpm_config_dir/pool.d/$app.conf" - ynh_backup_if_checksum_is_different "$finalphpconf" - sudo cp ../conf/php-fpm.conf "$finalphpconf" - ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf" - ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf" - ynh_replace_string "__USER__" "$app" "$finalphpconf" - sudo chown root: "$finalphpconf" - ynh_store_file_checksum "$finalphpconf" - if [ -e "../conf/php-fpm.ini" ] - then - finalphpini="$fpm_config_dir/conf.d/20-$app.ini" - ynh_backup_if_checksum_is_different "$finalphpini" - sudo cp ../conf/php-fpm.ini "$finalphpini" - sudo chown root: "$finalphpini" - ynh_store_file_checksum "$finalphpini" - fi - sudo systemctl reload $fpm_service -} +# ynh_add_fpm7.2_config () { +# # Configure PHP-FPM 7.1 by default +# ynh_secure_remove "/etc/php/7.1/fpm/pool.d/$app.conf" 2>&1 +# ynh_secure_remove "/etc/php/7.1/fpm/conf.d/20-$app.ini" 2>&1 +# local fpm_config_dir="/etc/php/7.2/fpm" +# local fpm_service="php7.2-fpm" +# ynh_app_setting_set $app fpm_config_dir "$fpm_config_dir" +# ynh_app_setting_set $app fpm_service "$fpm_service" +# finalphpconf="$fpm_config_dir/pool.d/$app.conf" +# ynh_backup_if_checksum_is_different "$finalphpconf" +# sudo cp ../conf/php-fpm.conf "$finalphpconf" +# ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf" +# ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf" +# ynh_replace_string "__USER__" "$app" "$finalphpconf" +# sudo chown root: "$finalphpconf" +# ynh_store_file_checksum "$finalphpconf" + +# if [ -e "../conf/php-fpm.ini" ] +# then +# finalphpini="$fpm_config_dir/conf.d/20-$app.ini" +# ynh_backup_if_checksum_is_different "$finalphpini" +# sudo cp ../conf/php-fpm.ini "$finalphpini" +# sudo chown root: "$finalphpini" +# ynh_store_file_checksum "$finalphpini" +# fi +# sudo systemctl reload $fpm_service +# } # Remove the dedicated php-fpm config # # usage: ynh_remove_fpm7.1_config -ynh_remove_fpm7.2_config () { - local fpm_config_dir=$(ynh_app_setting_get $app fpm_config_dir) - local fpm_service=$(ynh_app_setting_get $app fpm_service) - ynh_secure_remove "$fpm_config_dir/pool.d/$app.conf" - ynh_secure_remove "$fpm_config_dir/conf.d/20-$app.ini" 2>&1 - sudo systemctl reload $fpm_service -} + +# ynh_remove_fpm7.2_config () { +# local fpm_config_dir=$(ynh_app_setting_get $app fpm_config_dir) +# local fpm_service=$(ynh_app_setting_get $app fpm_service) +# ynh_secure_remove "$fpm_config_dir/pool.d/$app.conf" +# ynh_secure_remove "$fpm_config_dir/conf.d/20-$app.ini" 2>&1 +# sudo systemctl reload $fpm_service +# } @@ -110,22 +119,22 @@ sudo_path () { # PHP7 helpers # -ynh_install_php7 () { +# ynh_install_php7 () { - ynh_package_update - ynh_package_install apt-transport-https --no-install-recommends +# ynh_package_update +# ynh_package_install apt-transport-https --no-install-recommends - wget -q -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg - echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.list +# wget -q -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg +# echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.list - ynh_package_update - ynh_install_app_dependencies php7.2 php7.2-zip php7.2-fpm php7.2-mysql php7.2-xml php7.2-intl php7.2-mbstring php7.2-gd php7.2-curl php7.2-bcmath php7.2-opcache php7.2-ldap - sudo update-alternatives --install /usr/bin/php php /usr/bin/php5 70 -} +# ynh_package_update +# ynh_install_app_dependencies php7.2 php7.2-zip php7.2-fpm php7.2-mysql php7.2-xml php7.2-intl php7.2-mbstring php7.2-gd php7.2-curl php7.2-bcmath php7.2-opcache php7.2-ldap +# sudo update-alternatives --install /usr/bin/php php /usr/bin/php5 70 +# } -ynh_remove_php7 () { - sudo rm -f /etc/apt/sources.list.d/php7.list - sudo apt-key del 4096R/89DF5277 - sudo apt-key del 2048R/11A06851 - ynh_remove_app_dependencies php7.2 php7.2-zip php7.2-fpm php7.2-mysql php7.2-xml php7.2-intl php7.2-mbstring php7.2-gd php7.2-curl php7.2-bcmath php7.2-opcache -} +# ynh_remove_php7 () { +# sudo rm -f /etc/apt/sources.list.d/php7.list +# sudo apt-key del 4096R/89DF5277 +# sudo apt-key del 2048R/11A06851 +# ynh_remove_app_dependencies php7.2 php7.2-zip php7.2-fpm php7.2-mysql php7.2-xml php7.2-intl php7.2-mbstring php7.2-gd php7.2-curl php7.2-bcmath php7.2-opcache +# } diff --git a/scripts/backup b/scripts/backup index 676dc2c..42f767f 100755 --- a/scripts/backup +++ b/scripts/backup @@ -24,39 +24,61 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -domain=$(ynh_app_setting_get $app domain) -db_name=$(ynh_app_setting_get $app db_name) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#================================================= -# STANDARD BACKUP STEPS #================================================= # BACKUP THE APP MAIN DIR #================================================= +ynh_script_progression --message="Backing up the main app directory..." --time --weight=1 -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1 -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1 -ynh_backup "/etc/php/7.2/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/7.2/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= +ynh_script_progression --message="Backing up the MySQL database..." --time --weight=1 -ynh_mysql_dump_db "$db_name" > db.sql +ynh_mysql_dump_db --database="$db_name" > db.sql +#================================================= +# BACKUP FAIL2BAN CONFIGURATION +#================================================= +ynh_script_progression --message="Backing up fail2ban configuration..." --time --weight=1 +ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" +ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= +ynh_script_progression --message="Backing up logrotate configuration..." --time --weight=1 +ynh_backup --src_path="/etc/logrotate.d/$app" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last diff --git a/scripts/change_url b/scripts/change_url index 51b3b36..689ff59 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -37,13 +37,13 @@ old_path=$(ynh_normalize_url_path $old_path) change_domain=0 if [ "$old_domain" != "$new_domain" ] then - change_domain=1 + change_domain=1 fi change_path=0 if [ "$old_path" != "$new_path" ] then - change_path=1 + change_path=1 fi #================================================= @@ -51,31 +51,32 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= +ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the path in the nginx config file if [ $change_path -eq 1 ] then - # Make a backup of the original nginx config file if modified - ynh_backup_if_checksum_is_different "$nginx_conf_path" - # Replace locations starting with old_path - # Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location) - ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path" - # Replace path in "return" directives - ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" - # Calculate and store the nginx config file checksum - ynh_store_file_checksum "$nginx_conf_path" + # Make a backup of the original nginx config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Replace locations starting with old_path + # Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location) + ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path" + # Replace path in "return" directives + ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" + # Calculate and store the nginx config file checksum + ynh_store_file_checksum --file="$nginx_conf_path" fi # Change the domain for nginx if [ $change_domain -eq 1 ] then - # Delete file checksum for the old conf file location - ynh_delete_file_checksum "$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location - ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" + # Delete file checksum for the old conf file location + ynh_delete_file_checksum --file="$nginx_conf_path" + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + # Store file checksum for the new config file location + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -84,10 +85,15 @@ fi # ... #================================================= -#================================================= -# GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --time --last diff --git a/scripts/install b/scripts/install index 0cbf8c3..8796e60 100755 --- a/scripts/install +++ b/scripts/install @@ -41,55 +41,57 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_script_progression --message="Validating installation parameters..." --time --weight=1 final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" +test ! -e "$final_path" || ynh_die --message="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 +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_script_progression --message="Storing installation settings..." --time --weight=1 -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app admin $admin -ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app random_key $random_key +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=admin --value=$admin +ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=random_key --value=$random_key #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Installing dependencies..." --time --weight=1 -ynh_install_php7 +# ynh_install_php7 +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE A MYSQL DATABASE #================================================= -# If your app uses a MySQL database, you can use these lines to bootstrap -# a database, an associated user and save the password in app settings +ynh_script_progression --message="Creating a MySQL database..." --time --weight=1 -db_name=$(ynh_sanitize_dbid $app) -ynh_app_setting_set $app db_name $db_name -ynh_mysql_setup_db $db_name $db_name +db_name=$(ynh_sanitize_dbid --db_name=$app) +db_user=$db_name +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Setting up source files..." --time --weight=1 -ynh_app_setting_set $app final_path $final_path +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 # Create a dedicated nginx config ynh_add_nginx_config @@ -97,16 +99,19 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Configuring system user..." --time --weight=1 # Create a system user -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # PHP-FPM 7.2 CONFIGURATION #================================================= +ynh_script_progression --message="Configuring php-fpm..." --time --weight=1 # Create a dedicated php-fpm7.1 config -ynh_add_fpm7.2_config +# ynh_add_fpm7.2_config +ynh_add_fpm_config --phpversion=7.2 #================================================= # SPECIFIC SETUP @@ -117,6 +122,7 @@ email=$(ynh_user_get_info $admin 'mail') # setup application config sudo cp ../conf/.env $final_path/.env + #================================================= # MODIFY A CONFIG FILE #================================================= @@ -137,11 +143,12 @@ db_name=$(ynh_sanitize_dbid $app) cd $final_path && sudo /usr/bin/php7.2 artisan -q :refresh --seed --force cd $final_path && sudo /usr/bin/php7.2 artisan passport:install --force ) + #================================================= # SETUP APPLICATION PERMISSIONS #================================================= -# Set right permissions +# Set right permissions chown -R $app: $final_path #================================================= @@ -154,26 +161,79 @@ ynh_store_file_checksum "$final_path/.env" #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 if [ $is_public -eq 0 ] then # Remove the public access - ynh_app_setting_delete $app skipped_uris + 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 "/" + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set $app unprotected_uris "/" fi +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Configuring log rotation..." --time --weight=1 + +### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app. +### Use this helper only if there is effectively a log file for this app. +### If you're not using this helper: +### - Remove the section "BACKUP LOGROTATE" in the backup script +### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script +### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script +### - And the section "SETUP LOGROTATE" in the upgrade script + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +### `yunohost service add` is a CLI yunohost command to add a service in the admin panel. +### You'll find the service in the 'services' section of YunoHost admin panel. +### This CLI command would be useless if the app does not have any services (systemd or sysvinit) +### If you're not using these lines: +### - You can remove these files in conf/. +### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script +### - As well as the section "ADVERTISE SERVICE IN ADMIN PANEL" in the restore script + +yunohost service add $app --log "/var/log/$app/$app.log" +# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added +#yunohost service add $app --description "$app daemon for XXX" --log "/var/log/$app/$app.log" + +#================================================= +# SETUP FAIL2BAN +#================================================= +ynh_script_progression --message="Configuring fail2ban..." --time --weight=1 + +# Create a dedicated fail2ban config +ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" + #================================================= # RELOAD NGINX #================================================= -systemctl reload php7.2-fpm -systemctl reload nginx +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 + +# systemctl reload php7.2-fpm +# systemctl reload nginx + +ynh_systemd_action --service_name=php7.2-fpm --action=reload +ynh_systemd_action --service_name=nginx --action=reload + # Set default php to php5 or php7.0 -if [ "$(lsb_release --codename --short)" == "jessie" ]; then - update-alternatives --set php /usr/bin/php5 -else - update-alternatives --set php /usr/bin/php7.0 -fi +# if [ "$(lsb_release --codename --short)" == "jessie" ]; then +# update-alternatives --set php /usr/bin/php5 +# else +# update-alternatives --set php /usr/bin/php7.0 +# fi + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of $app completed" --time --last diff --git a/scripts/remove b/scripts/remove index c04c43f..cd63178 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,31 +12,57 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -db_name=$(ynh_app_setting_get $app db_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name -final_path=$(ynh_app_setting_get $app final_path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +#================================================= +# STANDARD REMOVE +#================================================= +# REMOVE SERVICE FROM ADMIN PANEL +#================================================= + +# Remove a service from the admin panel, added by `yunohost service add` +if yunohost service status $app >/dev/null 2>&1 +then + ynh_script_progression --message="Removing $app service..." --time --weight=1 + yunohost service remove $app +fi #================================================= # REMOVE THE MYSQL DATABASE #================================================= +ynh_script_progression --message="Removing the MySQL database..." --time --weight=1 # Remove a database if it exists, along with the associated user -ynh_mysql_remove_db $db_user $db_name +ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name + +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --time --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= +ynh_script_progression --message="Removing app main directory..." --time --weight=1 # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1 # Remove the dedicated nginx config ynh_remove_nginx_config @@ -44,20 +70,40 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1 # Remove the dedicated php-fpm config -ynh_remove_fpm7.2_config +ynh_remove_fpm_config +# ynh_remove_fpm7.2_config #================================================= -# SPECIFIC REMOVE +# REMOVE LOGROTATE CONFIGURATION #================================================= +ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1 +# Remove the app-specific logrotate config +ynh_remove_logrotate + +#================================================= +# REMOVE FAIL2BAN CONFIGURATION +#================================================= +ynh_script_progression --message="Removing fail2ban configuration..." --time --weight=1 + +# Remove the dedicated fail2ban config +ynh_remove_fail2ban_config #================================================= # GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= +ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 # Delete a system user -ynh_system_user_delete $app +ynh_system_user_delete --username=$app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --time --last diff --git a/scripts/restore b/scripts/restore index 62668e9..4004350 100755 --- a/scripts/restore +++ b/scripts/restore @@ -7,10 +7,11 @@ #================================================= 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 + # 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 @@ -24,32 +25,25 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading settings..." --time --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) -db_name=$(ynh_app_setting_get $app db_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" +ynh_webpath_available --domain=$domain --path_url=$path_url \ +|| ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ - || ynh_die "There is already a directory: $final_path " - - -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= - -# Define and install dependencies -ynh_install_php7 +|| ynh_die --message="There is already a directory: $final_path "s #================================================= # STANDARD RESTORATION STEPS @@ -57,29 +51,23 @@ ynh_install_php7 # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" - - -#================================================= -# RESTORE THE MYSQL DATABASE -#================================================= - -db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_mysql_setup_db $db_name $db_name $db_pwd -ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_restore_file "$final_path" +ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 + +ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS @@ -92,7 +80,47 @@ chown -R $app: $final_path # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file "/etc/php/7.2/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/7.2/fpm/pool.d/$app.conf" + +#================================================= +# RESTORE FAIL2BAN CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the fail2ban configuration..." --time --weight=1 + +ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" +ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" +ynh_systemd_action --action=restart --service_name=fail2ban + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1 + +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add $app --log "/var/log/$app/$app.log" + +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # SPECIFIC UPGRADE @@ -109,12 +137,13 @@ cd $final_path && sudo /usr/bin/php7.2 artisan passport:install #================================================= # RELOAD NGINX AND PHP-FPM #================================================= +ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 -systemctl reload php7.2-fpm -systemctl reload nginx -# Set default php to php5 or php7.0 -if [ "$(lsb_release --codename --short)" == "jessie" ]; then - update-alternatives --set php /usr/bin/php5 -else - update-alternatives --set php /usr/bin/php7.0 -fi +ynh_systemd_action --service_name=php7.2-fpm --action=reload +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --time --last From 481780d690ace2b8f4621b31485ce791a776bec6 Mon Sep 17 00:00:00 2001 From: Alex Budurovici Date: Sun, 23 Jun 2019 01:32:31 +0200 Subject: [PATCH 05/45] Update yunohost version requirement --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index eb8b715..321166f 100644 --- a/manifest.json +++ b/manifest.json @@ -15,7 +15,7 @@ "url": "https://datamol.org" }, "requirements": { - "yunohost": ">= 2.7.2" + "yunohost": ">= 3.5.0" }, "multi_instance": true, "services": [ From 8077e55640c5506a6785a9c16d70b23f5b93e55d Mon Sep 17 00:00:00 2001 From: Alex Budurovici Date: Sun, 23 Jun 2019 01:49:21 +0200 Subject: [PATCH 06/45] Change to run composer as local user and not root --- scripts/_common.sh | 3 ++- scripts/install | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 772e721..d6b0ab2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -90,7 +90,8 @@ exec_composer() { shift 1 COMPOSER_HOME="${WORKDIR}/.composer" \ - sudo /usr/bin/php7.2 "${WORKDIR}/composer.phar" $@ \ + # sudo /usr/bin/php7.2 "${WORKDIR}/composer.phar" $@ \ + /usr/bin/php7.2 "${WORKDIR}/composer.phar" $@ \ -d "${WORKDIR}" --no-interaction } diff --git a/scripts/install b/scripts/install index 8796e60..304e79b 100755 --- a/scripts/install +++ b/scripts/install @@ -133,7 +133,7 @@ ynh_replace_string "yunobase" "$db_name" "$final_path/.env" ynh_replace_string "yunomail" "$email" "$final_path/.env" ynh_replace_string "yunodomain" "$domain" "$final_path/.env" -init_composer $final_path +init_composer $final_path $app ( cd $final_path && sudo /usr/bin/php7.2 artisan config:clear ) db_name=$(ynh_sanitize_dbid $app) From a904264002b4a8f3c68b3a4a4f465014820881a9 Mon Sep 17 00:00:00 2001 From: Alex Budurovici Date: Sun, 23 Jun 2019 01:53:34 +0200 Subject: [PATCH 07/45] Comment out fail2ban setup --- scripts/backup | 6 +++--- scripts/install | 7 ++++--- scripts/remove | 6 +++--- scripts/restore | 8 ++++---- scripts/upgrade | 6 +++--- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/scripts/backup b/scripts/backup index 42f767f..7ad24d2 100755 --- a/scripts/backup +++ b/scripts/backup @@ -63,10 +63,10 @@ ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= # BACKUP FAIL2BAN CONFIGURATION #================================================= -ynh_script_progression --message="Backing up fail2ban configuration..." --time --weight=1 +# ynh_script_progression --message="Backing up fail2ban configuration..." --time --weight=1 -ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" -ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" +# ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" +# ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" #================================================= # SPECIFIC BACKUP diff --git a/scripts/install b/scripts/install index 304e79b..5d3b91a 100755 --- a/scripts/install +++ b/scripts/install @@ -209,10 +209,11 @@ yunohost service add $app --log "/var/log/$app/$app.log" #================================================= # SETUP FAIL2BAN #================================================= -ynh_script_progression --message="Configuring fail2ban..." --time --weight=1 +# ynh_script_progression --message="Configuring fail2ban..." --time --weight=1 + +# # Create a dedicated fail2ban config +# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authentication failure. while reading response header from upstream, client: ,.*POST $path_url.*$" --max_retry=5 -# Create a dedicated fail2ban config -ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" #================================================= # RELOAD NGINX diff --git a/scripts/remove b/scripts/remove index cd63178..2df1b93 100755 --- a/scripts/remove +++ b/scripts/remove @@ -87,10 +87,10 @@ ynh_remove_logrotate #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= -ynh_script_progression --message="Removing fail2ban configuration..." --time --weight=1 +# ynh_script_progression --message="Removing fail2ban configuration..." --time --weight=1 -# Remove the dedicated fail2ban config -ynh_remove_fail2ban_config +# # Remove the dedicated fail2ban config +# ynh_remove_fail2ban_config #================================================= # GENERIC FINALIZATION diff --git a/scripts/restore b/scripts/restore index 4004350..7d49034 100755 --- a/scripts/restore +++ b/scripts/restore @@ -85,11 +85,11 @@ ynh_restore_file --origin_path="/etc/php/7.2/fpm/pool.d/$app.conf" #================================================= # RESTORE FAIL2BAN CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the fail2ban configuration..." --time --weight=1 +# ynh_script_progression --message="Restoring the fail2ban configuration..." --time --weight=1 -ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" -ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" -ynh_systemd_action --action=restart --service_name=fail2ban +# ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" +# ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" +# ynh_systemd_action --action=restart --service_name=fail2ban #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 2d4d560..9af9722 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -157,10 +157,10 @@ ynh_use_logrotate --non-append #================================================= # UPGRADE FAIL2BAN #================================================= -ynh_script_progression --message="Reconfiguring fail2ban..." --time --weight=1 +# ynh_script_progression --message="Reconfiguring fail2ban..." --time --weight=1 -# Create a dedicated fail2ban config -ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" +# # Create a dedicated fail2ban config +# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authentication failure. while reading response header from upstream, client: ,.*POST $path_url.*$" --max_retry=5 #================================================= # SPECIFIC UPGRADE From 328b9178c079c8aa67d906436d6c42d10057c661 Mon Sep 17 00:00:00 2001 From: Alex Budurovici Date: Sun, 23 Jun 2019 12:39:48 +0200 Subject: [PATCH 08/45] Cleanup obsolete helpers in common.sh --- scripts/_common.sh | 70 ---------------------------------------------- 1 file changed, 70 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index d6b0ab2..1e86d02 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -19,52 +19,6 @@ ynh_delete_file_checksum () { ynh_app_setting_delete $app $checksum_setting_name } -# Create a dedicated php-fpm config -# -# usage: ynh_add_fpm_config - -# ynh_add_fpm7.2_config () { -# # Configure PHP-FPM 7.1 by default -# ynh_secure_remove "/etc/php/7.1/fpm/pool.d/$app.conf" 2>&1 -# ynh_secure_remove "/etc/php/7.1/fpm/conf.d/20-$app.ini" 2>&1 -# local fpm_config_dir="/etc/php/7.2/fpm" -# local fpm_service="php7.2-fpm" -# ynh_app_setting_set $app fpm_config_dir "$fpm_config_dir" -# ynh_app_setting_set $app fpm_service "$fpm_service" -# finalphpconf="$fpm_config_dir/pool.d/$app.conf" -# ynh_backup_if_checksum_is_different "$finalphpconf" -# sudo cp ../conf/php-fpm.conf "$finalphpconf" -# ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf" -# ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf" -# ynh_replace_string "__USER__" "$app" "$finalphpconf" -# sudo chown root: "$finalphpconf" -# ynh_store_file_checksum "$finalphpconf" - -# if [ -e "../conf/php-fpm.ini" ] -# then -# finalphpini="$fpm_config_dir/conf.d/20-$app.ini" -# ynh_backup_if_checksum_is_different "$finalphpini" -# sudo cp ../conf/php-fpm.ini "$finalphpini" -# sudo chown root: "$finalphpini" -# ynh_store_file_checksum "$finalphpini" -# fi -# sudo systemctl reload $fpm_service -# } - -# Remove the dedicated php-fpm config -# -# usage: ynh_remove_fpm7.1_config - -# ynh_remove_fpm7.2_config () { -# local fpm_config_dir=$(ynh_app_setting_get $app fpm_config_dir) -# local fpm_service=$(ynh_app_setting_get $app fpm_service) -# ynh_secure_remove "$fpm_config_dir/pool.d/$app.conf" -# ynh_secure_remove "$fpm_config_dir/conf.d/20-$app.ini" 2>&1 -# sudo systemctl reload $fpm_service -# } - - - # Execute a command as another user # usage: exec_as USER COMMAND [ARG ...] exec_as() { @@ -115,27 +69,3 @@ init_composer() { sudo_path () { sudo env "PATH=$PATH" $@ } - -# -# PHP7 helpers -# - -# ynh_install_php7 () { - -# ynh_package_update -# ynh_package_install apt-transport-https --no-install-recommends - -# wget -q -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg -# echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.list - -# ynh_package_update -# ynh_install_app_dependencies php7.2 php7.2-zip php7.2-fpm php7.2-mysql php7.2-xml php7.2-intl php7.2-mbstring php7.2-gd php7.2-curl php7.2-bcmath php7.2-opcache php7.2-ldap -# sudo update-alternatives --install /usr/bin/php php /usr/bin/php5 70 -# } - -# ynh_remove_php7 () { -# sudo rm -f /etc/apt/sources.list.d/php7.list -# sudo apt-key del 4096R/89DF5277 -# sudo apt-key del 2048R/11A06851 -# ynh_remove_app_dependencies php7.2 php7.2-zip php7.2-fpm php7.2-mysql php7.2-xml php7.2-intl php7.2-mbstring php7.2-gd php7.2-curl php7.2-bcmath php7.2-opcache -# } From 32d6a496c8f0da9245abe91cea828f19b0ce7fae Mon Sep 17 00:00:00 2001 From: Alex Budurovici Date: Sun, 23 Jun 2019 12:40:35 +0200 Subject: [PATCH 09/45] Cleanup fail2ban comments --- scripts/backup | 8 -------- scripts/install | 9 --------- scripts/remove | 8 -------- scripts/restore | 9 --------- scripts/upgrade | 10 ---------- 5 files changed, 44 deletions(-) diff --git a/scripts/backup b/scripts/backup index 7ad24d2..4b08dcd 100755 --- a/scripts/backup +++ b/scripts/backup @@ -60,14 +60,6 @@ ynh_script_progression --message="Backing up the MySQL database..." --time --wei ynh_mysql_dump_db --database="$db_name" > db.sql -#================================================= -# BACKUP FAIL2BAN CONFIGURATION -#================================================= -# ynh_script_progression --message="Backing up fail2ban configuration..." --time --weight=1 - -# ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" -# ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" - #================================================= # SPECIFIC BACKUP #================================================= diff --git a/scripts/install b/scripts/install index 5d3b91a..67bb35a 100755 --- a/scripts/install +++ b/scripts/install @@ -206,15 +206,6 @@ yunohost service add $app --log "/var/log/$app/$app.log" # if using yunohost version 3.2 or more in the 'manifest.json', a description can be added #yunohost service add $app --description "$app daemon for XXX" --log "/var/log/$app/$app.log" -#================================================= -# SETUP FAIL2BAN -#================================================= -# ynh_script_progression --message="Configuring fail2ban..." --time --weight=1 - -# # Create a dedicated fail2ban config -# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authentication failure. while reading response header from upstream, client: ,.*POST $path_url.*$" --max_retry=5 - - #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/remove b/scripts/remove index 2df1b93..18b5612 100755 --- a/scripts/remove +++ b/scripts/remove @@ -84,14 +84,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --time -- # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE FAIL2BAN CONFIGURATION -#================================================= -# ynh_script_progression --message="Removing fail2ban configuration..." --time --weight=1 - -# # Remove the dedicated fail2ban config -# ynh_remove_fail2ban_config - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 7d49034..d330801 100755 --- a/scripts/restore +++ b/scripts/restore @@ -82,15 +82,6 @@ chown -R $app: $final_path ynh_restore_file --origin_path="/etc/php/7.2/fpm/pool.d/$app.conf" -#================================================= -# RESTORE FAIL2BAN CONFIGURATION -#================================================= -# ynh_script_progression --message="Restoring the fail2ban configuration..." --time --weight=1 - -# ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" -# ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" -# ynh_systemd_action --action=restart --service_name=fail2ban - #================================================= # SPECIFIC RESTORATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 9af9722..fcb09da 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -152,16 +152,6 @@ ynh_script_progression --message="Upgrading logrotate configuration..." --time - # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -#================================================= -# GENERIC FINALIZATION -#================================================= -# UPGRADE FAIL2BAN -#================================================= -# ynh_script_progression --message="Reconfiguring fail2ban..." --time --weight=1 - -# # Create a dedicated fail2ban config -# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authentication failure. while reading response header from upstream, client: ,.*POST $path_url.*$" --max_retry=5 - #================================================= # SPECIFIC UPGRADE #================================================= From da8e72d946214e261f4dd36ec8a9f0670147cabb Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Wed, 19 Feb 2020 17:30:25 +0100 Subject: [PATCH 10/45] Update package to 5.0.5 --- conf/app.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 37980ee..238ce9d 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://github.com/firefly-iii/firefly-iii/archive/4.7.17.tar.gz -SOURCE_SUM=f070089d89f2ac5f27c1c2adaadc911d0779533978226606c5f6d8d69cf5d1db +SOURCE_URL=https://github.com/firefly-iii/firefly-iii/archive/5.0.5.tar.gz +SOURCE_SUM=bb3c6ecbbc680c6ebbaab7439819a8c61a22b7911d21860c0d217bed655750c0 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= +SOURCE_FILENAME=firefly-iii-5.0.5.tar.gz From e1d133083bde4ea1d86253bc0f08b8a76084d542 Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Wed, 19 Feb 2020 17:32:54 +0100 Subject: [PATCH 11/45] Version update --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 321166f..7fd9fe9 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Firefly III is a self-hosted financial manager.", "fr": "Firefly III est un gestionnaire de finances personnelles." }, - "version": "4.7.17", + "version": "5.0.5", "url": "https://firefly-iii.org/", "license": "GPL v3", "maintainer": { From 290d847ba04f4b68d16b7dc3bd81d84aec8a1183 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 22 Feb 2020 01:13:49 +0100 Subject: [PATCH 12/45] Add support for version 5.0.5 --- conf/nginx.conf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 1356ce1..e0cc14b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,7 @@ location ^~ __PATH__ { - alias __FINALPATH__/public/; + alias __FINALPATH__/public; - index index.php index.htm index.html; + index index.php; # Force https if ($scheme = http) { @@ -9,11 +9,11 @@ location ^~ __PATH__ { } try_files $uri $uri/ @firefly; - location ~ \.php { + + location ~* \.php(?:$|/) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php7.2-fpm-__NAME__.sock; - - fastcgi_index index.php; + fastcgi_pass unix:/var/run/php7.3-fpm-__NAME__.sock; + fastcgi_param modHeadersAvailable true; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; @@ -22,5 +22,5 @@ location ^~ __PATH__ { } location @firefly { - rewrite /(.*)$ /index.php?/$1 last; + rewrite /__PATH__/(.*)$ /__PATH__/index.php?/$1 last; } From ba6f8069864cb8878769889f0a32e371005a8e6a Mon Sep 17 00:00:00 2001 From: root Date: Sat, 22 Feb 2020 01:16:38 +0100 Subject: [PATCH 13/45] Preleminary support for version 5.0.5 --- scripts/ynh_add_extra_apt_repos__3 | 295 +++++++++++++++++++++++++++++ scripts/ynh_composer | 52 +++++ scripts/ynh_install_php__3 | 82 ++++++++ 3 files changed, 429 insertions(+) create mode 100644 scripts/ynh_add_extra_apt_repos__3 create mode 100644 scripts/ynh_composer create mode 100644 scripts/ynh_install_php__3 diff --git a/scripts/ynh_add_extra_apt_repos__3 b/scripts/ynh_add_extra_apt_repos__3 new file mode 100644 index 0000000..0121777 --- /dev/null +++ b/scripts/ynh_add_extra_apt_repos__3 @@ -0,0 +1,295 @@ +#!/bin/bash + +# Pin a repository. +# +# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append] +# | arg: -p, --package - Packages concerned by the pin. Or all, *. +# | arg: -i, --pin - Filter for the pin. +# | arg: -p, --priority - Priority for the pin +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +# +# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning. +# +ynh_pin_repo () { + # Declare an array to define the options of this helper. + local legacy_args=pirna + declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append ) + local package + local pin + local priority + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + package="${package:-*}" + priority=${priority:-50} + name="${name:-$app}" + append=${append:-0} + + if [ $append -eq 1 ] + then + append="tee -a" + else + append="tee" + fi + + mkdir -p "/etc/apt/preferences.d" + echo "Package: $package +Pin: $pin +Pin-Priority: $priority" \ + | $append "/etc/apt/preferences.d/$name" +} + +# Add a repository. +# +# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append] +# | arg: -u, --uri - Uri of the repository. +# | arg: -s, --suite - Suite of the repository. +# | arg: -c, --component - Component of the repository. +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +# +# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable +# uri suite component +# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable +# +ynh_add_repo () { + # Declare an array to define the options of this helper. + local legacy_args=uscna + declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append ) + local uri + local suite + local component + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + append=${append:-0} + + if [ $append -eq 1 ] + then + append="tee -a" + else + append="tee" + fi + + mkdir -p "/etc/apt/sources.list.d" + # Add the new repo in sources.list.d + echo "deb $uri $suite $component" \ + | $append "/etc/apt/sources.list.d/$name.list" +} + +# Add an extra repository correctly, pin it and get the key. +# +# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append] +# | arg: -r, --repo - Complete url of the extra repository. +# | arg: -k, --key - url to get the public key. +# | arg: -p, --priority - Priority for the pin +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +ynh_install_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=rkpna + declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append ) + local repo + local key + local priority + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + append=${append:-0} + key=${key:-0} + priority=${priority:-} + + if [ $append -eq 1 ] + then + append="--append" + wget_append="tee -a" + else + append="" + wget_append="tee" + fi + + # Split the repository into uri, suite and components. + # Remove "deb " at the beginning of the repo. + repo="${repo#deb }" + + # Get the uri + local uri="$(echo "$repo" | awk '{ print $1 }')" + + # Get the suite + local suite="$(echo "$repo" | awk '{ print $2 }')" + + # Get the components + local component="${repo##$uri $suite }" + + # Add the repository into sources.list.d + ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append + + # Pin the new repo with the default priority, so it won't be used for upgrades. + # Build $pin from the uri without http and any sub path + local pin="${uri#*://}" + pin="${pin%%/*}" + # Set a priority only if asked + if [ -n "$priority" ] + then + priority="--priority=$priority" + fi + ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append + + # Get the public key for the repo + if [ -n "$key" ] + then + mkdir -p "/etc/apt/trusted.gpg.d" + wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null + fi + + # Update the list of package with the new repo + ynh_package_update +} + +# Remove an extra repository and the assiociated configuration. +# +# usage: ynh_remove_extra_repo [--name=name] +# | arg: -n, --name - Name for the files for this repo, $app as default value. +ynh_remove_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=n + declare -Ar args_array=( [n]=name= ) + local name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + + ynh_secure_remove "/etc/apt/sources.list.d/$name.list" + ynh_secure_remove "/etc/apt/preferences.d/$name" + ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg" + ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc" + + # Update the list of package to exclude the old repo + ynh_package_update +} + +# Install packages from an extra repository properly. +# +# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name] +# | arg: -r, --repo - Complete url of the extra repository. +# | arg: -p, --package - The packages to install from this extra repository +# | arg: -k, --key - url to get the public key. +# | arg: -n, --name - Name for the files for this repo, $app as default value. +ynh_install_extra_app_dependencies () { + # Declare an array to define the options of this helper. + local legacy_args=rpkn + declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= ) + local repo + local package + local key + local name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + key=${key:-0} + + # Set a key only if asked + if [ -n "$key" ] + then + key="--key=$key" + fi + # Add an extra repository for those packages + ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name + + # Install requested dependencies from this extra repository. + ynh_add_app_dependencies --package="$package" + + # Remove this extra repository after packages are installed + ynh_remove_extra_repo --name=$app +} + +#================================================= + +# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies + +# Define and install dependencies with a equivs control file +# This helper can/should only be called once per app +# +# usage: ynh_install_app_dependencies dep [dep [...]] +# | arg: dep - the package name to install in dependence +# You can give a choice between some package with this syntax : "dep1|dep2" +# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5" +# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5) +# +# Requires YunoHost version 2.6.4 or higher. +ynh_install_app_dependencies () { + local dependencies=$@ + dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')" + dependencies=${dependencies//|/ | } + local manifest_path="../manifest.json" + if [ ! -e "$manifest_path" ]; then + manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place + fi + + local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file. + if [ ${#version} -eq 0 ]; then + version="1.0" + fi + local dep_app=${app//_/-} # Replace all '_' by '-' + + # Handle specific versions + if [[ "$dependencies" =~ [\<=\>] ]] + then + # Replace version specifications by relationships syntax + # https://www.debian.org/doc/debian-policy/ch-relationships.html + # Sed clarification + # [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice. + # [\<=\>] matches < = or > + # \+ matches one or more occurence of the previous characters, for >= or >>. + # [^,]\+ matches all characters except ',' + # Ex: package>=1.0 will be replaced by package (>= 1.0) + dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')" + fi + + cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build +Section: misc +Priority: optional +Package: ${dep_app}-ynh-deps +Version: ${version} +Depends: ${dependencies} +Architecture: all +Description: Fake package for $app (YunoHost app) dependencies + This meta-package is only responsible of installing its dependencies. +EOF + ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \ + || ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies + rm /tmp/${dep_app}-ynh-deps.control + ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies" +} + +ynh_add_app_dependencies () { + # Declare an array to define the options of this helper. + local legacy_args=pr + declare -Ar args_array=( [p]=package= [r]=replace) + local package + local replace + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + replace=${replace:-0} + + local current_dependencies="" + if [ $replace -eq 0 ] + then + local dep_app=${app//_/-} # Replace all '_' by '-' + if ynh_package_is_installed --package="${dep_app}-ynh-deps" + then + current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) " + fi + + current_dependencies=${current_dependencies// | /|} + fi + + ynh_install_app_dependencies "${current_dependencies}${package}" +} + diff --git a/scripts/ynh_composer b/scripts/ynh_composer new file mode 100644 index 0000000..5eb341e --- /dev/null +++ b/scripts/ynh_composer @@ -0,0 +1,52 @@ +#!/bin/bash + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +# Execute a command with Composer +# +# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands" +# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +# | arg: -c, --commands - Commands to execute. +ynh_composer_exec () { + # Declare an array to define the options of this helper. + local legacy_args=vwc + declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= ) + local phpversion + local workdir + local commands + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" + phpversion="${phpversion:-7.0}" + + COMPOSER_HOME="$workdir/.composer" \ + php${phpversion} "$workdir/composer.phar" $commands \ + -d "$workdir" --quiet --no-interaction +} + +# Install and initialize Composer in the given directory +# +# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path] +# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +ynh_install_composer () { + # Declare an array to define the options of this helper. + local legacy_args=vw + declare -Ar args_array=( [v]=phpversion= [w]=workdir= ) + local phpversion + local workdir + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" + phpversion="${phpversion:-7.0}" + + curl -sS https://getcomposer.org/installer \ + | COMPOSER_HOME="$workdir/.composer" \ + php${phpversion} -- --quiet --install-dir="$workdir" \ + || ynh_die "Unable to install Composer." + + # update dependencies to create composer.lock + ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \ + || ynh_die "Unable to update core dependencies with Composer." +} diff --git a/scripts/ynh_install_php__3 b/scripts/ynh_install_php__3 new file mode 100644 index 0000000..bd19151 --- /dev/null +++ b/scripts/ynh_install_php__3 @@ -0,0 +1,82 @@ +#!/bin/bash + +# Install another version of php. +# +# usage: ynh_install_php --phpversion=phpversion [--package=packages] +# | arg: -v, --phpversion - Version of php to install. Can be one of 7.1, 7.2 or 7.3 +# | arg: -p, --package - Additionnal php packages to install +ynh_install_php () { + # Declare an array to define the options of this helper. + local legacy_args=vp + declare -Ar args_array=( [v]=phpversion= [p]=package= ) + local phpversion + local package + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + package=${package:-} + + # Store php_version into the config of this app + ynh_app_setting_set $app php_version $phpversion + + if [ "$phpversion" == "7.0" ] + then + ynh_die "Do not use ynh_install_php to install php7.0" + fi + + # Store the ID of this app and the version of php requested for it + echo "$YNH_APP_INSTANCE_NAME:$phpversion" | tee --append "/etc/php/ynh_app_version" + + # Add an extra repository for those packages + if [ ! -f "/etc/apt/sources.list.d/sury.list" ]; then + ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --priority=995 --name=extra_php_version + fi + + # Install requested dependencies from this extra repository. + # Install php-fpm first, otherwise php will install apache as a dependency. + ynh_add_app_dependencies --package="php${phpversion}-fpm" + ynh_add_app_dependencies --package="php$phpversion php${phpversion}-common $package" + + # Set php7.0 back as the default version for php-cli. + update-alternatives --set php /usr/bin/php7.0 + + # Remove this extra repository after packages are installed + if [ ! -f "/etc/apt/sources.list.d/sury.list" ]; then + ynh_remove_extra_repo --name=extra_php_version + fi + + # Advertise service in admin panel + yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log" +} + +ynh_remove_php () { + # Get the version of php used by this app + local phpversion=$(ynh_app_setting_get $app php_version) + + if [ "$phpversion" == "7.0" ] || [ -z "$phpversion" ] + then + if [ "$phpversion" == "7.0" ] + then + ynh_print_err "Do not use ynh_remove_php to install php7.0" + fi + return 0 + fi + + # Remove the line for this app + sed --in-place "/$YNH_APP_INSTANCE_NAME:$phpversion/d" "/etc/php/ynh_app_version" + + # If no other app uses this version of php, remove it. + if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version" + then + # Purge php dependences for this version. + ynh_package_autopurge "php$phpversion php${phpversion}-fpm php${phpversion}-common" + # Remove the service from the admin panel + yunohost service remove php${phpversion}-fpm + fi + + # If no other app uses alternate php versions, remove the extra repo for php + if [ ! -s "/etc/php/ynh_app_version" ] + then + ynh_secure_remove /etc/php/ynh_app_version + fi +} + From 16dedc5033b55fdc0034b74349ac2dc35ed20efa Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Sat, 22 Feb 2020 01:21:36 +0100 Subject: [PATCH 14/45] Changer version to 5.0.5 --- README.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c109b6a..434e69b 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@

-# Firefly III v4.7.17 for YunoHost +# Firefly III v5.0.5 for YunoHost [![Integration level](https://dash.yunohost.org/integration/Firefly-III.svg)](https://ci-apps.yunohost.org/jenkins/job/firefly-iii%20%28Community%29/lastBuild/consoleFull) [![Install Firefly III with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=firefly-iii)

-*Please note that this app will install PHP 7.2* +*Please note that this app will install PHP 7.3* ## Introduction "Firefly III" is a (self-hosted) manager for your personal finances. It can help you keep track of your expenses and income, so you can spend less and save more. Firefly III supports the use of budgets, categories and tags. It can import data from external sources and it has many neat financial reports available. You can [read all about it in the main repository](https://github.com/firefly-iii/firefly-iii) and in the [official documentation](https://firefly-iii.readthedocs.io/en/latest/). @@ -69,24 +69,20 @@ Everything is organised: ### Installation on YunoHost -- Firefly III requires a **dedicated (sub)domain** (must install under web root like **https://firefly.example.com/** not **https://example.com/firefly/** ) - -#### Register a new domain and add it to YunoHost - -Firefly III requires a dedicated (sub)domain, so obtain one and add it using the YunoHost admin panel. **Domains -> Add domain**. As Firefly III uses the full domain and is installed on the root, you can create a subdomain such as firefly.domain.tld. Don't forget to update your DNS if you manage them manually. +- Tested under a subdirectory on an existing domain #### Install the Firefly III application Use the YunoHost admin panel to install Firefly III by entering the GitHub repo address in the custom app URL: ``` -https://github.com/YunoHost-Apps/firefly-iii_ynh +https://github.com/dr41nU/Firefly-III_ynh ``` Or use the command line to install the Firefly III app: ``` -$ yunohost app install https://github.com/YunoHost-Apps/firefly-iii_ynh +$ yunohost app install https://github.com/dr41nU/Firefly-III_ynh ``` - The admin user should be a registered YunoHost user. From 0ec9acf071c04969fd2dead7ead511974145022e Mon Sep 17 00:00:00 2001 From: root Date: Sat, 22 Feb 2020 01:28:06 +0100 Subject: [PATCH 15/45] Upgrade to 5.0.5 --- conf/nginx.conf | 3 ++ conf/php-fpm.conf | 2 +- manifest.json | 10 +++++++ scripts/_common.sh | 3 +- scripts/install | 55 ++++++++++++++++++------------------- scripts/remove | 8 ++++++ scripts/ynh_composer~ | 64 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 115 insertions(+), 30 deletions(-) create mode 100644 scripts/ynh_composer~ diff --git a/conf/nginx.conf b/conf/nginx.conf index e0cc14b..1f18d7f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -19,6 +19,9 @@ location ^~ __PATH__ { fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; } + + include conf.d/yunohost_panel.conf.inc; + } location @firefly { diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 9f3942f..9bb8e4d 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -30,7 +30,7 @@ group = __USER__ ; specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php7.2-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php7.3-fpm-__NAMETOCHANGE__.sock ; Set listen(2) backlog. A value of '-1' means unlimited. ; Default Value: 128 (-1 on FreeBSD and OpenBSD) diff --git a/manifest.json b/manifest.json index 7fd9fe9..2115f97 100644 --- a/manifest.json +++ b/manifest.json @@ -34,6 +34,16 @@ }, "example": "example.com" }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for Firefly III", + "fr": "Choisissez un chemin pour Firefly III" + }, + "example": "/example", + "default": "/firefly" + }, { "name": "admin", "type": "user", diff --git a/scripts/_common.sh b/scripts/_common.sh index 1e86d02..a1c1d9e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,8 @@ #================================================= # dependencies used by the app -pkg_dependencies="php7.2 php7.2-zip php7.2-fpm php7.2-mysql php7.2-xml php7.2-intl php7.2-mbstring php7.2-gd php7.2-curl php7.2-bcmath php7.2-opcache php7.2-ldap" +phpversion="7.3" +pkg_dependencies="php${phpversion}-zip php${phpversion}-fpm php${phpversion}-mysql php${phpversion}-xml php${phpversion}-intl php${phpversion}-mbstring php${phpversion}-gd php${phpversion}-curl php${phpversion}-bcmath php${phpversion}-opcache php${phpversion}-ldap" # ============= FUTURE YUNOHOST HELPER ============= # Delete a file checksum from the app settings diff --git a/scripts/install b/scripts/install index 67bb35a..57baeae 100755 --- a/scripts/install +++ b/scripts/install @@ -7,6 +7,9 @@ #================================================= source _common.sh +source ynh_add_extra_apt_repos__3 +source ynh_install_php__3 +source ynh_composer source /usr/share/yunohost/helpers #================================================= @@ -21,7 +24,7 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -path_url="/" +path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC random_key=$(ynh_string_random 32) @@ -44,8 +47,8 @@ app=$YNH_APP_INSTANCE_NAME ynh_script_progression --message="Validating installation parameters..." --time --weight=1 final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +#mkdir $final_path # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -64,10 +67,9 @@ ynh_app_setting_set --app=$app --key=random_key --value=$random_key #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --time --weight=1 -# ynh_install_php7 -ynh_install_app_dependencies $pkg_dependencies +ynh_script_progression --message="Installing dependencies..." --time --weight=1 +ynh_install_php --phpversion="$phpversion" --package="$pkg_dependencies" #================================================= # CREATE A MYSQL DATABASE @@ -105,18 +107,22 @@ ynh_script_progression --message="Configuring system user..." --time --weight=1 ynh_system_user_create --username=$app #================================================= -# PHP-FPM 7.2 CONFIGURATION +# PHP-FPM 7.3 CONFIGURATION #================================================= + ynh_script_progression --message="Configuring php-fpm..." --time --weight=1 # Create a dedicated php-fpm7.1 config -# ynh_add_fpm7.2_config -ynh_add_fpm_config --phpversion=7.2 +#ynh_add_fpm7.2_config +ynh_add_fpm_config --phpversion="$phpversion" #================================================= # SPECIFIC SETUP #================================================= +# Install via composer +ynh_install_composer --phpversion="$phpversion" + # create a user email=$(ynh_user_get_info $admin 'mail') @@ -133,23 +139,26 @@ ynh_replace_string "yunobase" "$db_name" "$final_path/.env" ynh_replace_string "yunomail" "$email" "$final_path/.env" ynh_replace_string "yunodomain" "$domain" "$final_path/.env" -init_composer $final_path $app -( cd $final_path && sudo /usr/bin/php7.2 artisan config:clear ) +#init_composer $final_path $app -db_name=$(ynh_sanitize_dbid $app) +cd $final_path && php$phpversion artisan migrate:refresh --seed +cd $final_path && php$phpversion artisan firefly-iii:upgrade-database +cd $final_path && php$phpversion artisan passport:install +#( cd $final_path && sudo /usr/bin/php7.3 artisan config:clear ) # setup application config -( -cd $final_path && sudo /usr/bin/php7.2 artisan -q :refresh --seed --force -cd $final_path && sudo /usr/bin/php7.2 artisan passport:install --force -) +#( +#cd $final_path && sudo /usr/bin/php7.3 artisan -q :refresh --seed --force +#cd $final_path && sudo /usr/bin/php7.3 artisan passport:install --force +#) #================================================= # SETUP APPLICATION PERMISSIONS #================================================= # Set right permissions -chown -R $app: $final_path +chown -R $app:$app $final_path +chmod -R 775 ${final_path}/storage #================================================= # STORE THE CHECKSUM OF THE CONFIG FILE @@ -202,27 +211,17 @@ ynh_use_logrotate ### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script ### - As well as the section "ADVERTISE SERVICE IN ADMIN PANEL" in the restore script -yunohost service add $app --log "/var/log/$app/$app.log" +#yunohost service add $app --log "/var/log/$app/$app.log" # if using yunohost version 3.2 or more in the 'manifest.json', a description can be added -#yunohost service add $app --description "$app daemon for XXX" --log "/var/log/$app/$app.log" #================================================= # RELOAD NGINX #================================================= ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 -# systemctl reload php7.2-fpm -# systemctl reload nginx - -ynh_systemd_action --service_name=php7.2-fpm --action=reload +ynh_systemd_action --service_name=php7.3-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload -# Set default php to php5 or php7.0 -# if [ "$(lsb_release --codename --short)" == "jessie" ]; then -# update-alternatives --set php /usr/bin/php5 -# else -# update-alternatives --set php /usr/bin/php7.0 -# fi #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 18b5612..f93422f 100755 --- a/scripts/remove +++ b/scripts/remove @@ -76,6 +76,14 @@ ynh_script_progression --message="Removing php-fpm configuration..." --time --we ynh_remove_fpm_config # ynh_remove_fpm7.2_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --time --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_php "$phpversion" + #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= diff --git a/scripts/ynh_composer~ b/scripts/ynh_composer~ new file mode 100644 index 0000000..218dae2 --- /dev/null +++ b/scripts/ynh_composer~ @@ -0,0 +1,64 @@ +#!/bin/bash + +#================================================= +# COMMON VARIABLES +#================================================= + +# Package dependencies +pkg_dependencies="php-cli php-common php-intl php-json php-mcrypt php-pear php-auth-sasl php-mail-mime php-patchwork-utf8 php-net-smtp php-net-socket php-net-ldap2 php-net-ldap3 php-zip php-gd php-mbstring php-curl" + +# Plugins version +contextmenu_version=2.3 +automatic_addressbook_version=v0.4.3 +carddav_version=3.0.3 + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +# Execute a command with Composer +# +# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands" +# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +# | arg: -c, --commands - Commands to execute. +ynh_composer_exec () { + # Declare an array to define the options of this helper. + local legacy_args=vwc + declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= ) + local phpversion + local workdir + local commands + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" + phpversion="${phpversion:-7.0}" + + COMPOSER_HOME="$workdir/.composer" \ + php${phpversion} "$workdir/composer.phar" $commands \ + -d "$workdir" --quiet --no-interaction +} + +# Install and initialize Composer in the given directory +# +# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path] +# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +ynh_install_composer () { + # Declare an array to define the options of this helper. + local legacy_args=vw + declare -Ar args_array=( [v]=phpversion= [w]=workdir= ) + local phpversion + local workdir + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" + phpversion="${phpversion:-7.0}" + + curl -sS https://getcomposer.org/installer \ + | COMPOSER_HOME="$workdir/.composer" \ + php${phpversion} -- --quiet --install-dir="$workdir" \ + || ynh_die "Unable to install Composer." + + # update dependencies to create composer.lock + ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \ + || ynh_die "Unable to update core dependencies with Composer." +} From 68fb6a07181f6b76b5f7f013fe2f7b930dfe3e37 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 22 Feb 2020 15:33:30 +0100 Subject: [PATCH 16/45] Add LDAP support and remove script update --- conf/.env | 18 +++++++++--------- scripts/install | 2 ++ scripts/remove | 4 +++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/conf/.env b/conf/.env index d8cdf12..db10484 100644 --- a/conf/.env +++ b/conf/.env @@ -19,7 +19,7 @@ TZ=UTC # This variable must match your installation's external address but keep in mind that # it's only used on the command line as a fallback value. -APP_URL=http://localhost +APP_URL=https://yunoappurl # TRUSTED_PROXIES is a useful variable when using Docker and/or a reverse proxy. TRUSTED_PROXIES= @@ -109,7 +109,7 @@ USE_ENCRYPTION=false # and "adldap" for LDAP servers. # For full instructions on these settings please visit: # https://firefly-iii.readthedocs.io/en/latest/installation/authentication.html -LOGIN_PROVIDER=eloquent +LOGIN_PROVIDER=ldap # LDAP connection configuration # OpenLDAP, FreeIPA or ActiveDirectory @@ -117,10 +117,10 @@ ADLDAP_CONNECTION_SCHEME=OpenLDAP ADLDAP_AUTO_CONNECT=true # LDAP connection settings -ADLDAP_CONTROLLERS= +ADLDAP_CONTROLLERS=localhost ADLDAP_PORT=389 ADLDAP_TIMEOUT=5 -ADLDAP_BASEDN="" +ADLDAP_BASEDN="dc=yunohost,dc=org" ADLDAP_FOLLOW_REFFERALS=false ADLDAP_USE_SSL=false ADLDAP_USE_TLS=false @@ -128,8 +128,8 @@ ADLDAP_USE_TLS=false ADLDAP_ADMIN_USERNAME= ADLDAP_ADMIN_PASSWORD= -ADLDAP_ACCOUNT_PREFIX= -ADLDAP_ACCOUNT_SUFFIX= +ADLDAP_ACCOUNT_PREFIX="uid=" +ADLDAP_ACCOUNT_SUFFIX=",ou=users,dc=yunohost,dc=org" ADLDAP_ADMIN_ACCOUNT_PREFIX= ADLDAP_ADMIN_ACCOUNT_SUFFIX= @@ -137,15 +137,15 @@ ADLDAP_ADMIN_ACCOUNT_SUFFIX= ADLDAP_PASSWORD_SYNC=false ADLDAP_LOGIN_FALLBACK=false -ADLDAP_DISCOVER_FIELD=distinguishedname -ADLDAP_AUTH_FIELD=distinguishedname +ADLDAP_DISCOVER_FIELD=uid +ADLDAP_AUTH_FIELD=uid # Will allow SSO if your server provides an AUTH_USER field. WINDOWS_SSO_DISCOVER=samaccountname WINDOWS_SSO_KEY=AUTH_USER # field to sync as local username. -ADLDAP_SYNC_FIELD=userprincipalname +ADLDAP_SYNC_FIELD=uid # Leave the following configuration vars as is. # Unless you like to tinker and know what you're doing. diff --git a/scripts/install b/scripts/install index 57baeae..5ac950b 100755 --- a/scripts/install +++ b/scripts/install @@ -138,6 +138,8 @@ ynh_replace_string "yunopass" "$db_pwd" "$final_path/.env" ynh_replace_string "yunobase" "$db_name" "$final_path/.env" ynh_replace_string "yunomail" "$email" "$final_path/.env" ynh_replace_string "yunodomain" "$domain" "$final_path/.env" +ynh_replace_string "yunoappurl" "$domain$path_url" "$final_path/.env" + #init_composer $final_path $app diff --git a/scripts/remove b/scripts/remove index f93422f..adec8cb 100755 --- a/scripts/remove +++ b/scripts/remove @@ -7,6 +7,8 @@ #================================================= source _common.sh +source ynh_add_extra_apt_repos__3 +source ynh_install_php__3 source /usr/share/yunohost/helpers #================================================= @@ -82,7 +84,7 @@ ynh_remove_fpm_config ynh_script_progression --message="Removing dependencies..." --time --weight=1 # Remove metapackage and its dependencies -ynh_remove_php "$phpversion" +ynh_remove_php #================================================= # REMOVE LOGROTATE CONFIGURATION From 23be6e89a30d59c30b0139008ad8483454cddba4 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 22 Feb 2020 18:38:34 +0100 Subject: [PATCH 17/45] Update of remove process --- conf/nginx.conf | 2 +- scripts/remove | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 1f18d7f..507b369 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -25,5 +25,5 @@ location ^~ __PATH__ { } location @firefly { - rewrite /__PATH__/(.*)$ /__PATH__/index.php?/$1 last; + rewrite __PATH__/(.*)$ __PATH__/index.php?/$1 last; } diff --git a/scripts/remove b/scripts/remove index adec8cb..2344567 100755 --- a/scripts/remove +++ b/scripts/remove @@ -76,7 +76,6 @@ ynh_script_progression --message="Removing php-fpm configuration..." --time --we # Remove the dedicated php-fpm config ynh_remove_fpm_config -# ynh_remove_fpm7.2_config #================================================= # REMOVE DEPENDENCIES From b8acaaad24307747fe9fef207eea36e36f70068f Mon Sep 17 00:00:00 2001 From: root Date: Sat, 22 Feb 2020 21:29:53 +0100 Subject: [PATCH 18/45] Upgrade of upgrade script --- scripts/upgrade | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index fcb09da..dc1ef09 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,6 +7,9 @@ #================================================= source _common.sh +source ynh_add_extra_apt_repos__3 +source ynh_install_php__3 +source ynh_composer source /usr/share/yunohost/helpers #================================================= @@ -92,14 +95,31 @@ mkdir -p "$final_path/storage/upload/" mkdir -p "$final_path/storage/export/" cp -a "$final_path/storage/upload/" "$tmpdir/storage/upload/" cp -a "$final_path/storage/export/" "$tmpdir/storage/export/" +rm -Rf "$final_path" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" +ynh_install_composer --phpversion="$phpversion" +cd $final_path && php$phpversion artisan migrate:refresh --seed +cd $final_path && php$phpversion artisan firefly-iii:upgrade-database +cd $final_path && php$phpversion artisan passport:install + rm -rf "$final_path/bootstrap/cache/*" + +cd $final_path && php$phpversion artisan cache:clear +cd $final_path && php$phpversion artisan migrate --seed +cd $final_path && php$phpversion artisan firefly-iii:upgrade-database +cd $final_path && php$phpversion artisan passport:install +cd $final_path && php$phpversion artisan cache:clear + cp -a "$tmpdir/storage/upload/" "$final_path/storage/upload/" cp -a "$tmpdir/storage/export/" "$final_path/storage/export/" +# Set right permissions +chown -R $app:$app $final_path +chmod -R 775 ${final_path}/storage + #remove tmp dir sudo rm -Rf "$tmpdir" From 7003110e3cc6621d904bbc834d9e4375ebc73391 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 22 Feb 2020 21:31:17 +0100 Subject: [PATCH 19/45] minor change, cleaning comments --- scripts/install | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/install b/scripts/install index 5ac950b..2a98bc5 100755 --- a/scripts/install +++ b/scripts/install @@ -147,12 +147,6 @@ cd $final_path && php$phpversion artisan migrate:refresh --seed cd $final_path && php$phpversion artisan firefly-iii:upgrade-database cd $final_path && php$phpversion artisan passport:install -#( cd $final_path && sudo /usr/bin/php7.3 artisan config:clear ) -# setup application config -#( -#cd $final_path && sudo /usr/bin/php7.3 artisan -q :refresh --seed --force -#cd $final_path && sudo /usr/bin/php7.3 artisan passport:install --force -#) #================================================= # SETUP APPLICATION PERMISSIONS From 198100113143dcd87f09ce455cee8ed4be98405a Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Sun, 23 Feb 2020 01:59:42 +0100 Subject: [PATCH 20/45] Make it work for dedicated domain Make it work for installation on root on a dedicated domain --- conf/nginx.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 507b369..c17a3a0 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,7 +8,7 @@ location ^~ __PATH__ { rewrite ^ https://$server_name$request_uri? permanent; } - try_files $uri $uri/ @firefly; + try_files $uri $uri/ /$uri /$uri/ @firefly; location ~* \.php(?:$|/) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; @@ -17,7 +17,7 @@ location ^~ __PATH__ { include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } include conf.d/yunohost_panel.conf.inc; From a1606227961a0e544fda46e16c844bfdcdaa767e Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Sun, 23 Feb 2020 19:29:22 +0100 Subject: [PATCH 21/45] Make it work for both root and subpath --- conf/nginx.conf | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index c17a3a0..a05b09b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,6 @@ -location ^~ __PATH__ { - alias __FINALPATH__/public; +rewrite ^__PATH__$ __PATH__/ permanent; +location ^~ __PATH__/ { + alias __FINALPATH__/public/; index index.php; @@ -17,7 +18,7 @@ location ^~ __PATH__ { include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_FILENAME $request_filename; } include conf.d/yunohost_panel.conf.inc; From 3b5f630f18dbac8edeafa0c3b3b86999b6650dae Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Sun, 23 Feb 2020 21:10:31 +0100 Subject: [PATCH 22/45] Add restrictions and TODO --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 434e69b..11e4e5e 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ Everything is organised: ### Installation on YunoHost - Tested under a subdirectory on an existing domain +- Tested on amd64 and arm64 arches #### Install the Firefly III application @@ -85,5 +86,11 @@ Or use the command line to install the Firefly III app: $ yunohost app install https://github.com/dr41nU/Firefly-III_ynh ``` -- The admin user should be a registered YunoHost user. -- Important: when the installation is complete, you will have to visit the domain on which the app is installed and register the first account with the **primary email address of the Admin user given at the time of installayion** (otherwise you will not get admin rights). The registration will lock itself after the first registration. +- The admin user should be the first user to log into firefly +- SSO is not working yet +- You will probably be warned about missing locale from your system. Once you change the language to those corresponding to your system, the warning will desapear + +TODO + - [] make firefly admin user dependant of the user choosen at installation + - [] Make SSO Working + - [] Define default language accordingly to system one From 56511fa17ea4f76f14285dcbfa9d956bc4128c80 Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Sun, 23 Feb 2020 21:11:32 +0100 Subject: [PATCH 23/45] Tipos corrections --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 11e4e5e..08f6a19 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,6 @@ $ yunohost app install https://github.com/dr41nU/Firefly-III_ynh - You will probably be warned about missing locale from your system. Once you change the language to those corresponding to your system, the warning will desapear TODO - - [] make firefly admin user dependant of the user choosen at installation - - [] Make SSO Working - - [] Define default language accordingly to system one + - [ ] make firefly admin user dependant of the user choosen at installation + - [ ] Make SSO Working + - [ ] Define default language accordingly to system one From 0bcaa30920bf1d1fc349c7f44174c9cf123eae84 Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Mon, 24 Feb 2020 11:05:09 +0100 Subject: [PATCH 24/45] Revert installation process --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 08f6a19..a360619 100644 --- a/README.md +++ b/README.md @@ -77,13 +77,13 @@ Everything is organised: Use the YunoHost admin panel to install Firefly III by entering the GitHub repo address in the custom app URL: ``` -https://github.com/dr41nU/Firefly-III_ynh +https://github.com/YunoHost-Apps/firefly-iii_ynh ``` Or use the command line to install the Firefly III app: ``` -$ yunohost app install https://github.com/dr41nU/Firefly-III_ynh +$ yunohost app install https://github.com/YunoHost-Apps/firefly-iii_ynh ``` - The admin user should be the first user to log into firefly From 52e769a9e3389a4b324872543f2d25cbfa57bbf6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 25 Feb 2020 18:39:05 +0100 Subject: [PATCH 25/45] Clean up script and readme. --- README.md | 56 ++++----------------------------------------------- manifest.json | 2 +- 2 files changed, 5 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index a360619..1de78c2 100644 --- a/README.md +++ b/README.md @@ -19,54 +19,6 @@ - [Firefly III on GitHub](https://github.com/firefly-iii/firefly-iii) - [Demo 1](https://demo.firefly-iii.org/login), [Demo 2](http://www.softaculous.com/softaculous/demos/Firefly_III) -### Screenshots - -[![The index of Firefly III](https://firefly-iii.org/static/screenshots/4.7.4/tiny/index.png)](https://firefly-iii.org/static/screenshots/4.7.4/index.png) [![The account overview of Firefly III](https://firefly-iii.org/static/screenshots/4.7.4/tiny/account.png)](https://firefly-iii.org/static/screenshots/4.7.4/account.png) - -[![Overview of all budgets](https://firefly-iii.org/static/screenshots/4.7.4/tiny/budget.png)](https://firefly-iii.org/static/screenshots/4.7.4/budget.png) [![Overview of a category](https://firefly-iii.org/static/screenshots/4.7.4/tiny/category.png)](https://firefly-iii.org/static/screenshots/4.7.4/category.png) - -### Features - -Most importantly... - -* Firefly III runs on your own server, so you are fully in control of your data. It will not contact other sites or servers. -* You can import from over 2500 financial providers, in 55 countries when you enable the [Spectre API](http://firefly-iii.readthedocs.io/en/latest/import/spectre.html). -* You can import from [bunq](https://www.bunq.com/). -* You can import CSV files from practically any bank. -* Firefly III features an JSON REST API. - -But actually, it features: - -* [A double-entry bookkeeping system](http://firefly-iii.readthedocs.io/en/latest/concepts/transactions.html) -* You can store, edit and remove [withdrawals, deposits and transfers](http://firefly-iii.readthedocs.io/en/latest/concepts/transactions.html). This allows you full financial management -* You can manage different types of accounts - * [Asset](http://firefly-iii.readthedocs.io/en/latest/concepts/accounts.html) accounts - * Shared [asset accounts](http://firefly-iii.readthedocs.io/en/latest/concepts/accounts.html) ([household accounts](http://firefly-iii.readthedocs.io/en/latest/concepts/accounts.html)) - * Saving accounts - * Credit cards -* It's possible to create, change and manage money using [budgets](http://firefly-iii.readthedocs.io/en/latest/concepts/budgets.html) -* Organize transactions using [categories](http://firefly-iii.readthedocs.io/en/latest/concepts/categories.html) -* Save towards a goal using [piggy banks](http://firefly-iii.readthedocs.io/en/latest/advanced/piggies.html) -* Predict and anticipate [bills](http://firefly-iii.readthedocs.io/en/latest/advanced/bills.html) -* View income / expense [reports](http://firefly-iii.readthedocs.io/en/latest/advanced/reports.html) -* [Rule based](http://firefly-iii.readthedocs.io/en/latest/advanced/rules.html) transaction handling with the ability to create your own rules. -* The ability to [export data](http://firefly-iii.readthedocs.io/en/latest/import/export.html) so you can move to another system. -* The ability to [import data](http://firefly-iii.readthedocs.io/en/latest/import/csv.html) so you can move _from_ another system. -* Organize expenses using [tags](http://firefly-iii.readthedocs.io/en/latest/concepts/tags.html) -* 2 factor authentication for extra security 🔒 -* Supports any currency you want, including [crypto currencies](http://firefly-iii.readthedocs.io/en/latest/concepts/currencies.html) such as ₿itcoin and Ξthereum -* Lots of help text in case you don’t get it -* Translations into 10(!) languages, proudly powered by Crowdin - -Everything is organised: - -* Clear views that should show you how you're doing -* Easy navigation through your records -* Browse back and forth to see previous months or even years -* Lots of charts because we all love them -* Financial reporting showing you how well you are doing -* Lots of math because we all like math! - ### Installation on YunoHost - Tested under a subdirectory on an existing domain @@ -86,11 +38,11 @@ Or use the command line to install the Firefly III app: $ yunohost app install https://github.com/YunoHost-Apps/firefly-iii_ynh ``` -- The admin user should be the first user to log into firefly +- The admin user should be the first user to log into Firefly III - SSO is not working yet - You will probably be warned about missing locale from your system. Once you change the language to those corresponding to your system, the warning will desapear TODO - - [ ] make firefly admin user dependant of the user choosen at installation - - [ ] Make SSO Working - - [ ] Define default language accordingly to system one + - [ ] Make Firefly III admin user dependant of the user choosen at installation + - [ ] Make SSO work + - [ ] Define default language according to system language diff --git a/manifest.json b/manifest.json index 2115f97..a6d6409 100644 --- a/manifest.json +++ b/manifest.json @@ -20,7 +20,7 @@ "multi_instance": true, "services": [ "nginx", - "php7.2-fpm", + "php7.3-fpm", "mysql" ], "arguments": { From b02f4a2b5bac35c698f10c7c9d26fe381b83eaaa Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Sun, 8 Mar 2020 10:45:18 +0100 Subject: [PATCH 26/45] Backup file added by error --- scripts/ynh_composer~ | 64 ------------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 scripts/ynh_composer~ diff --git a/scripts/ynh_composer~ b/scripts/ynh_composer~ deleted file mode 100644 index 218dae2..0000000 --- a/scripts/ynh_composer~ +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -#================================================= -# COMMON VARIABLES -#================================================= - -# Package dependencies -pkg_dependencies="php-cli php-common php-intl php-json php-mcrypt php-pear php-auth-sasl php-mail-mime php-patchwork-utf8 php-net-smtp php-net-socket php-net-ldap2 php-net-ldap3 php-zip php-gd php-mbstring php-curl" - -# Plugins version -contextmenu_version=2.3 -automatic_addressbook_version=v0.4.3 -carddav_version=3.0.3 - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -# Execute a command with Composer -# -# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands" -# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. -# | arg: -c, --commands - Commands to execute. -ynh_composer_exec () { - # Declare an array to define the options of this helper. - local legacy_args=vwc - declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= ) - local phpversion - local workdir - local commands - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - workdir="${workdir:-$final_path}" - phpversion="${phpversion:-7.0}" - - COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} "$workdir/composer.phar" $commands \ - -d "$workdir" --quiet --no-interaction -} - -# Install and initialize Composer in the given directory -# -# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path] -# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. -ynh_install_composer () { - # Declare an array to define the options of this helper. - local legacy_args=vw - declare -Ar args_array=( [v]=phpversion= [w]=workdir= ) - local phpversion - local workdir - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - workdir="${workdir:-$final_path}" - phpversion="${phpversion:-7.0}" - - curl -sS https://getcomposer.org/installer \ - | COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} -- --quiet --install-dir="$workdir" \ - || ynh_die "Unable to install Composer." - - # update dependencies to create composer.lock - ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \ - || ynh_die "Unable to update core dependencies with Composer." -} From 4ec78d1aae9df5ce24967de8692e5589cbdacf57 Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Sun, 8 Mar 2020 10:48:24 +0100 Subject: [PATCH 27/45] Change php version for conf backup --- scripts/backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index 4b08dcd..69c295a 100755 --- a/scripts/backup +++ b/scripts/backup @@ -51,7 +51,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1 -ynh_backup --src_path="/etc/php/7.2/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE From ff14f259873a29bfb6304cae82deeac76342b0cf Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Tue, 10 Mar 2020 21:16:31 +0100 Subject: [PATCH 28/45] Update version --- conf/app.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 238ce9d..50df31d 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://github.com/firefly-iii/firefly-iii/archive/5.0.5.tar.gz -SOURCE_SUM=bb3c6ecbbc680c6ebbaab7439819a8c61a22b7911d21860c0d217bed655750c0 +SOURCE_URL=https://github.com/firefly-iii/firefly-iii/archive/5.1.0.tar.gz +SOURCE_SUM=3e20da603780f218fbd0b1354ad975fb2f7af37b216a015b1c3a4a1783a06233 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=firefly-iii-5.0.5.tar.gz +SOURCE_FILENAME=firefly-iii-5.1.0.tar.gz From f6ad1fe87018b2949dd2720f702cbcc256861cb8 Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Tue, 10 Mar 2020 21:19:25 +0100 Subject: [PATCH 29/45] Update version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1de78c2..1a98f32 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

-# Firefly III v5.0.5 for YunoHost +# Firefly III v5.1.0 for YunoHost [![Integration level](https://dash.yunohost.org/integration/Firefly-III.svg)](https://ci-apps.yunohost.org/jenkins/job/firefly-iii%20%28Community%29/lastBuild/consoleFull) From 0e11d861c417b7aab1aa6796fd0e090fb5bc16d0 Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Tue, 10 Mar 2020 21:24:25 +0100 Subject: [PATCH 30/45] Update version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index a6d6409..c7f61f1 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Firefly III is a self-hosted financial manager.", "fr": "Firefly III est un gestionnaire de finances personnelles." }, - "version": "5.0.5", + "version": "5.1.0", "url": "https://firefly-iii.org/", "license": "GPL v3", "maintainer": { From 4cd1db38d1a073363fa0a584597057b48667a608 Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Tue, 10 Mar 2020 22:34:02 +0100 Subject: [PATCH 31/45] Update pakage version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index c7f61f1..595182e 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Firefly III is a self-hosted financial manager.", "fr": "Firefly III est un gestionnaire de finances personnelles." }, - "version": "5.1.0", + "version": "5.1.0~ynh1", "url": "https://firefly-iii.org/", "license": "GPL v3", "maintainer": { From 057bb96b9a54b6f0949bcd18d795d9130536bdba Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Thu, 12 Mar 2020 21:56:25 +0100 Subject: [PATCH 32/45] Revert package version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 595182e..c7f61f1 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Firefly III is a self-hosted financial manager.", "fr": "Firefly III est un gestionnaire de finances personnelles." }, - "version": "5.1.0~ynh1", + "version": "5.1.0", "url": "https://firefly-iii.org/", "license": "GPL v3", "maintainer": { From 5d4f979104bc93826abb1ab559567b0a68370761 Mon Sep 17 00:00:00 2001 From: Kayou Date: Fri, 27 Mar 2020 16:58:43 +0100 Subject: [PATCH 33/45] fix restore --- scripts/restore | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/restore b/scripts/restore index d330801..d006fdb 100755 --- a/scripts/restore +++ b/scripts/restore @@ -117,11 +117,11 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" # SPECIFIC UPGRADE #================================================= init_composer $final_path -cd $final_path && sudo /usr/bin/php7.2 artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/php7.2 artisan cache:clear -cd $final_path && sudo /usr/bin/php7.2 artisan firefly:upgrade-database -cd $final_path && sudo /usr/bin/php7.2 artisan firefly:verify -cd $final_path && sudo /usr/bin/php7.2 artisan passport:install +cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force +cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear +cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database +cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify +cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install #================================================= # GENERIC FINALIZATION From 1154a742155742a4d92eedf7b2255ec93e1976b7 Mon Sep 17 00:00:00 2001 From: Kayou Date: Fri, 27 Mar 2020 17:07:04 +0100 Subject: [PATCH 34/45] Update restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index d006fdb..815fddc 100755 --- a/scripts/restore +++ b/scripts/restore @@ -130,7 +130,7 @@ cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install #================================================= ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 -ynh_systemd_action --service_name=php7.2-fpm --action=reload +ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= From 0bf76c15ee3aed060d45b23c9c952d0c6a7cb595 Mon Sep 17 00:00:00 2001 From: Kayou Date: Fri, 27 Mar 2020 17:08:06 +0100 Subject: [PATCH 35/45] Update restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 815fddc..d8aafe4 100755 --- a/scripts/restore +++ b/scripts/restore @@ -80,7 +80,7 @@ chown -R $app: $final_path # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file --origin_path="/etc/php/7.2/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORATION From e03cc8c117a8e6213064aaf26a566e0ed5774191 Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Sun, 12 Apr 2020 15:23:40 +0200 Subject: [PATCH 36/45] Missing var for php version --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 2a98bc5..cf31f87 100755 --- a/scripts/install +++ b/scripts/install @@ -215,7 +215,7 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 -ynh_systemd_action --service_name=php7.3-fpm --action=reload +ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload From b6761491df86f4064c1f004054015b81265a3015 Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Sun, 12 Apr 2020 15:26:28 +0200 Subject: [PATCH 37/45] Missing version var for call to php --- scripts/restore | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/restore b/scripts/restore index d330801..ca24598 100755 --- a/scripts/restore +++ b/scripts/restore @@ -80,7 +80,7 @@ chown -R $app: $final_path # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file --origin_path="/etc/php/7.2/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORATION @@ -117,11 +117,11 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" # SPECIFIC UPGRADE #================================================= init_composer $final_path -cd $final_path && sudo /usr/bin/php7.2 artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/php7.2 artisan cache:clear -cd $final_path && sudo /usr/bin/php7.2 artisan firefly:upgrade-database -cd $final_path && sudo /usr/bin/php7.2 artisan firefly:verify -cd $final_path && sudo /usr/bin/php7.2 artisan passport:install +cd $final_path && sudo /usr/bin/$phpversion artisan migrate --env=production --force +cd $final_path && sudo /usr/bin/$phpversion artisan cache:clear +cd $final_path && sudo /usr/bin/$phpversion firefly:upgrade-database +cd $final_path && sudo /usr/bin/$phpversion firefly:verify +cd $final_path && sudo /usr/bin/$phpversion passport:install #================================================= # GENERIC FINALIZATION @@ -130,7 +130,7 @@ cd $final_path && sudo /usr/bin/php7.2 artisan passport:install #================================================= ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 -ynh_systemd_action --service_name=php7.2-fpm --action=reload +ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= From 913bc219e55544abb1977128cf9ea03a84274593 Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Sun, 12 Apr 2020 15:28:36 +0200 Subject: [PATCH 38/45] Version update --- conf/app.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 50df31d..79e2204 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://github.com/firefly-iii/firefly-iii/archive/5.1.0.tar.gz -SOURCE_SUM=3e20da603780f218fbd0b1354ad975fb2f7af37b216a015b1c3a4a1783a06233 +SOURCE_URL=https://github.com/firefly-iii/firefly-iii/archive/5.2.0.tar.gz +SOURCE_SUM=136ddb92167a63e0eeafc91c18d12285e28533f18441b80a683d69cb1ea05115 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=firefly-iii-5.1.0.tar.gz +SOURCE_FILENAME=firefly-iii-5.2.0.tar.gz From 8eac138ecec3b610971f746d0354c890b86181e3 Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Sun, 12 Apr 2020 15:33:21 +0200 Subject: [PATCH 39/45] Upgrade version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a98f32..cecbc34 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

-# Firefly III v5.1.0 for YunoHost +# Firefly III v5.2.0 for YunoHost [![Integration level](https://dash.yunohost.org/integration/Firefly-III.svg)](https://ci-apps.yunohost.org/jenkins/job/firefly-iii%20%28Community%29/lastBuild/consoleFull) From 3ca8ddc29b6e182b6660bed99fe3bdcd9745822c Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Sun, 12 Apr 2020 15:33:48 +0200 Subject: [PATCH 40/45] Upgrade version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index c7f61f1..7b3df92 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Firefly III is a self-hosted financial manager.", "fr": "Firefly III est un gestionnaire de finances personnelles." }, - "version": "5.1.0", + "version": "5.2.0", "url": "https://firefly-iii.org/", "license": "GPL v3", "maintainer": { From afc6e45719dbef8b7f3f8f5eaebabcb073764233 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 9 May 2020 16:27:05 +0200 Subject: [PATCH 41/45] Merge Kay0u updates --- scripts/restore | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/restore b/scripts/restore index ca24598..d8aafe4 100755 --- a/scripts/restore +++ b/scripts/restore @@ -117,11 +117,11 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" # SPECIFIC UPGRADE #================================================= init_composer $final_path -cd $final_path && sudo /usr/bin/$phpversion artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/$phpversion artisan cache:clear -cd $final_path && sudo /usr/bin/$phpversion firefly:upgrade-database -cd $final_path && sudo /usr/bin/$phpversion firefly:verify -cd $final_path && sudo /usr/bin/$phpversion passport:install +cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force +cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear +cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database +cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify +cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install #================================================= # GENERIC FINALIZATION @@ -130,7 +130,7 @@ cd $final_path && sudo /usr/bin/$phpversion passport:install #================================================= ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 -ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload +ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= From 44257785f34e5bfdfad4801f6ffc373467909d11 Mon Sep 17 00:00:00 2001 From: dr41nU <50152843+dr41nU@users.noreply.github.com> Date: Sat, 9 May 2020 16:55:48 +0200 Subject: [PATCH 42/45] Fix php version --- scripts/upgrade | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index dc1ef09..7d7fb3b 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -152,7 +152,7 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1 # Create a dedicated php-fpm config -ynh_add_fpm_config --phpversion=7.2 +ynh_add_fpm_config --phpversion=$phpversion #================================================= # STORE THE CONFIG FILE CHECKSUM @@ -191,11 +191,11 @@ ynh_replace_string --match_string"yunomail" --replace_string="$email" --f ynh_replace_string --match_string"yunodomain" --replace_string="$domain" --file="$final_path/.env" init_composer $final_path -cd $final_path && sudo /usr/bin/php7.2 artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/php7.2 artisan cache:clear -cd $final_path && sudo /usr/bin/php7.2 artisan firefly:upgrade-database -cd $final_path && sudo /usr/bin/php7.2 artisan firefly:verify -cd $final_path && sudo /usr/bin/php7.2 artisan passport:install +cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force +cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear +cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database +cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify +cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install # Verify the checksum and backup the file if it's different ynh_backup_if_checksum_is_different --file="$final_path/.env" @@ -229,7 +229,7 @@ fi ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 ynh_systemd_action --service_name=nginx --action=reload -ynh_systemd_action --service_name=php7.2-fpm --action=reload +ynh_systemd_action --service_name=php$phpversion-fpm --action=reload #================================================= # END OF SCRIPT From af0886c7f4841fc7b74fa56e7a0d09a448dfe286 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 9 May 2020 20:48:44 +0200 Subject: [PATCH 43/45] Fix upgrade script --- scripts/restore.orig | 152 +++++++++++++++++++++++++++++++++++++++++++ scripts/restore~ | 152 +++++++++++++++++++++++++++++++++++++++++++ scripts/upgrade | 21 +++--- 3 files changed, 317 insertions(+), 8 deletions(-) create mode 100755 scripts/restore.orig create mode 100755 scripts/restore~ diff --git a/scripts/restore.orig b/scripts/restore.orig new file mode 100755 index 0000000..3a978b5 --- /dev/null +++ b/scripts/restore.orig @@ -0,0 +1,152 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# 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 + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading settings..." --time --weight=1 + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name + +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 + +ynh_webpath_available --domain=$domain --path_url=$path_url \ +|| ynh_die --message="Path not available: ${domain}${path_url}" +test ! -d $final_path \ +|| ynh_die --message="There is already a directory: $final_path "s + +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= + +ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 + +ynh_restore_file --origin_path="$final_path" + +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R $app: $final_path + +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1 + +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add $app --log "/var/log/$app/$app.log" + +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + +#================================================= +# SPECIFIC UPGRADE +#================================================= +init_composer $final_path +<<<<<<< HEAD +cd $final_path && sudo /usr/bin/$phpversion artisan migrate --env=production --force +cd $final_path && sudo /usr/bin/$phpversion artisan cache:clear +cd $final_path && sudo /usr/bin/$phpversion firefly:upgrade-database +cd $final_path && sudo /usr/bin/$phpversion firefly:verify +cd $final_path && sudo /usr/bin/$phpversion passport:install +======= +cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force +cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear +cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database +cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify +cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install +>>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX AND PHP-FPM +#================================================= +ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 + +<<<<<<< HEAD +ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload +======= +ynh_systemd_action --service_name=php$phpversion-fpm --action=reload +>>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --time --last diff --git a/scripts/restore~ b/scripts/restore~ new file mode 100755 index 0000000..3a978b5 --- /dev/null +++ b/scripts/restore~ @@ -0,0 +1,152 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# 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 + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading settings..." --time --weight=1 + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name + +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 + +ynh_webpath_available --domain=$domain --path_url=$path_url \ +|| ynh_die --message="Path not available: ${domain}${path_url}" +test ! -d $final_path \ +|| ynh_die --message="There is already a directory: $final_path "s + +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= + +ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 + +ynh_restore_file --origin_path="$final_path" + +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R $app: $final_path + +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1 + +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add $app --log "/var/log/$app/$app.log" + +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + +#================================================= +# SPECIFIC UPGRADE +#================================================= +init_composer $final_path +<<<<<<< HEAD +cd $final_path && sudo /usr/bin/$phpversion artisan migrate --env=production --force +cd $final_path && sudo /usr/bin/$phpversion artisan cache:clear +cd $final_path && sudo /usr/bin/$phpversion firefly:upgrade-database +cd $final_path && sudo /usr/bin/$phpversion firefly:verify +cd $final_path && sudo /usr/bin/$phpversion passport:install +======= +cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force +cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear +cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database +cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify +cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install +>>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX AND PHP-FPM +#================================================= +ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 + +<<<<<<< HEAD +ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload +======= +ynh_systemd_action --service_name=php$phpversion-fpm --action=reload +>>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --time --last diff --git a/scripts/upgrade b/scripts/upgrade index dc1ef09..f16bc97 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -152,7 +152,7 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1 # Create a dedicated php-fpm config -ynh_add_fpm_config --phpversion=7.2 +ynh_add_fpm_config --phpversion="$phpversion" #================================================= # STORE THE CONFIG FILE CHECKSUM @@ -175,6 +175,9 @@ ynh_use_logrotate --non-append #================================================= # SPECIFIC UPGRADE #================================================= +# Install via composer +ynh_install_composer --phpversion="$phpversion" + # Get the admin email email=$(ynh_user_get_info --username=$admin --key='mail') @@ -190,12 +193,13 @@ ynh_replace_string --match_string"yunobase" --replace_string="$db_name" --f ynh_replace_string --match_string"yunomail" --replace_string="$email" --file="$final_path/.env" ynh_replace_string --match_string"yunodomain" --replace_string="$domain" --file="$final_path/.env" -init_composer $final_path -cd $final_path && sudo /usr/bin/php7.2 artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/php7.2 artisan cache:clear -cd $final_path && sudo /usr/bin/php7.2 artisan firefly:upgrade-database -cd $final_path && sudo /usr/bin/php7.2 artisan firefly:verify -cd $final_path && sudo /usr/bin/php7.2 artisan passport:install +#init_composer $final_path + +cd $final_path && php$phpversion artisan migrate --env=production --force +cd $final_path && php$phpversion artisan cache:clear +cd $final_path && php$phpversion artisan firefly:upgrade-database +cd $final_path && php$phpversion artisan firefly:verify +cd $final_path && php$phpversion artisan passport:install # Verify the checksum and backup the file if it's different ynh_backup_if_checksum_is_different --file="$final_path/.env" @@ -210,6 +214,7 @@ ynh_store_file_checksum --file="$final_path/.env" # Set right permissions chown -R $app: $final_path +chmod -R 775 ${final_path}/storage #================================================= # SETUP SSOWAT @@ -228,8 +233,8 @@ fi #================================================= ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload -ynh_systemd_action --service_name=php7.2-fpm --action=reload #================================================= # END OF SCRIPT From 8d3a467dd1619fb714eabaee65c2f3842fa95476 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 9 May 2020 21:17:00 +0200 Subject: [PATCH 44/45] Command order correction --- scripts/restore.orig | 152 ------------------------ scripts/restore~ | 152 ------------------------ scripts/upgrade.orig | 271 ------------------------------------------- scripts/upgrade~ | 271 ------------------------------------------- 4 files changed, 846 deletions(-) delete mode 100755 scripts/restore.orig delete mode 100755 scripts/restore~ delete mode 100755 scripts/upgrade.orig delete mode 100755 scripts/upgrade~ diff --git a/scripts/restore.orig b/scripts/restore.orig deleted file mode 100755 index 3a978b5..0000000 --- a/scripts/restore.orig +++ /dev/null @@ -1,152 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC START -#================================================= -# 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 - -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --time --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 - -ynh_webpath_available --domain=$domain --path_url=$path_url \ -|| ynh_die --message="Path not available: ${domain}${path_url}" -test ! -d $final_path \ -|| ynh_die --message="There is already a directory: $final_path "s - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= - -ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 - -ynh_restore_file --origin_path="$final_path" - -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions on app files -chown -R $app: $final_path - -#================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# RESTORE THE MYSQL DATABASE -#================================================= -ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1 - -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql - -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= - -yunohost service add $app --log "/var/log/$app/$app.log" - -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - -#================================================= -# SPECIFIC UPGRADE -#================================================= -init_composer $final_path -<<<<<<< HEAD -cd $final_path && sudo /usr/bin/$phpversion artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/$phpversion artisan cache:clear -cd $final_path && sudo /usr/bin/$phpversion firefly:upgrade-database -cd $final_path && sudo /usr/bin/$phpversion firefly:verify -cd $final_path && sudo /usr/bin/$phpversion passport:install -======= -cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear -cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database -cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify -cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install ->>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf - -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX AND PHP-FPM -#================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 - -<<<<<<< HEAD -ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload -======= -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ->>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf -ynh_systemd_action --service_name=nginx --action=reload - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Restoration completed for $app" --time --last diff --git a/scripts/restore~ b/scripts/restore~ deleted file mode 100755 index 3a978b5..0000000 --- a/scripts/restore~ +++ /dev/null @@ -1,152 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC START -#================================================= -# 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 - -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --time --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 - -ynh_webpath_available --domain=$domain --path_url=$path_url \ -|| ynh_die --message="Path not available: ${domain}${path_url}" -test ! -d $final_path \ -|| ynh_die --message="There is already a directory: $final_path "s - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= - -ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 - -ynh_restore_file --origin_path="$final_path" - -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions on app files -chown -R $app: $final_path - -#================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# RESTORE THE MYSQL DATABASE -#================================================= -ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1 - -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql - -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= - -yunohost service add $app --log "/var/log/$app/$app.log" - -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - -#================================================= -# SPECIFIC UPGRADE -#================================================= -init_composer $final_path -<<<<<<< HEAD -cd $final_path && sudo /usr/bin/$phpversion artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/$phpversion artisan cache:clear -cd $final_path && sudo /usr/bin/$phpversion firefly:upgrade-database -cd $final_path && sudo /usr/bin/$phpversion firefly:verify -cd $final_path && sudo /usr/bin/$phpversion passport:install -======= -cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear -cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database -cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify -cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install ->>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf - -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX AND PHP-FPM -#================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 - -<<<<<<< HEAD -ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload -======= -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ->>>>>>> 87fccba099c4ee4e22f4988fd409a8b760b3bfaf -ynh_systemd_action --service_name=nginx --action=reload - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Restoration completed for $app" --time --last diff --git a/scripts/upgrade.orig b/scripts/upgrade.orig deleted file mode 100755 index 98cde32..0000000 --- a/scripts/upgrade.orig +++ /dev/null @@ -1,271 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source _common.sh -source ynh_add_extra_apt_repos__3 -source ynh_install_php__3 -source ynh_composer -source /usr/share/yunohost/helpers - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -admin=$(ynh_app_setting_get --app=$app --key=admin) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -random_key=$(ynh_app_setting_get --app=$app --key=random_key) - -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 - -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 - elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - -# If db_name doesn't exist, create it -if [ -z $db_name ]; then - db_name=$(ynh_sanitize_dbid --db_name=$app) - ynh_app_setting_set --app=$app --key=db_name --value=$db_name -fi - -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/var/www/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path -fi - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK THE PATH -#================================================= - -# Normalize the URL path syntax -path_url=$(ynh_normalize_url_path --path_url=$path_url) - -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= -ynh_script_progression --message="Upgrading source files..." --time --weight=1 - -# Create a temporary directory -tmpdir="$(mktemp -d)" -# Backup the config file in the temp dir -mkdir -p "$tmpdir/storage/upload" -mkdir -p "$tmpdir/storage/export" -mkdir -p "$final_path/storage/upload/" -mkdir -p "$final_path/storage/export/" -cp -a "$final_path/storage/upload/" "$tmpdir/storage/upload/" -cp -a "$final_path/storage/export/" "$tmpdir/storage/export/" -rm -Rf "$final_path" - -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" -ynh_install_composer --phpversion="$phpversion" -cd $final_path && php$phpversion artisan migrate:refresh --seed -cd $final_path && php$phpversion artisan firefly-iii:upgrade-database -cd $final_path && php$phpversion artisan passport:install - - -rm -rf "$final_path/bootstrap/cache/*" - -cd $final_path && php$phpversion artisan cache:clear -cd $final_path && php$phpversion artisan migrate --seed -cd $final_path && php$phpversion artisan firefly-iii:upgrade-database -cd $final_path && php$phpversion artisan passport:install -cd $final_path && php$phpversion artisan cache:clear - -cp -a "$tmpdir/storage/upload/" "$final_path/storage/upload/" -cp -a "$tmpdir/storage/export/" "$final_path/storage/export/" - -# Set right permissions -chown -R $app:$app $final_path -chmod -R 775 ${final_path}/storage - -#remove tmp dir -sudo rm -Rf "$tmpdir" - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 - -# Create a dedicated nginx config -ynh_add_nginx_config - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1 - -# Create a dedicated php-fpm config -<<<<<<< HEAD -ynh_add_fpm_config --phpversion="$phpversion" -||||||| merged common ancestors -ynh_add_fpm_config --phpversion=7.2 -======= -ynh_add_fpm_config --phpversion=$phpversion ->>>>>>> 44257785f34e5bfdfad4801f6ffc373467909d11 - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= - -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$final_path/CONFIG_FILE" - -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - -#================================================= -# SPECIFIC UPGRADE -#================================================= -# Install via composer -ynh_install_composer --phpversion="$phpversion" - -# Get the admin email -email=$(ynh_user_get_info --username=$admin --key='mail') - -# setup application config -sudo cp ../conf/.env $final_path/.env -#================================================= -# MODIFY A CONFIG FILE -#================================================= -ynh_replace_string --match_string"random_key" --replace_string="$random_key" --file="$final_path/.env" -ynh_replace_string --match_string"yunouser" --replace_string="$db_name" --file="$final_path/.env" -ynh_replace_string --match_string"yunopass" --replace_string="$db_pwd" --file="$final_path/.env" -ynh_replace_string --match_string"yunobase" --replace_string="$db_name" --file="$final_path/.env" -ynh_replace_string --match_string"yunomail" --replace_string="$email" --file="$final_path/.env" -ynh_replace_string --match_string"yunodomain" --replace_string="$domain" --file="$final_path/.env" - -<<<<<<< HEAD -#init_composer $final_path - -cd $final_path && php$phpversion artisan migrate --env=production --force -cd $final_path && php$phpversion artisan cache:clear -cd $final_path && php$phpversion artisan firefly:upgrade-database -cd $final_path && php$phpversion artisan firefly:verify -cd $final_path && php$phpversion artisan passport:install -||||||| merged common ancestors -init_composer $final_path -cd $final_path && sudo /usr/bin/php7.2 artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/php7.2 artisan cache:clear -cd $final_path && sudo /usr/bin/php7.2 artisan firefly:upgrade-database -cd $final_path && sudo /usr/bin/php7.2 artisan firefly:verify -cd $final_path && sudo /usr/bin/php7.2 artisan passport:install -======= -init_composer $final_path -cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear -cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database -cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify -cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install ->>>>>>> 44257785f34e5bfdfad4801f6ffc373467909d11 - -# Verify the checksum and backup the file if it's different -ynh_backup_if_checksum_is_different --file="$final_path/.env" -# Recalculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$final_path/.env" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set right permissions -chown -R $app: $final_path -chmod -R 775 ${final_path}/storage - -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 - -# 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=$app --key=unprotected_uris --value="/" -fi - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 - -ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload -ynh_systemd_action --service_name=nginx --action=reload -<<<<<<< HEAD -||||||| merged common ancestors -ynh_systemd_action --service_name=php7.2-fpm --action=reload -======= -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ->>>>>>> 44257785f34e5bfdfad4801f6ffc373467909d11 - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Upgrade of $app completed" --time --last diff --git a/scripts/upgrade~ b/scripts/upgrade~ deleted file mode 100755 index 98cde32..0000000 --- a/scripts/upgrade~ +++ /dev/null @@ -1,271 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source _common.sh -source ynh_add_extra_apt_repos__3 -source ynh_install_php__3 -source ynh_composer -source /usr/share/yunohost/helpers - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -admin=$(ynh_app_setting_get --app=$app --key=admin) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -random_key=$(ynh_app_setting_get --app=$app --key=random_key) - -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 - -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 - elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - -# If db_name doesn't exist, create it -if [ -z $db_name ]; then - db_name=$(ynh_sanitize_dbid --db_name=$app) - ynh_app_setting_set --app=$app --key=db_name --value=$db_name -fi - -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/var/www/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path -fi - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK THE PATH -#================================================= - -# Normalize the URL path syntax -path_url=$(ynh_normalize_url_path --path_url=$path_url) - -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= -ynh_script_progression --message="Upgrading source files..." --time --weight=1 - -# Create a temporary directory -tmpdir="$(mktemp -d)" -# Backup the config file in the temp dir -mkdir -p "$tmpdir/storage/upload" -mkdir -p "$tmpdir/storage/export" -mkdir -p "$final_path/storage/upload/" -mkdir -p "$final_path/storage/export/" -cp -a "$final_path/storage/upload/" "$tmpdir/storage/upload/" -cp -a "$final_path/storage/export/" "$tmpdir/storage/export/" -rm -Rf "$final_path" - -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" -ynh_install_composer --phpversion="$phpversion" -cd $final_path && php$phpversion artisan migrate:refresh --seed -cd $final_path && php$phpversion artisan firefly-iii:upgrade-database -cd $final_path && php$phpversion artisan passport:install - - -rm -rf "$final_path/bootstrap/cache/*" - -cd $final_path && php$phpversion artisan cache:clear -cd $final_path && php$phpversion artisan migrate --seed -cd $final_path && php$phpversion artisan firefly-iii:upgrade-database -cd $final_path && php$phpversion artisan passport:install -cd $final_path && php$phpversion artisan cache:clear - -cp -a "$tmpdir/storage/upload/" "$final_path/storage/upload/" -cp -a "$tmpdir/storage/export/" "$final_path/storage/export/" - -# Set right permissions -chown -R $app:$app $final_path -chmod -R 775 ${final_path}/storage - -#remove tmp dir -sudo rm -Rf "$tmpdir" - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 - -# Create a dedicated nginx config -ynh_add_nginx_config - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1 - -# Create a dedicated php-fpm config -<<<<<<< HEAD -ynh_add_fpm_config --phpversion="$phpversion" -||||||| merged common ancestors -ynh_add_fpm_config --phpversion=7.2 -======= -ynh_add_fpm_config --phpversion=$phpversion ->>>>>>> 44257785f34e5bfdfad4801f6ffc373467909d11 - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= - -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$final_path/CONFIG_FILE" - -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - -#================================================= -# SPECIFIC UPGRADE -#================================================= -# Install via composer -ynh_install_composer --phpversion="$phpversion" - -# Get the admin email -email=$(ynh_user_get_info --username=$admin --key='mail') - -# setup application config -sudo cp ../conf/.env $final_path/.env -#================================================= -# MODIFY A CONFIG FILE -#================================================= -ynh_replace_string --match_string"random_key" --replace_string="$random_key" --file="$final_path/.env" -ynh_replace_string --match_string"yunouser" --replace_string="$db_name" --file="$final_path/.env" -ynh_replace_string --match_string"yunopass" --replace_string="$db_pwd" --file="$final_path/.env" -ynh_replace_string --match_string"yunobase" --replace_string="$db_name" --file="$final_path/.env" -ynh_replace_string --match_string"yunomail" --replace_string="$email" --file="$final_path/.env" -ynh_replace_string --match_string"yunodomain" --replace_string="$domain" --file="$final_path/.env" - -<<<<<<< HEAD -#init_composer $final_path - -cd $final_path && php$phpversion artisan migrate --env=production --force -cd $final_path && php$phpversion artisan cache:clear -cd $final_path && php$phpversion artisan firefly:upgrade-database -cd $final_path && php$phpversion artisan firefly:verify -cd $final_path && php$phpversion artisan passport:install -||||||| merged common ancestors -init_composer $final_path -cd $final_path && sudo /usr/bin/php7.2 artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/php7.2 artisan cache:clear -cd $final_path && sudo /usr/bin/php7.2 artisan firefly:upgrade-database -cd $final_path && sudo /usr/bin/php7.2 artisan firefly:verify -cd $final_path && sudo /usr/bin/php7.2 artisan passport:install -======= -init_composer $final_path -cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear -cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database -cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify -cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install ->>>>>>> 44257785f34e5bfdfad4801f6ffc373467909d11 - -# Verify the checksum and backup the file if it's different -ynh_backup_if_checksum_is_different --file="$final_path/.env" -# Recalculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$final_path/.env" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set right permissions -chown -R $app: $final_path -chmod -R 775 ${final_path}/storage - -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 - -# 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=$app --key=unprotected_uris --value="/" -fi - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 - -ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload -ynh_systemd_action --service_name=nginx --action=reload -<<<<<<< HEAD -||||||| merged common ancestors -ynh_systemd_action --service_name=php7.2-fpm --action=reload -======= -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ->>>>>>> 44257785f34e5bfdfad4801f6ffc373467909d11 - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Upgrade of $app completed" --time --last From c5850cc394c10c073cd64eb2489068354b4e9120 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 10 May 2020 00:40:14 +0200 Subject: [PATCH 45/45] Fix for upgrade and restore (missing working directory return after making artisan stuff) --- scripts/_common.sh | 28 ----------- scripts/backup | 5 ++ scripts/install | 7 ++- scripts/restore | 31 +++++++++--- scripts/upgrade | 114 +++++++++++++++++++++------------------------ 5 files changed, 86 insertions(+), 99 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index a1c1d9e..24fbe97 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -38,34 +38,6 @@ exec_as() { # Composer helpers # -# Execute a composer command from a given directory -# usage: composer_exec AS_USER WORKDIR COMMAND [ARG ...] -exec_composer() { - local WORKDIR=$1 - shift 1 - - COMPOSER_HOME="${WORKDIR}/.composer" \ - # sudo /usr/bin/php7.2 "${WORKDIR}/composer.phar" $@ \ - /usr/bin/php7.2 "${WORKDIR}/composer.phar" $@ \ - -d "${WORKDIR}" --no-interaction -} - -# Install and initialize Composer in the given directory -# usage: init_composer DESTDIR [AS_USER] -init_composer() { - local DESTDIR=$1 - local AS_USER=${2:-admin} - - # install composer - curl -sS https://getcomposer.org/installer \ - | COMPOSER_HOME="${DESTDIR}/.composer" \ - sudo /usr/bin/php7.2 -- --quiet --install-dir="$DESTDIR" \ - || ynh_die "Unable to install Composer" - - # update dependencies to create composer.lock - exec_composer "$DESTDIR" install --no-dev --prefer-dist --no-scripts \ - || ynh_die "Unable to update firefly-iii core dependencies" -} sudo_path () { sudo env "PATH=$PATH" $@ diff --git a/scripts/backup b/scripts/backup index 69c295a..5eda3df 100755 --- a/scripts/backup +++ b/scripts/backup @@ -11,9 +11,14 @@ if [ ! -e _common.sh ]; then cp ../settings/scripts/_common.sh ./_common.sh chmod a+rx _common.sh fi + source _common.sh +source ynh_add_extra_apt_repos__3 +source ynh_install_php__3 +source ynh_composer source /usr/share/yunohost/helpers + #================================================= # MANAGE SCRIPT FAILURE #================================================= diff --git a/scripts/install b/scripts/install index cf31f87..80c5dfa 100755 --- a/scripts/install +++ b/scripts/install @@ -48,7 +48,6 @@ ynh_script_progression --message="Validating installation parameters..." --time final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -#mkdir $final_path # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -143,9 +142,9 @@ ynh_replace_string "yunoappurl" "$domain$path_url" "$final_path/.env" #init_composer $final_path $app -cd $final_path && php$phpversion artisan migrate:refresh --seed -cd $final_path && php$phpversion artisan firefly-iii:upgrade-database -cd $final_path && php$phpversion artisan passport:install +cd $final_path && php$phpversion artisan migrate:refresh --seed && cd $YNH_CWD +cd $final_path && php$phpversion artisan firefly-iii:upgrade-database && cd $YNH_CWD +cd $final_path && php$phpversion artisan passport:install && cd $YNH_CWD #================================================= diff --git a/scripts/restore b/scripts/restore index d8aafe4..7055b3a 100755 --- a/scripts/restore +++ b/scripts/restore @@ -13,8 +13,12 @@ if [ ! -e _common.sh ]; then fi source _common.sh +source ynh_add_extra_apt_repos__3 +source ynh_install_php__3 +source ynh_composer source /usr/share/yunohost/helpers + #================================================= # MANAGE SCRIPT FAILURE #================================================= @@ -116,12 +120,27 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # SPECIFIC UPGRADE #================================================= -init_composer $final_path -cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force -cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear -cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database -cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify -cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install + +# Install via composer +ynh_install_composer --phpversion="$phpversion" + +#cd $final_path && sudo /usr/bin/php$phpversion artisan migrate --env=production --force +#cd $final_path && sudo /usr/bin/php$phpversion artisan cache:clear +#cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:upgrade-database +#cd $final_path && sudo /usr/bin/php$phpversion artisan firefly:verify +#cd $final_path && sudo /usr/bin/php$phpversion artisan passport:install + +cd $final_path && php$phpversion artisan migrate:refresh --seed && cd $YNH_CWD +cd $final_path && php$phpversion artisan firefly-iii:upgrade-database && cd $YNH_CWD +cd $final_path && php$phpversion artisan passport:install && cd $YNH_CWD + +#================================================= +# SETUP APPLICATION PERMISSIONS +#================================================= + +# Set right permissions +chown -R $app:$app $final_path +chmod -R 775 ${final_path}/storage #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index f16bc97..916782b 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,6 +81,13 @@ ynh_abort_if_errors # Normalize the URL path syntax path_url=$(ynh_normalize_url_path --path_url=$path_url) +#================================================= +# INSTALL DEPENDENCIES +#================================================= + +ynh_script_progression --message="Installing dependencies..." --time --weight=1 +ynh_install_php --phpversion="$phpversion" --package="$pkg_dependencies" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -99,25 +106,61 @@ rm -Rf "$final_path" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" + +#================================================= +# SPECIFIC SETUP +#================================================= + +# Install via composer ynh_install_composer --phpversion="$phpversion" -cd $final_path && php$phpversion artisan migrate:refresh --seed -cd $final_path && php$phpversion artisan firefly-iii:upgrade-database -cd $final_path && php$phpversion artisan passport:install +# create a user +email=$(ynh_user_get_info $admin 'mail') -rm -rf "$final_path/bootstrap/cache/*" +# setup application config +sudo cp ../conf/.env $final_path/.env -cd $final_path && php$phpversion artisan cache:clear -cd $final_path && php$phpversion artisan migrate --seed -cd $final_path && php$phpversion artisan firefly-iii:upgrade-database -cd $final_path && php$phpversion artisan passport:install -cd $final_path && php$phpversion artisan cache:clear +#================================================= +# MODIFY A CONFIG FILE +#================================================= +ynh_replace_string "random_key" "$random_key" "$final_path/.env" +ynh_replace_string "yunouser" "$db_name" "$final_path/.env" +ynh_replace_string "yunopass" "$db_pwd" "$final_path/.env" +ynh_replace_string "yunobase" "$db_name" "$final_path/.env" +ynh_replace_string "yunomail" "$email" "$final_path/.env" +ynh_replace_string "yunodomain" "$domain" "$final_path/.env" +ynh_replace_string "yunoappurl" "$domain$path_url" "$final_path/.env" + +#Run artisan stuff + +cd $final_path && php$phpversion artisan migrate:refresh --seed && cd $YNH_CWD +cd $final_path && php$phpversion artisan firefly-iii:upgrade-database && cd $YNH_CWD +cd $final_path && php$phpversion artisan passport:install && cd $YNH_CWD + +#rm -rf "$final_path/bootstrap/cache/*" + +#cd $final_path && php$phpversion artisan cache:clear +#cd $final_path && php$phpversion artisan migrate --seed +#cd $final_path && php$phpversion artisan firefly-iii:upgrade-database +#cd $final_path && php$phpversion artisan passport:install +#cd $final_path && php$phpversion artisan cache:clear + +# Verify the checksum and backup the file if it's different +ynh_backup_if_checksum_is_different --file="$final_path/.env" +# Recalculate and store the config file checksum into the app settings +ynh_store_file_checksum --file="$final_path/.env" cp -a "$tmpdir/storage/upload/" "$final_path/storage/upload/" cp -a "$tmpdir/storage/export/" "$final_path/storage/export/" +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + # Set right permissions -chown -R $app:$app $final_path +chown -R $app: $final_path chmod -R 775 ${final_path}/storage #remove tmp dir @@ -131,13 +174,6 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." - # Create a dedicated nginx config ynh_add_nginx_config -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # CREATE DEDICATED USER #================================================= @@ -172,50 +208,6 @@ ynh_script_progression --message="Upgrading logrotate configuration..." --time - # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -#================================================= -# SPECIFIC UPGRADE -#================================================= -# Install via composer -ynh_install_composer --phpversion="$phpversion" - -# Get the admin email -email=$(ynh_user_get_info --username=$admin --key='mail') - -# setup application config -sudo cp ../conf/.env $final_path/.env -#================================================= -# MODIFY A CONFIG FILE -#================================================= -ynh_replace_string --match_string"random_key" --replace_string="$random_key" --file="$final_path/.env" -ynh_replace_string --match_string"yunouser" --replace_string="$db_name" --file="$final_path/.env" -ynh_replace_string --match_string"yunopass" --replace_string="$db_pwd" --file="$final_path/.env" -ynh_replace_string --match_string"yunobase" --replace_string="$db_name" --file="$final_path/.env" -ynh_replace_string --match_string"yunomail" --replace_string="$email" --file="$final_path/.env" -ynh_replace_string --match_string"yunodomain" --replace_string="$domain" --file="$final_path/.env" - -#init_composer $final_path - -cd $final_path && php$phpversion artisan migrate --env=production --force -cd $final_path && php$phpversion artisan cache:clear -cd $final_path && php$phpversion artisan firefly:upgrade-database -cd $final_path && php$phpversion artisan firefly:verify -cd $final_path && php$phpversion artisan passport:install - -# Verify the checksum and backup the file if it's different -ynh_backup_if_checksum_is_different --file="$final_path/.env" -# Recalculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$final_path/.env" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set right permissions -chown -R $app: $final_path -chmod -R 775 ${final_path}/storage - #================================================= # SETUP SSOWAT #=================================================