From ed6f79adc4c60a78bf54322da77bb4145651cbdc Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 20 Apr 2020 04:16:40 +0200 Subject: [PATCH 01/22] Apply example_ynh And upgrade to 0.04.6 --- README.md | 8 +- README_fr.md | 13 +-- check_process | 16 +--- conf/app.src | 4 +- conf/lufi.conf.template | 134 ++++++++++++++++++++------- manifest.json | 10 +- scripts/_common.sh | 112 ++--------------------- scripts/backup | 54 +++++++---- scripts/change_url | 100 +++++++++++--------- scripts/install | 176 ++++++++++++++++++----------------- scripts/remove | 103 +++++++++++---------- scripts/restore | 130 +++++++++++++------------- scripts/upgrade | 197 +++++++++++++++++++++++----------------- 13 files changed, 550 insertions(+), 507 deletions(-) diff --git a/README.md b/README.md index 9562d62..17704a2 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Lufi for YunoHost [![Integration level](https://dash.yunohost.org/integration/lufi.svg)](https://dash.yunohost.org/appci/app/lufi) -[![Install lufi with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lufi) +[![Install Lufi with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lufi) *[Lire ce readme en français.](./README_fr.md)* -> *This package allow you to install lufi quickly and simply on a YunoHost server. +> *This package allow you to install Lufi quickly and simply on a YunoHost server. If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* ## Overview @@ -16,7 +16,7 @@ The administrator of the Lufi instance you use will not be able to see what is i The encryption key part of the URL is a anchor (Cf. [Fragment Identifier](https://en.wikipedia.org/wiki/Fragment_identifier)), that means this part is only processed client-side and does not reach the server. :-) -**Shipped version:** 0.03.5 +**Shipped version:** 0.04.6 ## Screenshots @@ -45,12 +45,12 @@ Can the app be used by multiple users? **Yes** * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lufi%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/lufi/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lufi%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lufi/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/lufi%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/lufi/) ## Links * Report a bug: https://github.com/YunoHost-Apps/lufi_ynh/issues * App website: https://framagit.org/fiat-tux/hat-softwares/lufi + * Upstream app repository: https://framagit.org/fiat-tux/hat-softwares/lufi * YunoHost website: https://yunohost.org/ --- diff --git a/README_fr.md b/README_fr.md index 978f621..d9648b3 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,11 +1,11 @@ # Lufi pour YunoHost [![Integration level](https://dash.yunohost.org/integration/lufi.svg)](https://dash.yunohost.org/appci/app/lufi) -[![Install lufi with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lufi) +[![Install Lufi with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lufi) *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer lufi rapidement et simplement sur un serveur Yunohost. +> *Ce package vous permet d'installer Lufi rapidement et simplement sur un serveur Yunohost. Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* ## Vue d'ensemble @@ -15,7 +15,7 @@ Est-ce tout? Non. Tous les fichiers sont cryptés par le navigateur! Non chiffr La clé de cryptage est une ancre (voir [Fragment Identifier](https://en.wikipedia.org/wiki/Fragment_identifier)), ce qui signifie que cette partie n'est traitée que par le client et n'atteint pas le serveur. :-) -**Version incluse:** 0.03.5 +**Version incluse:** 0.04.6 ## Captures d'écran @@ -40,16 +40,17 @@ Comment configurer cette application: un fichier brut en SSH. L'authentification LDAP et HTTP est-elle prise en charge? **Oui** L'application peut-elle être utilisée par plusieurs utilisateurs? **Oui** -#### Supported architectures +#### Architectures supportées * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lufi%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/lufi/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lufi%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lufi/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/lufi%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/lufi/) -## Links + +## Liens * Signaler un bug: https://github.com/YunoHost-Apps/lufi_ynh/issues * Site de l'application: https://framagit.org/fiat-tux/hat-softwares/lufi + * Dépôt de l'application principale: https://framagit.org/fiat-tux/hat-softwares/lufi * Site web YunoHost: https://yunohost.org/ --- diff --git a/check_process b/check_process index 7b9b7ae..27a19e8 100644 --- a/check_process +++ b/check_process @@ -3,9 +3,8 @@ ; Manifest domain="domain.tld" (DOMAIN) path="/path" (PATH) - is_public="Yes" (PUBLIC|public=Yes|private=No) max_file_size=100 - admin="john" (USER) + is_public=1 (PUBLIC|public=1|private=0) ; Checks pkg_linter=1 setup_sub_dir=1 @@ -17,17 +16,10 @@ upgrade=1 from_commit=1d53901957efcf8861b10efc8d3f081cadd2ba9e backup_restore=1 multi_instance=1 - incorrect_path=1 + # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. + # incorrect_path=1 port_already_use=1 (8095) change_url=1 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto - Level 4=1 + # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 diff --git a/conf/app.src b/conf/app.src index 50cce5a..70ec7d5 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lufi/-/archive/0.03.5/lufi-0.03.5.tar.gz -SOURCE_SUM=aeb4bb4e7b4d5a7a12a7b8a49578e98c4ef8b6cb606b266b4531767a6ea6debe +SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lufi/-/archive/0.04.6/lufi-0.04.6.tar.gz +SOURCE_SUM=2d1f7e174129164fbb4474188dac0b5f358c14e01f5feacf69ec342cf58ff925 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/lufi.conf.template b/conf/lufi.conf.template index 4fc1e86..7057dbe 100644 --- a/conf/lufi.conf.template +++ b/conf/lufi.conf.template @@ -32,6 +32,10 @@ # optional, default is ['fdjsofjoihrei'], PLEASE, CHANGE IT secrets => ['__SECRET__'], + # Name of the instance, displayed next to the logo + # optional, default is Lufi + #instance_name => 'Lufi', + # choose a theme. See the available themes in `themes` directory # optional, default is 'default' #theme => 'default', @@ -71,7 +75,7 @@ # optional, default is 0 (no limit) default_delay => 365, - # number of days after which the images will be deleted, even if they were uploaded with "no delay" (or value superior to max_delay) + # Number of days after which the files will be deleted, even if they were uploaded with "no delay" (or value superior to max_delay) # a warning message will be displayed on homepage # optional, default is 0 (no limit) #max_delay => 0, @@ -97,10 +101,38 @@ # optional, no domains allowed by default #allowed_domains => ['http://1.example.com', 'http://2.example.com'], - # if set, the shortened URLs will use this domain - # optional + # Define a path to the upload directory, where the uploaded files will be stored + # You can define it relative to lufi directory or set an absolute path + # Remember that it has to be in a directory writable by Lufi user + # DO NOT CHANGE THIS IF FILES HAVE BEEN ALREADY UPLOADED: THEY WILL NOT BE DOWNLOADABLE ANYMORE + # optional, default is 'files' + #upload_dir => 'files', + + # allow to add a password on files, asked before allowing to download files + # optional, default is 0 + allow_pwd_on_files => 1, + + # force all files to be in "Burn after reading mode" + # optional, default is 0 + #force_burn_after_reading => 0, + + # if set, the files' URLs will always use this domain + # optional, no default #fixed_domain => 'example.org', + # abuse reasons + # set an integer in the abuse field of a file in the database and it will not be downloadable anymore + # the reason will be displayed to the downloader, according to the reasons you will configure here. + # optional, no default + #abuse => { + # 0 => 'Copyright infringment', + # 1 => 'Illegal content', + #}, + + ############### + # Mail settings + ############### + # Mail configuration # See https://metacpan.org/pod/Mojolicious::Plugin::Mail#EXAMPLES # Optional, default to sendmail method with no arguments @@ -114,6 +146,10 @@ # Optional, default to no-reply@lufi.io #mail_sender => 'no-reply@lufi.io', + ############# + # DB settings + ############# + # choose what database you want to use # valid choices are sqlite, postgresql and mysql (all lowercase) # optional, default is sqlite @@ -156,12 +192,9 @@ # #max_connections => 5, #}, - # define a path to the upload directory, where the uploaded files will be stored - # you can define it relative to lufi directory or set an absolute path - # remember that it has to be in a directory writable by Lufi user - # DO NOT CHANGE THIS IF FILES HAVE BEEN ALREADY UPLOADED: THEY WILL NOT BE DOWNLOADABLE ANYMORE - # optional, default is 'files' - #upload_dir => 'files', + ############################################# + # LDAP settings (authentication and features) + ############################################# # set `ldap` if you want that only authenticated users can upload files # please note that everybody can still download files @@ -181,36 +214,71 @@ __IS_PUBLIC__ #} __IS_PUBLIC__}, - # set `htpasswd` if you want to use an htpasswd file instead of ldap - # see 'man htpasswd' to know how to create such file - #htpasswd => 'lufi.passwd', - # if you've set ldap above, the session will last `session_duration` seconds before # the user needs to reauthenticate # optional, default is 3600 #session_duration => 3600, - # allow to add a password on files, asked before allowing to download files - # optional, default is 0 - allow_pwd_on_files => 1, - - # force all files to be in "Burn after reading mode" - # optional, default is 0 - #force_burn_after_reading => 0, - - # if set, the files' URLs will always use this domain + # If you use `ldap` for authentication, you can map some attributes from LDAP to be able to access them in Lufi + # Those attributes will be accessible with: + # $c->current_user->{lufi_attribute_name} in Lufi backend files (all that is in `lib` directory) + # <%= $self->current_user->{lufi_attribute_name} %> in templates files (in `themes` directory) + # + # Define the attributes like this: `lufi_attribute_name => 'LDAP_attribute_name'` + # Note that you can’t use `username` as a Lufi attribute name: this name is reserved and will contain the login of the user # optional, no default - #fixed_domain => 'example.org', - - # abuse reasons - # set an integer in the abuse field of a file in the database and it will not be downloadable anymore - # the reason will be displayed to the downloader, according to the reasons you will configure here. - # optional, no default - #abuse => { - # 0 => 'Copyright infringment', - # 1 => 'Illegal content', + #ldap_map_attr => { + # displayname => 'cn', + # mail => 'mail' #}, + # When using LDAP authentication, LDAP users can invite people (by mail) to use Lufi to send them files without + # being authenticated. + # This is where you configure the behavior of the invitations. + # You may need to fetch some attributes from LDAP to use some invitations settings. See `ldap_map_attr` above. + # optional, no default + #invitations => { + # # The name of the key set in `ldap_map_attr` (above) that corresponds to the mail of the LDAP user + # # optional, default is `mail` + # mail_attr => 'mail', + # # The `From` header of invitation mail can be the mail of the LDAP user + # # Be sure to have a mail system that will correctly send the mail from your users! (DKIM, SPF…) + # # To enable this feature, set it to 1 + # # optional, disabled by default + # send_invitation_with_ldap_user_mail => 1, + # # The user is able to set an expiration delay for the invitation. + # # This expiration delay can’t be more than this setting (in days). + # # optional, default is 30 days + # max_invitation_expiration_delay => 30, + # # Once the guest has submitted his files, he has an additional period of time to submit forgotten files. + # # You can set that additional period of time in minutes here. + # # To disable that feature, set it to 0 or less + # # optional, default is 10 minutes + # max_additional_period => 10, + # # Lufi follows privacy-by-design, so, by default, no files URLs (with the decode secret) are stored in database. + # # However, the concern is different for this case. Storing files URLs makes users able to retrieve the guests’ sent files + # # from their `invitations` page. + # # Set to 1 to store guests’ files URLs in database + # # optional, default is 0 (disabled) + # save_files_url_in_db => 0, + # # Users can resend the invitation to their guest. This does not extend the invitation’s expiration delay unless you + # # set this option to 1. + # # optional, default is 0 (disabled) + # extend_invitation_expiration_on_resend => 0, + #}, + + ######################### + # Htpasswd authentication + ######################### + + # set `htpasswd` if you want to use an htpasswd file instead of ldap + # see 'man htpasswd' to know how to create such file + #htpasswd => 'lufi.passwd', + + ####################### + # HTTP Headers settings + ####################### + # Content-Security-Policy header that will be sent by Lufi # Set to '' to disable CSP header # https://content-security-policy.com/ provides a good documentation about CSP. @@ -255,11 +323,11 @@ # default action when files directory is over max_total_size (used with script/lufi cron watch) # valid values are 'warn', 'stop-upload' and 'delete' - # please, see readme + # Please, see README.md # optional, default is 'warn' #policy_when_full => 'warn', - # images which are not viewed since delete_no_longer_viewed_files days will be deleted by the cron cleanfiles task + # Files which are not viewed since delete_no_longer_viewed_files days will be deleted by the cron cleanfiles task # if delete_no_longer_viewed_files is not set, the no longer viewed files will NOT be deleted # optional, no default #delete_no_longer_viewed_files => 90, diff --git a/manifest.json b/manifest.json index b9dff0c..65e64a4 100644 --- a/manifest.json +++ b/manifest.json @@ -2,20 +2,20 @@ "name": "Lufi", "id": "lufi", "packaging_format": 1, - "requirements": { - "yunohost": ">= 3.2.2" - }, "description": { "en": "Self hosting files and sharing anonymous application", "fr": "Application d'hébergement et de partage de fichiers anonyme" }, - "version": "0.03.5~ynh1", + "version": "0.04.6~ynh1", "url": "https://git.framasoft.org/luc/lufi", "license": "AGPL-3.0-or-later", "maintainer": { "name": "frju365, cyp", "email": "win10@tutanota.com, cyp@rouquin.me" }, + "requirements": { + "yunohost": ">= 3.5" + }, "multi_instance": true, "services": [ "nginx" @@ -62,4 +62,4 @@ } ] } -} \ No newline at end of file +} diff --git a/scripts/_common.sh b/scripts/_common.sh index d572836..6042ab2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,111 +8,13 @@ pkg_dependencies="build-essential libssl-dev libio-socket-ssl-perl liblwp-protocol-https-perl libpq-dev postgresql cpanminus" #================================================= -# FUTURE OFFICIAL HELPERS +# PERSONAL HELPERS #================================================= -# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started -# -# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ] -# | arg: -n, --service_name= - Name of the service to start. Default : $app -# | arg: -a, --action= - Action to perform with systemctl. Default: start -# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. -# If not defined it don't wait until the service is completely started. -# WARNING: When using --line_match, you should always add `ynh_clean_check_starting` into your -# `ynh_clean_setup` at the beginning of the script. Otherwise, tail will not stop in case of failure -# of the script. The script will then hang forever. -# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log -# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. -# | arg: -e, --length= - Length of the error log : Default : 20 -ynh_systemd_action() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) - local service_name - local action - local line_match - local length - local log_path - local timeout +#================================================= +# EXPERIMENTAL HELPERS +#================================================= - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - local service_name="${service_name:-$app}" - local action=${action:-start} - local log_path="${log_path:-/var/log/$service_name/$service_name.log}" - local length=${length:-20} - local timeout=${timeout:-300} - - # Start to read the log - if [[ -n "${line_match:-}" ]] - then - local templog="$(mktemp)" - # Following the starting of the app in its log - if [ "$log_path" == "systemd" ] ; then - # Read the systemd journal - journalctl --unit=$service_name --follow --since=-0 --quiet > "$templog" & - # Get the PID of the journalctl command - local pid_tail=$! - else - # Read the specified log file - tail -F -n0 "$log_path" > "$templog" 2>&1 & - # Get the PID of the tail command - local pid_tail=$! - fi - fi - - ynh_print_info --message="${action^} the service $service_name" - - # Use reload-or-restart instead of reload. So it wouldn't fail if the service isn't running. - if [ "$action" == "reload" ]; then - action="reload-or-restart" - fi - - systemctl $action $service_name \ - || ( journalctl --no-pager --lines=$length -u $service_name >&2 \ - ; test -e "$log_path" && echo "--" >&2 && tail --lines=$length "$log_path" >&2 \ - ; false ) - - # Start the timeout and try to find line_match - if [[ -n "${line_match:-}" ]] - then - local i=0 - for i in $(seq 1 $timeout) - do - # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout - if grep --quiet "$line_match" "$templog" - then - ynh_print_info --message="The service $service_name has correctly started." - break - fi - if [ $i -eq 3 ]; then - echo -n "Please wait, the service $service_name is ${action}ing" >&2 - fi - if [ $i -ge 3 ]; then - echo -n "." >&2 - fi - sleep 1 - done - if [ $i -ge 3 ]; then - echo "" >&2 - fi - if [ $i -eq $timeout ] - then - ynh_print_warn --message="The service $service_name didn't fully started before the timeout." - ynh_print_warn --message="Please find here an extract of the end of the log of the service $service_name:" - journalctl --no-pager --lines=$length -u $service_name >&2 - test -e "$log_path" && echo "--" >&2 && tail --lines=$length "$log_path" >&2 - fi - ynh_clean_check_starting - fi -} - -# Clean temporary process and file used by ynh_check_starting -# (usually used in ynh_clean_setup scripts) -# -# usage: ynh_clean_check_starting -ynh_clean_check_starting () { - # Stop the execution of tail. - kill -s 15 $pid_tail 2>&1 - ynh_secure_remove "$templog" 2>&1 -} \ No newline at end of file +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index 15c84e6..69a55e4 100644 --- a/scripts/backup +++ b/scripts/backup @@ -12,10 +12,10 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -23,62 +23,76 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." 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 +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="$final_path/log/production.log" + #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info "Backing up the main app directory..." +ynh_print_info --message="Backing up the main app directory..." -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info "Backing up nginx web server configuration..." +ynh_print_info --message="Backing up nginx web server configuration..." -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info "Backing up the PostgreSQL database..." +ynh_print_info --message="Backing up the PostgreSQL database..." -ynh_psql_dump_db "$db_name" > db.sql +ynh_psql_dump_db --database="$db_name" > db.sql #================================================= # SPECIFIC BACKUP #================================================= # BACKUP LOGROTATE #================================================= -ynh_print_info "Backing up logrotate configuration..." +ynh_print_info --message="Backing up logrotate configuration..." -ynh_backup "/etc/logrotate.d/$app" +ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= -ynh_print_info "Backing up systemd configuration..." +ynh_print_info --message="Backing up systemd configuration..." -ynh_backup "/etc/systemd/system/$app.service" +ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= -# BACKUP CRON +# BACKUP A CRON FILE #================================================= -ynh_print_info "Backing up cron configuration..." +ynh_print_info --message="Backing up a cron file..." -ynh_backup "/etc/cron.d/${app}" +ynh_backup --src_path="/etc/cron.d/$app" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/production.log" #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." \ No newline at end of file +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 23da1c3..b38781b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= +ynh_print_info --message="Retrieve arguments from the manifest" old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH @@ -24,28 +25,36 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get $app final_path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Needed for lufi conf -port=$(ynh_app_setting_get $app port) -is_public=$(ynh_app_setting_get $app is_public) -db_name=$(ynh_app_setting_get "$app" db_name) -db_pwd=$(ynh_app_setting_get $app psqlpwd) +port=$(ynh_app_setting_get --app=$app --key=port) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) db_user=$db_name -secret=$(ynh_app_setting_get $app secret) -max_file_size=$(ynh_app_setting_get $app max_file_size) +secret=$(ynh_app_setting_get --app=$app --key=secret) +max_file_size=$(ynh_app_setting_get --app=$app --key=max_file_size) #================================================= -# CHECK THE SYNTAX OF THE PATHS +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_print_info --message="Backing up the app before changing its url (may take a while)..." -test -n "$old_path" || old_path="/" -test -n "$new_path" || new_path="/" -new_path=$(ynh_normalize_url_path $new_path) -old_path=$(ynh_normalize_url_path $old_path) +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # 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 WHICH PARTS SHOULD BE CHANGED @@ -65,10 +74,17 @@ fi #================================================= # STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="$final_path/log/production.log" + #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_print_info "Updating nginx web server configuration..." +ynh_print_info --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -76,7 +92,7 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf 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" + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for nginx helper domain="$old_domain" path_url="$new_path" @@ -88,10 +104,10 @@ fi if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum "$nginx_conf_path" + 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 "/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -99,38 +115,37 @@ fi #================================================= # SETUP LUFI #================================================= -ynh_print_info "Configuring lufi..." +ynh_print_info --message="Configuring lufi..." domain="$new_domain" path_url="$new_path" -cp ../conf/lufi.conf.template "${final_path}/lufi.conf" -ynh_replace_string "__DOMAIN__" "$domain" "${final_path}/lufi.conf" -ynh_replace_string "__PATH__" "$path_url" "${final_path}/lufi.conf" -ynh_replace_string "__PORT__" "$port" "${final_path}/lufi.conf" -ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lufi.conf" -ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lufi.conf" -ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lufi.conf" -ynh_replace_string "__MAX_FILE_SIZE__" "$max_file_size" "${final_path}/lufi.conf" +config=${final_path}/lufi.conf +ynh_backup_if_checksum_is_different --file="$config" +cp ../conf/lufi.conf.template "$config" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" +ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config" +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" +ynh_replace_string --match_string="__MAX_FILE_SIZE__" --replace_string="$max_file_size" --target_file="$config" if [ $max_file_size -eq 0 ]; then # Comment the limitation line if no limit - ynh_replace_string "max_file_size" "#max_file_size" "${final_path}/lufi.conf" + ynh_replace_string --match_string="max_file_size" --replace_string="#max_file_size" --target_file="$config" fi - -ynh_replace_string "__SECRET__" "$secret" "${final_path}/lufi.conf" +ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config" if [ $is_public -eq 0 ]; then - ynh_replace_string "__IS_PUBLIC__" "" "${final_path}/lufi.conf" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="" --target_file="$config" else - ynh_replace_string "__IS_PUBLIC__" "#" "${final_path}/lufi.conf" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="#" --target_file="$config" fi -ynh_store_file_checksum "${final_path}/lufi.conf" +ynh_store_file_checksum --file="$config" -#================================================= -# GENERIC FINALISATION #================================================= # UPDATE SSOWAT #================================================= -ynh_print_info "Reconfigure SSOwat" +ynh_print_info --message="Reconfigure SSOwat" ynh_app_setting_set $app unprotected_uris "/" if [ $is_public -eq 0 ] @@ -141,24 +156,27 @@ then fi # Modify the domain to be used in a regex domain_regex=$(echo "$domain" | sed 's@-@.@g') - ynh_app_setting_set $app protected_regex "$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$" + ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$" fi #================================================= -# RESTART LUFI +# GENERIC FINALISATION #================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." -ynh_systemd_action -n $app -a reload -l "Creating process id file" -p "$final_path/log/production.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/production.log" --line_match="Creating process id file" #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Change of URL completed for $app" +ynh_print_info --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index d55e7a7..a853354 100644 --- a/scripts/install +++ b/scripts/install @@ -12,11 +12,10 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting - - true } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -24,62 +23,65 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +ynh_print_info --message="Retrieving arguments from the manifest..." domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC max_file_size=$YNH_APP_ARG_MAX_FILE_SIZE +is_public=$YNH_APP_ARG_IS_PUBLIC +secret=$(ynh_string_random 24) app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info "Validating installation parameters..." +ynh_print_info --message="Validating installation parameters..." 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) +path_url=$(ynh_normalize_url_path --path_url=$path_url) # Check if max_file_size is a number if ! [[ $max_file_size =~ "^[\-0-9]+$" ]] && [ $max_file_size -lt 0 ]; then - ynh_die "Max file must be a number positive or zero" + ynh_die --message="Max file must be a number positive or zero" fi # Check web path availability -ynh_webpath_available $domain $path_url +ynh_webpath_available --domain=$domain --path_url=$path_url # Register (book) web path -ynh_webpath_register $app $domain $path_url - -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_print_info "Configuring firewall..." - -# Find a free port -port=$(ynh_find_port 8095) -# Open this port -yunohost firewall allow --no-upnp TCP $port 2>&1 +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_print_info "Storing installation settings..." +ynh_print_info --message="Storing installation settings..." -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app port $port -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app max_file_size $max_file_size +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=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=max_file_size --value=$max_file_size +ynh_app_setting_set --app=$app --key=secret --value=$secret #================================================= # STANDARD MODIFICATIONS +#================================================= +# FIND AND OPEN A PORT +#================================================= +ynh_print_info --message="Configuring firewall..." + +# Find an available port +port=$(ynh_find_port --port=8095) +ynh_app_setting_set --app=$app --key=port --value=$port +# Open this port +ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port + #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_print_info "Installing dependencies..." +ynh_print_info --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies # Install Carton @@ -88,30 +90,30 @@ echo yes | cpanm Carton #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_print_info "Creating a PostgreSQL database..." +ynh_print_info --message="Creating a PostgreSQL database..." # Create postgresql database ynh_psql_test_if_first_run -db_name=$(ynh_sanitize_dbid "$app") +db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name -ynh_app_setting_set "$app" db_name "$db_name" +ynh_app_setting_set --app=$app --key=db_name --value=$db_name # Initialize database and store postgres password for upgrade -ynh_psql_setup_db "$db_name" "$db_user" -db_pwd=$(ynh_app_setting_get $app psqlpwd) # Password created in ynh_psql_setup_db function +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # Password created in ynh_psql_setup_db function #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Setting up source files..." +ynh_print_info --message="Setting up source files..." -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_print_info "Configuring nginx web server..." +ynh_print_info --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config max_file_size @@ -119,84 +121,103 @@ ynh_add_nginx_config max_file_size #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Configuring system user..." +ynh_print_info --message="Configuring system user..." # Create a system user -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= -# Copy and fix variable into lufi config +# SPECIFIC SETUP #================================================= -ynh_print_info "Configuring lufi..." +# CONFIGURE LUFI +#================================================= +ynh_print_info --message="Configuring lufi..." -cp ../conf/lufi.conf.template "${final_path}/lufi.conf" -ynh_replace_string "__DOMAIN__" "$domain" "${final_path}/lufi.conf" -ynh_replace_string "__PATH__" "$path_url" "${final_path}/lufi.conf" -ynh_replace_string "__PORT__" "$port" "${final_path}/lufi.conf" -ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lufi.conf" -ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lufi.conf" -ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lufi.conf" -ynh_replace_string "__MAX_FILE_SIZE__" "$max_file_size" "${final_path}/lufi.conf" +config=${final_path}/lufi.conf +cp ../conf/lufi.conf.template "$config" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" +ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config" +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" +ynh_replace_string --match_string="__MAX_FILE_SIZE__" --replace_string="$max_file_size" --target_file="$config" if [ $max_file_size -eq 0 ]; then # Comment the limitation line if no limit - ynh_replace_string "max_file_size" "#max_file_size" "${final_path}/lufi.conf" + ynh_replace_string --match_string="max_file_size" --replace_string="#max_file_size" --target_file="$config" fi - -secret=$(ynh_string_random 24) -ynh_app_setting_set $app secret $secret -ynh_replace_string "__SECRET__" "$secret" "${final_path}/lufi.conf" +ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config" if [ $is_public -eq 0 ]; then - ynh_replace_string "__IS_PUBLIC__" "" "${final_path}/lufi.conf" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="" --target_file="$config" else - ynh_replace_string "__IS_PUBLIC__" "#" "${final_path}/lufi.conf" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="#" --target_file="$config" fi -ynh_store_file_checksum "${final_path}/lufi.conf" +ynh_store_file_checksum "$config" + +#================================================= +# Install lufi's dependencies via carton +#================================================= +ynh_print_info --message="Installing lufi..." + +pushd $final_path + carton install --deployment --without=sqlite --without=mysql --without=htpasswd --without=test +popd #================================================= # SETUP CRON #================================================= cp ../conf/cron_lufi /etc/cron.d/$app -ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file="/etc/cron.d/$app" chmod +x $final_path/script/lufi #================================================= # SETUP SYSTEMD #================================================= -ynh_print_info "Configuring a systemd service..." +ynh_print_info --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config #================================================= -# Install lufi's dependencies via carton +# GENERIC FINALIZATION #================================================= -ynh_print_info "Installing lufi..." +# SECURE FILES AND DIRECTORIES +#================================================= +ynh_print_info --message="Securing files and directories..." -pushd $final_path -carton install --deployment --without=sqlite --without=mysql --without=htpasswd --without=test -popd +# Set permissions to app files +chown -R $app:$app $final_path #================================================= # SETUP LOGROTATE #================================================= -ynh_print_info "Configuring log rotation..." +ynh_print_info --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_print_info --message="Integrating service in YunoHost..." yunohost service add $app --log "$final_path/log/production.log" +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +systemctl enable $app.service +ynh_systemd_action -service_name=$app --action="start" --line_match="Creating process id file" --log_path="$final_path/log/production.log" + #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Configuring SSOwat..." +ynh_print_info --message="Configuring SSOwat..." -ynh_app_setting_set $app unprotected_uris "/" +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" if [ $is_public -eq 0 ] then if [ "$path_url" == "/" ]; then @@ -205,33 +226,18 @@ then fi # Modify the domain to be used in a regex domain_regex=$(echo "$domain" | sed 's@-@.@g') - ynh_app_setting_set $app protected_regex "$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$" + ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$" fi -#================================================= -# Configure owner -#================================================= - -chown -R $app:$app "$final_path" - -#================================================= -# Start lufi -#================================================= - -systemctl enable $app.service -ynh_systemd_action -n $app -a start -l "Creating process id file" -p "$final_path/log/production.log" - #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -# Reload Nginx -systemctl reload nginx -yunohost app ssowatconf +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Installation of $app completed" +ynh_print_info --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index b7eb829..c1d4f34 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,63 +12,74 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -domain=$(ynh_app_setting_get $app domain) -port=$(ynh_app_setting_get $app port) -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=$app --key=final_path) #================================================= # STANDARD REMOVE #================================================= -# REMOVE SERVICE FROM ADMIN PANEL +# REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= +ynh_print_info --message="Removing service integration in YunoHost..." -# Remove a service from the admin panel, added by `yunohost service add` -if yunohost service status | grep -q $app +# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) +if ynh_exec_warn_less yunohost service status $app >/dev/null then - echo "Remove $app service" + ynh_print_info --message="Removing $app service..." yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_print_info "Stopping and removing the systemd service" +ynh_print_info --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config +#================================================= +# REMOVE THE POSTGRESQL DATABASE +#================================================= +ynh_print_info --message="Removing the PostgreSQL database..." + +# Remove a database if it exists, along with the associated user +ynh_psql_remove_db --db_user=$db_user --db_name=$db_name + +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_print_info --message="Removing dependencies..." + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info "Removing app main directory" +ynh_print_info --message="Removing app main directory..." # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info "Removing nginx web server configuration" +ynh_print_info --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# DELETE LOG -#================================================= - -ynh_secure_remove "/var/log/$app" - #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_print_info "Removing logrotate configuration" +ynh_print_info --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate @@ -76,49 +87,43 @@ ynh_remove_logrotate #================================================= # CLOSE A PORT #================================================= +ynh_print_info --message="Closing a port..." if yunohost firewall list | grep -q "\- $port$" then - echo "Close port $port" - yunohost firewall disallow TCP $port 2>&1 + ynh_print_info --message="Closing port $port..." + ynh_exec_warn_less yunohost firewall disallow TCP $port fi -#================================================= -# REMOVE THE POSTGRESQL DATABASE -#================================================= -ynh_print_info "Removing the PostgreSQL database" - -ynh_psql_remove_db $db_name $db_user - -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_print_info "Removing dependencies" - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_print_info "Removing the dedicated system user" - -# Delete a system user -ynh_system_user_delete $app - #================================================= # SPECIFIC REMOVE #================================================= # REMOVE THE CRON FILE #================================================= +ynh_print_info --message="Removing the cron file..." # Remove a cron file -ynh_secure_remove "/etc/cron.d/$app" +ynh_secure_remove --file="/etc/cron.d/$app" + +#================================================= +# REMOVE LOG +#================================================= +ynh_print_info --message="Removing the log file..." + +ynh_secure_remove --file="/var/log/$app" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_print_info --message="Removing the dedicated system user..." + +# Delete a system user +ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Removal of $app completed" +ynh_print_info --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index e16363a..298dcca 100644 --- a/scripts/restore +++ b/scripts/restore @@ -12,11 +12,10 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting - - true } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -24,116 +23,125 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading settings..." +ynh_print_info --message="Loading settings..." 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_print_info "Validating restoration parameters..." +ynh_print_info --message="Validating restoration parameters..." -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 " + || ynh_die --message="There is already a directory: $final_path " #================================================= # 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_print_info --message="Restoring the app main directory..." + +ynh_restore_file --origin_path="$final_path" + +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_print_info --message="Recreating the dedicated system user..." + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app + +#================================================= +# RESTORE USER RIGHTS +#================================================= +ynh_print_info --message="Restoring user rights..." + +# Restore permissions on app files +chown -R $app:$app $final_path + +#================================================= +# SPECIFIC RESTORATION +#================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_print_info "Reinstalling dependencies..." +ynh_print_info --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies # Install Carton echo yes | cpanm Carton -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= - -ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_print_info "Restoring the app main directory..." - -ynh_restore_file "$final_path" - -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_print_info "Recreating the dedicated system user..." - -# Create the dedicated user (if not existing) -ynh_system_user_create $app - #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_print_info "Restoring the PostregSQL database..." +ynh_print_info --message="Restoring the PostregSQL database..." -db_pwd=$(ynh_app_setting_get $app psqlpwd) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) ynh_psql_test_if_first_run -ynh_psql_setup_db $db_name $db_name $db_pwd -ynh_psql_connect_as $db_name $db_pwd $db_name < ./db.sql +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions on app files -chown -R $app:$app "$final_path" - -#================================================= -# SPECIFIC RESTORATION #================================================= # RESTORE SYSTEMD #================================================= -ynh_print_info "Restoring the systemd configuration..." +ynh_print_info --message="Restoring the systemd configuration..." -ynh_restore_file "/etc/systemd/system/$app.service" +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service -ynh_systemd_action -n $app -a start -l "Creating process id file" -p "$final_path/log/production.log" #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_print_info --message="Integrating service in YunoHost..." yunohost service add $app --log "$final_path/log/production.log" +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/production.log" --line_match="Creating process id file" + +#================================================= +# RESTORE THE CRON FILE +#================================================= + +ynh_restore_file --origin_path="/etc/cron.d/$app" + #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= +ynh_print_info --message="Restoring the logrotate configuration..." -ynh_restore_file "/etc/logrotate.d/$app" - -#================================================= -# RESTORE THE CRON CONFIGURATION -#================================================= - -ynh_restore_file "/etc/cron.d/$app" +ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx -yunohost app ssowatconf +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Restoration completed for $app" +ynh_print_info --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 0699122..7e75235 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,30 +12,39 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -is_public=$(ynh_app_setting_get $app is_public) -port=$(ynh_app_setting_get $app port) -final_path=$(ynh_app_setting_get $app final_path) -secret=$(ynh_app_setting_get $app secret) -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) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +port=$(ynh_app_setting_get --app=$app --key=port) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +secret=$(ynh_app_setting_get --app=$app --key=secret) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name -db_pwd=$(ynh_app_setting_get $app psqlpwd) -max_file_size=$(ynh_app_setting_get $app max_file_size) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +max_file_size=$(ynh_app_setting_get --app=$app --key=max_file_size) #================================================= -# FIX OLD THINGS +# CHECK VERSION #================================================= +ynh_print_info --message="Checking version..." +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_print_info --message="Ensuring downward compatibility..." + +# Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen + ynh_app_setting_set --app=$app --key=is_public --value=1 is_public=1 elif [ "$is_public" = "No" ]; then - ynh_app_setting_set $app is_public 0 + ynh_app_setting_set --app=$app --key=is_public --value=0 is_public=0 fi @@ -58,7 +67,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info "Backing up the app before upgrading (may take a while)..." +ynh_print_info --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -72,97 +81,102 @@ ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="$final_path/log/production.log" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Upgrading source files..." -ynh_install_app_dependencies $pkg_dependencies +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_print_info --message="Upgrading source files..." -ynh_setup_source "$final_path" - -#================================================= -# CREATE A POSTGRESQL DATABASE IF NEEDED -#================================================= - -if [ $need_migration_from_sqlite_to_psql -eq 1 ]; then - ynh_print_info "Creating a PostgreSQL database..." - # Create postgresql database - ynh_psql_test_if_first_run - db_name=$(ynh_sanitize_dbid "$app") - db_user=$db_name - ynh_app_setting_set "$app" db_name "$db_name" - # Initialize database and store postgres password for upgrade - ynh_psql_setup_db "$db_name" "$db_user" - db_pwd=$(ynh_app_setting_get $app psqlpwd) # Password created in ynh_psql_setup_db function + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Upgrading nginx web server configuration..." +ynh_print_info --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config max_file_size +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_print_info --message="Upgrading dependencies..." + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Making sure dedicated system user exists..." +ynh_print_info --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # SPECIFIC UPGRADE +#================================================= +# CREATE A POSTGRESQL DATABASE IF NEEDED +#================================================= + +if [ $need_migration_from_sqlite_to_psql -eq 1 ]; then + ynh_print_info --message="Creating a PostgreSQL database..." + # Create postgresql database + ynh_psql_test_if_first_run + db_name=$(ynh_sanitize_dbid --db_name=$app) + db_user=$db_name + ynh_app_setting_set --app=$app --key=db_name --value=$db_name + # Initialize database and store postgres password for upgrade + ynh_psql_setup_db --db_user=user --db_name=name + db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # Password created in ynh_psql_setup_db function +fi + #================================================= # SETUP LUFI #================================================= -ynh_print_info "Configuring lufi..." +ynh_print_info --message="Configuring lufi..." -cp ../conf/lufi.conf.template "${final_path}/lufi.conf" -ynh_replace_string "__DOMAIN__" "$domain" "${final_path}/lufi.conf" -ynh_replace_string "__PATH__" "$path_url" "${final_path}/lufi.conf" -ynh_replace_string "__PORT__" "$port" "${final_path}/lufi.conf" -ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lufi.conf" -ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lufi.conf" -ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lufi.conf" -ynh_replace_string "__MAX_FILE_SIZE__" "$max_file_size" "${final_path}/lufi.conf" +config=${final_path}/lufi.conf +ynh_backup_if_checksum_is_different --file="$config" +cp ../conf/lufi.conf.template "$config" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" +ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config" +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" +ynh_replace_string --match_string="__MAX_FILE_SIZE__" --replace_string="$max_file_size" --target_file="$config" if [ $max_file_size -eq 0 ]; then # Comment the limitation line if no limit - ynh_replace_string "max_file_size" "#max_file_size" "${final_path}/lufi.conf" + ynh_replace_string --match_string="max_file_size" --replace_string="#max_file_size" --target_file="$config" fi -ynh_replace_string "__SECRET__" "$secret" "${final_path}/lufi.conf" +ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config" if [ $is_public -eq 0 ]; then - ynh_replace_string "__IS_PUBLIC__" "" "${final_path}/lufi.conf" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="" --target_file="$config" else - ynh_replace_string "__IS_PUBLIC__" "#" "${final_path}/lufi.conf" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="#" --target_file="$config" fi -ynh_store_file_checksum "${final_path}/lufi.conf" +ynh_store_file_checksum --file="$config" #================================================= # SETUP CRON #================================================= cp ../conf/cron_lufi /etc/cron.d/$app -ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file="/etc/cron.d/$app" chmod +x $final_path/script/lufi -#================================================= -# SECURING FILES AND DIRECTORIES -#================================================= - -chown -R $app: "$final_path" - -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_print_info "Upgrading systemd configuration..." - -# Create a dedicated systemd config -ynh_add_systemd_config - #================================================= # Install lufi's dependencies via carton #================================================= @@ -180,23 +194,12 @@ if [ $need_migration_from_sqlite_to_psql -eq 1 ]; then chown -R $app: "$final_path/log/production.log" fi - # Restart with news parameters - ynh_systemd_action -n $app -a restart -l "Creating process id file" -p "$final_path/log/production.log" - carton exec script/lufi sqliteToOtherDB fi carton install --deployment --without=sqlite --without=mysql --without=htpasswd --without=test popd -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_print_info "Upgrading logrotate configuration..." - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= @@ -204,17 +207,37 @@ ynh_use_logrotate --non-append yunohost service add $app --log "$final_path/log/production.log" #================================================= -# RESTART LUFI +# SETUP LOGROTATE #================================================= +ynh_print_info --message="Upgrading logrotate configuration..." -ynh_systemd_action -n $app -a reload -l "Creating process id file" -p "$final_path/log/production.log" +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_print_info --message="Upgrading systemd configuration..." + +# Create a dedicated systemd config +ynh_add_systemd_config + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURING FILES AND DIRECTORIES +#================================================= +ynh_print_info --message="Securing files and directories..." + +# Set permissions on app files +chown -R $app: $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Upgrading SSOwat configuration..." +ynh_print_info --message="Upgrading SSOwat configuration..." -ynh_app_setting_set $app unprotected_uris "/" +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" if [ $is_public -eq 0 ] then if [ "$path_url" == "/" ]; then @@ -223,19 +246,25 @@ then fi # Modify the domain to be used in a regex domain_regex=$(echo "$domain" | sed 's@-@.@g') - ynh_app_setting_set $app protected_regex "$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$" + ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$" fi +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/production.log" --line_match="Creating process id file" + #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx -yunohost app ssowatconf +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Upgrade of $app completed" +ynh_print_info --message="Upgrade of $app completed" From 70002cff34b6916b90ed199a0c3c09dd5b58ffcb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 21 Apr 2020 03:51:37 +0200 Subject: [PATCH 02/22] typo --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index a853354..36a42d4 100644 --- a/scripts/install +++ b/scripts/install @@ -210,7 +210,7 @@ yunohost service add $app --log "$final_path/log/production.log" ynh_print_info --message="Starting a systemd service..." systemctl enable $app.service -ynh_systemd_action -service_name=$app --action="start" --line_match="Creating process id file" --log_path="$final_path/log/production.log" +ynh_systemd_action --service_name=$app --action="start" --line_match="Creating process id file" --log_path="$final_path/log/production.log" #================================================= # SETUP SSOWAT From 7a0adc141296e20158a0da2f209dd61a640d1fd2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 21 Apr 2020 12:32:09 +0200 Subject: [PATCH 03/22] TO ensure compatibility from old version --- check_process | 1 + 1 file changed, 1 insertion(+) diff --git a/check_process b/check_process index 27a19e8..5538a64 100644 --- a/check_process +++ b/check_process @@ -5,6 +5,7 @@ path="/path" (PATH) max_file_size=100 is_public=1 (PUBLIC|public=1|private=0) + admin="john" (USER) ; Checks pkg_linter=1 setup_sub_dir=1 From d56e7789c3e090d32b987759173776889bc96aab Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 21 Apr 2020 12:33:03 +0200 Subject: [PATCH 04/22] Add upgrade check --- check_process | 2 ++ 1 file changed, 2 insertions(+) diff --git a/check_process b/check_process index 5538a64..b3abd9d 100644 --- a/check_process +++ b/check_process @@ -15,6 +15,8 @@ setup_public=1 upgrade=1 upgrade=1 from_commit=1d53901957efcf8861b10efc8d3f081cadd2ba9e + # 0.03.5 + upgrade=1 from_commit=6e05053ee90370e659d16abd9dcd9220e9e497f5 backup_restore=1 multi_instance=1 # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. From 868d262219fe5afe528cc9b3498eb20de1987540 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 22 Apr 2020 16:13:29 +0200 Subject: [PATCH 05/22] to make package check from old version --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index b3abd9d..5605ec7 100644 --- a/check_process +++ b/check_process @@ -4,7 +4,7 @@ domain="domain.tld" (DOMAIN) path="/path" (PATH) max_file_size=100 - is_public=1 (PUBLIC|public=1|private=0) + is_public="Yes" (PUBLIC|public=Yes|private=No) admin="john" (USER) ; Checks pkg_linter=1 From 2dd3b7da8fd10f7f54f85bfcd9e507d24eb291d8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 25 Apr 2020 22:41:57 +0200 Subject: [PATCH 06/22] Fix upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 7e75235..7a60e4f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -137,7 +137,7 @@ if [ $need_migration_from_sqlite_to_psql -eq 1 ]; then db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name # Initialize database and store postgres password for upgrade - ynh_psql_setup_db --db_user=user --db_name=name + ynh_psql_setup_db --db_user=$db_user --db_name=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # Password created in ynh_psql_setup_db function fi From 199c5c698c3d5e22e5cc12c156512be1b92a6a47 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 May 2020 17:36:04 +0200 Subject: [PATCH 07/22] Update app.src --- conf/app.src | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/app.src b/conf/app.src index 70ec7d5..0ae9db3 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,3 +3,4 @@ SOURCE_SUM=2d1f7e174129164fbb4474188dac0b5f358c14e01f5feacf69ec342cf58ff925 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= From d798663617b770240f7773df716296a3efaf3756 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 May 2020 17:44:04 +0200 Subject: [PATCH 08/22] Update check_process --- check_process | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/check_process b/check_process index 5605ec7..6a2fb26 100644 --- a/check_process +++ b/check_process @@ -14,6 +14,7 @@ setup_private=1 setup_public=1 upgrade=1 + # 0.01 upgrade=1 from_commit=1d53901957efcf8861b10efc8d3f081cadd2ba9e # 0.03.5 upgrade=1 from_commit=6e05053ee90370e659d16abd9dcd9220e9e497f5 @@ -26,3 +27,8 @@ ;;; Levels # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto +;;; Upgrade options + ; commit=1d53901957efcf8861b10efc8d3f081cadd2ba9e + name=0.01 + ; commit=6e05053ee90370e659d16abd9dcd9220e9e497f5 + name=0.03.5 From 6f471f7943ca7ee0ef87f76f4bf6d6f08b2f58d5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 01:58:07 +0200 Subject: [PATCH 09/22] Fix upgrade from 0.01 --- scripts/backup | 1 + scripts/install | 15 +++++++++++---- scripts/restore | 6 +++++- scripts/upgrade | 29 ++++++++++++++++++----------- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/scripts/backup b/scripts/backup index 69a55e4..ec97225 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers diff --git a/scripts/install b/scripts/install index 36a42d4..f0ac2f3 100644 --- a/scripts/install +++ b/scripts/install @@ -75,8 +75,13 @@ ynh_print_info --message="Configuring firewall..." # Find an available port port=$(ynh_find_port --port=8095) ynh_app_setting_set --app=$app --key=port --value=$port -# Open this port -ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port + +# Optional: Expose this port publicly +# (N.B. : you only need to do this if the app actually needs to expose the port publicly. +# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !) + +# Open the port +# ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port #================================================= # INSTALL DEPENDENCIES @@ -84,6 +89,7 @@ ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port ynh_print_info --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies + # Install Carton echo yes | cpanm Carton @@ -155,7 +161,7 @@ fi ynh_store_file_checksum "$config" #================================================= -# Install lufi's dependencies via carton +# INSTALL LUFI'S DEPENDENCIES VIA CARTON #================================================= ynh_print_info --message="Installing lufi..." @@ -166,6 +172,7 @@ popd #================================================= # SETUP CRON #================================================= +ynh_print_info --message="Setuping a cron..." cp ../conf/cron_lufi /etc/cron.d/$app ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file="/etc/cron.d/$app" @@ -202,7 +209,7 @@ ynh_use_logrotate #================================================= ynh_print_info --message="Integrating service in YunoHost..." -yunohost service add $app --log "$final_path/log/production.log" +yunohost service add $app --description "lufi service" --log "$final_path/log/production.log" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/restore b/scripts/restore index 298dcca..09c5e8d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -48,6 +49,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_print_info --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -83,6 +85,7 @@ ynh_print_info --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies + # Install Carton echo yes | cpanm Carton @@ -109,7 +112,7 @@ systemctl enable $app.service #================================================= ynh_print_info --message="Integrating service in YunoHost..." -yunohost service add $app --log "$final_path/log/production.log" +yunohost service add $app --description "lufi service" --log "$final_path/log/production.log" #================================================= # START SYSTEMD SERVICE @@ -121,6 +124,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/ #================================================= # RESTORE THE CRON FILE #================================================= +ynh_print_info --message="Restoring the cron file..." ynh_restore_file --origin_path="/etc/cron.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index 7a60e4f..d97f097 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -51,6 +51,7 @@ fi if [ "${#final_path}" -eq 0 ] then # Si final_path n'est pas renseigné dans la config yunohost, cas d'ancien script, code final_path en dur final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi if [ -z "$db_pwd" ]; then @@ -62,6 +63,7 @@ fi if [ -z "$max_file_size" ]; then max_file_size=100 # 100 Mo + ynh_app_setting_set --app=$app --key=max_file_size --value=$max_file_size fi #================================================= @@ -170,16 +172,9 @@ fi ynh_store_file_checksum --file="$config" #================================================= -# SETUP CRON -#================================================= - -cp ../conf/cron_lufi /etc/cron.d/$app -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file="/etc/cron.d/$app" -chmod +x $final_path/script/lufi - -#================================================= -# Install lufi's dependencies via carton +# INSTALL LUFI'S DEPENDENCIES VIA CARTON #================================================= +ynh_print_info --message="Installing lufi..." pushd $final_path # Migrate from SQLite to PostgreSQL @@ -194,17 +189,29 @@ if [ $need_migration_from_sqlite_to_psql -eq 1 ]; then chown -R $app: "$final_path/log/production.log" fi + # Restart with news parameters + ynh_systemd_action -n $app -a restart -l "Creating process id file" -p "$final_path/log/production.log" + carton exec script/lufi sqliteToOtherDB fi carton install --deployment --without=sqlite --without=mysql --without=htpasswd --without=test popd +#================================================= +# SETUP CRON +#================================================= +ynh_print_info --message="Setuping cron..." + +cp ../conf/cron_lufi /etc/cron.d/$app +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file="/etc/cron.d/$app" +chmod +x $final_path/script/lufi + #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add $app --log "$final_path/log/production.log" +yunohost service add $app --description "lufi service" --log "$final_path/log/production.log" #================================================= # SETUP LOGROTATE @@ -254,7 +261,7 @@ fi #================================================= ynh_print_info --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/production.log" --line_match="Creating process id file" +ynh_systemd_action --service_name=$app --action="restart" --log_path="$final_path/log/production.log" --line_match="Creating process id file" #================================================= # RELOAD NGINX From b26b59e0fcf0476e6785f5196cb57eebdc2cc19e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 May 2020 01:21:24 +0200 Subject: [PATCH 10/22] fix upgrade Too many arguments ! "-p" will be ignored. Too many arguments ! "/var/www/lufi/log/production.log" will be ignored. --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index d97f097..a4cfc1c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -190,7 +190,7 @@ if [ $need_migration_from_sqlite_to_psql -eq 1 ]; then fi # Restart with news parameters - ynh_systemd_action -n $app -a restart -l "Creating process id file" -p "$final_path/log/production.log" + ynh_systemd_action --service_name=$app --action="restart" --log_path="$final_path/log/production.log" --line_match="Creating process id file" carton exec script/lufi sqliteToOtherDB fi From 6b038d0a2772d69282a90605f55ddfd2c67ee880 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 May 2020 01:56:05 +0200 Subject: [PATCH 11/22] add template --- issue_template.md | 46 ++++++++++++++++++++++++++++++++++++++++ pull_request_template.md | 18 ++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 issue_template.md create mode 100644 pull_request_template.md diff --git a/issue_template.md b/issue_template.md new file mode 100644 index 0000000..79a0944 --- /dev/null +++ b/issue_template.md @@ -0,0 +1,46 @@ +--- +name: Bug report +about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!* + - *Otherwise, the issue may be due to lufi itself. Refer to its documentation or repository for help.* + - *If you have a doubt, post here, we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +**Describe the bug** +*A clear and concise description of what the bug is.* + +**Versions** +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +**To Reproduce** +*Steps to reproduce the behavior.* +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install lufi + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '....'* + 3. *Scroll down to '....'* + 4. *See error* + +**Expected behavior** +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +**Logs** +*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.* +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..93994e7 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,18 @@ +## Problem +- *Description of why you made this PR* + +## Solution +- *And how do you fix that problem* + +## PR Status +- [ ] Code finished. +- [ ] Tested with Package_check. +- [ ] Fix or enhancement tested. +- [ ] Upgrade from last version tested. +- [ ] Can be reviewed and tested. + +## Package_check results +--- +*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* + +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/lufi_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/lufi_ynh%20PR-NUM-%20(USERNAME)/) From 51b72a5a4fb1b8eacce24c55d326b3c7426b7e17 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 29 May 2020 22:37:32 +0200 Subject: [PATCH 12/22] downgrade to 0.03.5 --- README.md | 2 +- README_fr.md | 2 +- conf/app.src | 4 ++-- manifest.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 17704a2..130cfb5 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The administrator of the Lufi instance you use will not be able to see what is i The encryption key part of the URL is a anchor (Cf. [Fragment Identifier](https://en.wikipedia.org/wiki/Fragment_identifier)), that means this part is only processed client-side and does not reach the server. :-) -**Shipped version:** 0.04.6 +**Shipped version:** 0.03.5 ## Screenshots diff --git a/README_fr.md b/README_fr.md index d9648b3..f1343e2 100644 --- a/README_fr.md +++ b/README_fr.md @@ -15,7 +15,7 @@ Est-ce tout? Non. Tous les fichiers sont cryptés par le navigateur! Non chiffr La clé de cryptage est une ancre (voir [Fragment Identifier](https://en.wikipedia.org/wiki/Fragment_identifier)), ce qui signifie que cette partie n'est traitée que par le client et n'atteint pas le serveur. :-) -**Version incluse:** 0.04.6 +**Version incluse:** 0.03.5 ## Captures d'écran diff --git a/conf/app.src b/conf/app.src index 0ae9db3..3b1e0b7 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lufi/-/archive/0.04.6/lufi-0.04.6.tar.gz -SOURCE_SUM=2d1f7e174129164fbb4474188dac0b5f358c14e01f5feacf69ec342cf58ff925 +SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lufi/-/archive/0.03.5/lufi-0.03.5.tar.gz +SOURCE_SUM=aeb4bb4e7b4d5a7a12a7b8a49578e98c4ef8b6cb606b266b4531767a6ea6debe SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 65e64a4..c47704d 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Self hosting files and sharing anonymous application", "fr": "Application d'hébergement et de partage de fichiers anonyme" }, - "version": "0.04.6~ynh1", + "version": "0.03.5~ynh1", "url": "https://git.framasoft.org/luc/lufi", "license": "AGPL-3.0-or-later", "maintainer": { From d30265fac53b5104f02e5d73655912c17a097d7e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 29 May 2020 22:38:22 +0200 Subject: [PATCH 13/22] Upgrade version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index c47704d..6cbbfe3 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Self hosting files and sharing anonymous application", "fr": "Application d'hébergement et de partage de fichiers anonyme" }, - "version": "0.03.5~ynh1", + "version": "0.03.5~ynh2", "url": "https://git.framasoft.org/luc/lufi", "license": "AGPL-3.0-or-later", "maintainer": { From 638d4473e8f4ffcd614952fb1883a8194e9e051b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 29 May 2020 22:49:32 +0200 Subject: [PATCH 14/22] typo --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 0ad2a25..8c811e2 100644 --- a/scripts/install +++ b/scripts/install @@ -176,7 +176,7 @@ ynh_print_info --message="Setuping a cron..." cp ../conf/cron_lufi /etc/cron.d/$app ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file="/etc/cron.d/$app" -ynh_replace_string --match_string="__USER__" --replace_string"$app" --target_file="/etc/cron.d/$app" +ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="/etc/cron.d/$app" chmod +x $final_path/script/lufi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 2df44fb..a4d5a50 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -205,7 +205,7 @@ ynh_print_info --message="Setuping cron..." cp ../conf/cron_lufi /etc/cron.d/$app ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file="/etc/cron.d/$app" -ynh_replace_string --match_string="__USER__" --replace_string"$app" --target_file="/etc/cron.d/$app" +ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="/etc/cron.d/$app" chmod +x $final_path/script/lufi #================================================= From c61a6c5186b6136af8aec233ea65b50ac876be51 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 16:34:01 +0200 Subject: [PATCH 15/22] Apply last example_ynh --- README.md | 26 +++++++++---------- README_fr.md | 63 +++++----------------------------------------- conf/nginx.conf | 1 + manifest.json | 4 +-- scripts/backup | 60 ++++++++++++++++--------------------------- scripts/change_url | 23 ++++++++--------- scripts/install | 53 +++++++++++++++++++------------------- scripts/remove | 28 ++++++++++----------- scripts/restore | 33 ++++++++++++------------ scripts/upgrade | 48 ++++++++++++++++++----------------- 10 files changed, 134 insertions(+), 205 deletions(-) diff --git a/README.md b/README.md index 130cfb5..974b158 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Lufi for YunoHost -[![Integration level](https://dash.yunohost.org/integration/lufi.svg)](https://dash.yunohost.org/appci/app/lufi) +[![Integration level](https://dash.yunohost.org/integration/lufi.svg)](https://dash.yunohost.org/appci/app/lufi) ![](https://ci-apps.yunohost.org/ci/badges/lufi.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/lufi.maintain.svg) [![Install Lufi with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lufi) *[Lire ce readme en français.](./README_fr.md)* -> *This package allow you to install Lufi quickly and simply on a YunoHost server. -If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* +> *This package allows you to install Lufi quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview It stores files and allows you to download them. @@ -28,7 +28,7 @@ The encryption key part of the URL is a anchor (Cf. [Fragment Identifier](https: ## Configuration -How to configure this app: a plain file with SSH. +How to configure this app: a plain file at `/var/www/lufi/lufi.conf` with SSH. ## Documentation @@ -36,30 +36,31 @@ How to configure this app: a plain file with SSH. ## YunoHost specific features -#### Multi-users support +#### Multi-user support Are LDAP and HTTP auth supported? **Yes** Can the app be used by multiple users? **Yes** #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lufi%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/lufi/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lufi%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lufi/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lufi%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/lufi/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lufi%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lufi/) + +**More info on the documentation page:** +https://yunohost.org/packaging_apps ## Links * Report a bug: https://github.com/YunoHost-Apps/lufi_ynh/issues - * App website: https://framagit.org/fiat-tux/hat-softwares/lufi * Upstream app repository: https://framagit.org/fiat-tux/hat-softwares/lufi * YunoHost website: https://yunohost.org/ --- -Developers info +Developer info ---------------- -**Only if you want to use a testing branch for coding, instead of merging directly into master.** -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/lufi_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/lufi_ynh/tree/testing). To try the testing branch, please proceed like that. ``` @@ -67,6 +68,3 @@ sudo yunohost app install https://github.com/YunoHost-Apps/lufi_ynh/tree/testing or sudo yunohost app upgrade lufi -u https://github.com/YunoHost-Apps/lufi_ynh/tree/testing --debug ``` - -**More information on the documentation page:** -https://yunohost.org/packaging_apps diff --git a/README_fr.md b/README_fr.md index f1343e2..c51b73e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,12 +1,12 @@ # Lufi pour YunoHost -[![Integration level](https://dash.yunohost.org/integration/lufi.svg)](https://dash.yunohost.org/appci/app/lufi) -[![Install Lufi with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lufi) +[![Niveau d'intégration](https://dash.yunohost.org/integration/lufi.svg)](https://dash.yunohost.org/appci/app/lufi) ![](https://ci-apps.yunohost.org/ci/badges/lufi.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/lufi.maintain.svg) +[![Installer Lufi avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lufi) *[Read this readme in english.](./README.md)* > *Ce package vous permet d'installer Lufi rapidement et simplement sur un serveur Yunohost. -Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* +Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* ## Vue d'ensemble Il stocke vos fichiers et vous permet de les télécharger. @@ -35,21 +35,19 @@ Comment configurer cette application: un fichier brut en SSH. ## Caractéristiques spécifiques YunoHost -#### Support multi-utilisateurs +#### Support multi-utilisateur L'authentification LDAP et HTTP est-elle prise en charge? **Oui** L'application peut-elle être utilisée par plusieurs utilisateurs? **Oui** #### Architectures supportées -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lufi%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/lufi/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lufi%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lufi/) - +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lufi%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/lufi/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lufi%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lufi/) ## Liens * Signaler un bug: https://github.com/YunoHost-Apps/lufi_ynh/issues - * Site de l'application: https://framagit.org/fiat-tux/hat-softwares/lufi * Dépôt de l'application principale: https://framagit.org/fiat-tux/hat-softwares/lufi * Site web YunoHost: https://yunohost.org/ @@ -58,7 +56,6 @@ L'application peut-elle être utilisée par plusieurs utilisateurs? **Oui** Informations pour les développeurs ---------------- -**Seulement si vous voulez utiliser une branche de test pour le codage, au lieu de fusionner directement dans la banche principale.** Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/lufi_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. @@ -67,51 +64,3 @@ sudo yunohost app install https://github.com/YunoHost-Apps/lufi_ynh/tree/testing ou sudo yunohost app upgrade lufi -u https://github.com/YunoHost-Apps/lufi_ynh/tree/testing --debug ``` - -**Plus d'informations sur la page de documentation:** -https://yunohost.org/packaging_apps - -# Lufi for YunoHost - -[![Latest Version](https://img.shields.io/badge/version-_--_-green.svg?style=flat)](https://github.com/YunoHost-Apps/lufi_ynh/releases) -[![Status](https://img.shields.io/badge/status-working-yellow.svg?style=flat)](https://github.com/YunoHost-Apps/lufi_ynh/milestones) -[![Dependencies](https://img.shields.io/badge/dependencies-includes-lightgrey.svg?style=flat)](https://github.com/YunoHost-Apps/lufi_ynh#dependencies) -[![GitHub license](https://img.shields.io/badge/license-GPLv3-blue.svg?style=flat)](https://raw.githubusercontent.com/YunoHost-Apps/lufi_ynh/master/LICENSE) -[![Yunohost version](https://img.shields.io/badge/yunohost-2.4.2_tested-orange.svg?style=flat)](https://github.com/YunoHost/yunohost) -[![GitHub issues](https://img.shields.io/github/issues/YunoHost-Apps/lufi_ynh.svg?style=flat)](https://github.com/YunoHost-Apps/lufi_ynh/issues) - -## Lufi c'est quoi ? - -Il stocke vos fichiers et vous permet de les télécharger. - -Est-ce tout? Non. Tous les fichiers sont cryptés par le navigateur! Non chiffré. Ça ne marche pas. L'administrateur de l'instance Lufi ne pourra pas voir quel est votre administrateur réseau ou votre FAI. - -La clé de cryptage est une ancre (voir Fragment Identifier), ce qui signifie que cette partie n'est traitée que par le client et n'atteint pas le serveur. :-) - -Source: [Documentation de Lufi](https://framagit.org/luc/lufi/wikis/home) - -### Installation - -`$ sudo yunohost app install https://github.com/YunoHost-Apps/lufi_ynh.git` - -### Mise à jour - -`$ sudo yunohost app upgrade --verbose lufi -u https://github.com/YunoHost-Apps/lufi_ynh.git` - -## What is Lufi? - -It stores files and allows you to download them. - -Is that all? No. All the files are encrypted by the browser! It means that your files never leave your computer unencrypted. The administrator of the Lufi instance you use will not be able to see what is in your file, neither will your network administrator, or your ISP. - -The encryption key part of the URL is a anchor (Cf. Fragment Identifier), that means this part is only processed client-side and does not reach the server. :-) - -Source: [Lufi documentation](https://framagit.org/luc/lufi/wikis/home) - -### Install - -`$ sudo yunohost app install https://github.com/YunoHost-Apps/lufi_ynh.git` - -### Update - -`$ sudo yunohost app upgrade --verbose lufi -u https://github.com/YunoHost-Apps/lufi_ynh.git` diff --git a/conf/nginx.conf b/conf/nginx.conf index aed2041..4feb38f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,6 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { + if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } diff --git a/manifest.json b/manifest.json index 6cbbfe3..707e8a3 100644 --- a/manifest.json +++ b/manifest.json @@ -26,8 +26,8 @@ "name": "domain", "type": "domain", "ask": { - "en": "Choose a domain for Lufi", - "fr": "Choisissez un domaine pour Lufi" + "en": "Choose a domain name for Lufi", + "fr": "Choisissez un nom de domaine pour Lufi" }, "example": "domain.org" }, diff --git a/scripts/backup b/scripts/backup index ec97225..b8decc0 100644 --- a/scripts/backup +++ b/scripts/backup @@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -33,28 +32,43 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP #================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_print_info --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="$final_path/log/production.log" +ynh_print_info --message="Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info --message="Backing up the main app directory..." ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Backing up nginx web server configuration..." ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= + +ynh_backup --src_path="/etc/logrotate.d/$app" + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup --src_path="/etc/systemd/system/$app.service" + +#================================================= +# BACKUP A CRON FILE +#================================================= + +ynh_backup --src_path="/etc/cron.d/$app" + #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= @@ -62,36 +76,6 @@ ynh_print_info --message="Backing up the PostgreSQL database..." ynh_psql_dump_db --database="$db_name" > db.sql -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= -ynh_print_info --message="Backing up logrotate configuration..." - -ynh_backup --src_path="/etc/logrotate.d/$app" - -#================================================= -# BACKUP SYSTEMD -#================================================= -ynh_print_info --message="Backing up systemd configuration..." - -ynh_backup --src_path="/etc/systemd/system/$app.service" - -#================================================= -# BACKUP A CRON FILE -#================================================= -ynh_print_info --message="Backing up a cron file..." - -ynh_backup --src_path="/etc/cron.d/$app" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_print_info --message="Starting a systemd service..." - -ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/production.log" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index b38781b..9b72f3f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,7 +12,6 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= -ynh_print_info --message="Retrieve arguments from the manifest" old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH @@ -25,12 +24,12 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -# Needed for lufi conf +# Add settings here as needed by your application port=$(ynh_app_setting_get --app=$app --key=port) is_public=$(ynh_app_setting_get --app=$app --key=is_public) db_name=$(ynh_app_setting_get --app=$app --key=db_name) @@ -42,7 +41,7 @@ max_file_size=$(ynh_app_setting_get --app=$app --key=max_file_size) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info --message="Backing up the app before changing its url (may take a while)..." +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -77,14 +76,14 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_print_info --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="$final_path/log/production.log" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_print_info --message="Updating nginx web server configuration..." +ynh_script_progression --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -113,9 +112,9 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= -# SETUP LUFI +# CONFIGURE LUFI #================================================= -ynh_print_info --message="Configuring lufi..." +ynh_script_progression --message="Configuring lufi..." domain="$new_domain" path_url="$new_path" @@ -145,7 +144,7 @@ ynh_store_file_checksum --file="$config" #================================================= # UPDATE SSOWAT #================================================= -ynh_print_info --message="Reconfigure SSOwat" +ynh_script_progression --message="Reconfigure SSOwat" ynh_app_setting_set $app unprotected_uris "/" if [ $is_public -eq 0 ] @@ -164,14 +163,14 @@ fi #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/production.log" --line_match="Creating process id file" #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -179,4 +178,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Change of URL completed for $app" +ynh_script_progression --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 8c811e2..9680758 100644 --- a/scripts/install +++ b/scripts/install @@ -12,7 +12,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -23,20 +22,19 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -ynh_print_info --message="Retrieving arguments from the manifest..." domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH max_file_size=$YNH_APP_ARG_MAX_FILE_SIZE is_public=$YNH_APP_ARG_IS_PUBLIC -secret=$(ynh_string_random 24) +secret=$(ynh_string_random --length=24) app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info --message="Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -57,7 +55,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_print_info --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url @@ -70,7 +68,7 @@ ynh_app_setting_set --app=$app --key=secret --value=$secret #================================================= # FIND AND OPEN A PORT #================================================= -ynh_print_info --message="Configuring firewall..." +ynh_script_progression --message="Configuring firewall..." # Find an available port port=$(ynh_find_port --port=8095) @@ -86,7 +84,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_print_info --message="Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies @@ -96,21 +94,20 @@ echo yes | cpanm Carton #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Creating a PostgreSQL database..." +ynh_script_progression --message="Creating a PostgreSQL database..." # Create postgresql database ynh_psql_test_if_first_run db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name -# Initialize database and store postgres password for upgrade ynh_psql_setup_db --db_user=$db_user --db_name=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # Password created in ynh_psql_setup_db function #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src @@ -119,7 +116,7 @@ ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info --message="Configuring nginx web server..." +ynh_script_progression --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config max_file_size @@ -127,7 +124,7 @@ ynh_add_nginx_config max_file_size #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info --message="Configuring system user..." +ynh_script_progression --message="Configuring system user..." # Create a system user ynh_system_user_create --username=$app @@ -137,7 +134,7 @@ ynh_system_user_create --username=$app #================================================= # CONFIGURE LUFI #================================================= -ynh_print_info --message="Configuring lufi..." +ynh_script_progression --message="Configuring lufi..." config=${final_path}/lufi.conf cp ../conf/lufi.conf.template "$config" @@ -152,18 +149,20 @@ if [ $max_file_size -eq 0 ]; then # Comment the limitation line if no limit ynh_replace_string --match_string="max_file_size" --replace_string="#max_file_size" --target_file="$config" fi ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config" + if [ $is_public -eq 0 ]; then ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="" --target_file="$config" else ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="#" --target_file="$config" fi -ynh_store_file_checksum "$config" + +ynh_store_file_checksum --file="$config" #================================================= -# INSTALL LUFI'S DEPENDENCIES VIA CARTON +# INSTALL LUFI #================================================= -ynh_print_info --message="Installing lufi..." +ynh_script_progression --message="Installing lufi..." pushd $final_path carton install --deployment --without=sqlite --without=mysql --without=htpasswd --without=test @@ -172,7 +171,7 @@ popd #================================================= # SETUP CRON #================================================= -ynh_print_info --message="Setuping a cron..." +ynh_script_progression --message="Setuping a cron..." cp ../conf/cron_lufi /etc/cron.d/$app ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file="/etc/cron.d/$app" @@ -182,7 +181,7 @@ chmod +x $final_path/script/lufi #================================================= # SETUP SYSTEMD #================================================= -ynh_print_info --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config @@ -192,7 +191,7 @@ ynh_add_systemd_config #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_print_info --message="Securing files and directories..." +ynh_script_progression --message="Securing files and directories..." # Set permissions to app files chown -R $app:$app $final_path @@ -200,7 +199,7 @@ chown -R $app:$app $final_path #================================================= # SETUP LOGROTATE #================================================= -ynh_print_info --message="Configuring log rotation..." +ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -208,22 +207,22 @@ ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_print_info --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "lufi service" --log "$final_path/log/production.log" +yunohost service add $app --description "Lufi service" --log "$final_path/log/production.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." -systemctl enable $app.service +# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --line_match="Creating process id file" --log_path="$final_path/log/production.log" #================================================= # SETUP SSOWAT #================================================= -ynh_print_info --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring SSOwat..." ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" if [ $is_public -eq 0 ] @@ -240,7 +239,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -248,4 +247,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Installation of $app completed" +ynh_script_progression --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index c1d4f34..9db5cfb 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -27,19 +27,18 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -ynh_print_info --message="Removing service integration in YunoHost..." # Remove the service from the list of services known by Yunohost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null then - ynh_print_info --message="Removing $app service..." + ynh_script_progression --message="Removing $app service..." yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_print_info --message="Stopping and removing the systemd service..." +ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config @@ -47,7 +46,7 @@ ynh_remove_systemd_config #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Removing the PostgreSQL database..." +ynh_script_progression --message="Removing the PostgreSQL database..." # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_user=$db_user --db_name=$db_name @@ -55,7 +54,7 @@ ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_print_info --message="Removing dependencies..." +ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -63,7 +62,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info --message="Removing app main directory..." +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -71,7 +70,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -79,7 +78,7 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_print_info --message="Removing logrotate configuration..." +ynh_script_progression --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate @@ -87,11 +86,10 @@ ynh_remove_logrotate #================================================= # CLOSE A PORT #================================================= -ynh_print_info --message="Closing a port..." if yunohost firewall list | grep -q "\- $port$" then - ynh_print_info --message="Closing port $port..." + ynh_script_progression --message="Closing port $port..." ynh_exec_warn_less yunohost firewall disallow TCP $port fi @@ -100,7 +98,7 @@ fi #================================================= # REMOVE THE CRON FILE #================================================= -ynh_print_info --message="Removing the cron file..." +ynh_script_progression --message="Removing the cron file..." # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" @@ -108,7 +106,7 @@ ynh_secure_remove --file="/etc/cron.d/$app" #================================================= # REMOVE LOG #================================================= -ynh_print_info --message="Removing the log file..." +ynh_script_progression --message="Removing the log file..." ynh_secure_remove --file="/var/log/$app" @@ -117,7 +115,7 @@ ynh_secure_remove --file="/var/log/$app" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info --message="Removing the dedicated system user..." +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user ynh_system_user_delete --username=$app @@ -126,4 +124,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_print_info --message="Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 09c5e8d..4f1945a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -24,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading settings..." +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -37,7 +36,7 @@ db_user=$db_name #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_print_info --message="Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -49,21 +48,21 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Restoring the nginx configuration..." +ynh_script_progression --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_print_info --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info --message="Recreating the dedicated system user..." +ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app @@ -71,7 +70,7 @@ ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS #================================================= -ynh_print_info --message="Restoring user rights..." +ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files chown -R $app:$app $final_path @@ -81,7 +80,7 @@ chown -R $app:$app $final_path #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_print_info --message="Reinstalling dependencies..." +ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -92,17 +91,17 @@ echo yes | cpanm Carton #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Restoring the PostregSQL database..." +ynh_script_progression --message="Restoring the PostregSQL database..." -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) ynh_psql_test_if_first_run +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= # RESTORE SYSTEMD #================================================= -ynh_print_info --message="Restoring the systemd configuration..." +ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service @@ -110,28 +109,28 @@ systemctl enable $app.service #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_print_info --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description "lufi service" --log "$final_path/log/production.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/production.log" --line_match="Creating process id file" #================================================= # RESTORE THE CRON FILE #================================================= -ynh_print_info --message="Restoring the cron file..." +ynh_script_progression --message="Restoring the cron file..." ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_print_info --message="Restoring the logrotate configuration..." +ynh_script_progression --message="Restoring the logrotate configuration..." ynh_restore_file --origin_path="/etc/logrotate.d/$app" @@ -140,7 +139,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -148,4 +147,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Restoration completed for $app" +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index a4d5a50..daa21ac 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -30,14 +30,14 @@ max_file_size=$(ynh_app_setting_get --app=$app --key=max_file_size) #================================================= # CHECK VERSION #================================================= -ynh_print_info --message="Checking version..." +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -48,8 +48,8 @@ elif [ "$is_public" = "No" ]; then is_public=0 fi -if [ "${#final_path}" -eq 0 ] -then # Si final_path n'est pas renseigné dans la config yunohost, cas d'ancien script, code final_path en dur +# 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 @@ -69,7 +69,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info --message="Backing up the app before upgrading (may take a while)..." +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -86,7 +86,7 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_print_info --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="$final_path/log/production.log" @@ -96,7 +96,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="$final_path/l if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_print_info --message="Upgrading source files..." + ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" @@ -105,7 +105,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config max_file_size @@ -113,14 +113,14 @@ ynh_add_nginx_config max_file_size #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_print_info --message="Upgrading dependencies..." +ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info --message="Making sure dedicated system user exists..." +ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create --username=$app @@ -146,7 +146,7 @@ fi #================================================= # SETUP LUFI #================================================= -ynh_print_info --message="Configuring lufi..." +ynh_script_progression --message="Configuring lufi..." config=${final_path}/lufi.conf ynh_backup_if_checksum_is_different --file="$config" @@ -161,20 +161,21 @@ ynh_replace_string --match_string="__MAX_FILE_SIZE__" --replace_string="$max_fil if [ $max_file_size -eq 0 ]; then # Comment the limitation line if no limit ynh_replace_string --match_string="max_file_size" --replace_string="#max_file_size" --target_file="$config" fi - ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config" + if [ $is_public -eq 0 ]; then ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="" --target_file="$config" else ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="#" --target_file="$config" fi + ynh_store_file_checksum --file="$config" #================================================= -# INSTALL LUFI'S DEPENDENCIES VIA CARTON +# BUILD LUFI #================================================= -ynh_print_info --message="Installing lufi..." +ynh_script_progression --message="Building Lufi..." pushd $final_path # Migrate from SQLite to PostgreSQL @@ -201,7 +202,7 @@ popd #================================================= # SETUP CRON #================================================= -ynh_print_info --message="Setuping cron..." +ynh_script_progression --message="Setuping cron..." cp ../conf/cron_lufi /etc/cron.d/$app ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file="/etc/cron.d/$app" @@ -211,13 +212,14 @@ chmod +x $final_path/script/lufi #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= +ynh_script_progression --message="Storing the config file checksum..." yunohost service add $app --description "lufi service" --log "$final_path/log/production.log" #================================================= # SETUP LOGROTATE #================================================= -ynh_print_info --message="Upgrading logrotate configuration..." +ynh_script_progression --message="Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append @@ -225,7 +227,7 @@ ynh_use_logrotate --non-append #================================================= # SETUP SYSTEMD #================================================= -ynh_print_info --message="Upgrading systemd configuration..." +ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config @@ -235,7 +237,7 @@ ynh_add_systemd_config #================================================= # SECURING FILES AND DIRECTORIES #================================================= -ynh_print_info --message="Securing files and directories..." +ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app: $final_path @@ -243,7 +245,7 @@ chown -R $app: $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_print_info --message="Upgrading SSOwat configuration..." +ynh_script_progression --message="Upgrading SSOwat configuration..." ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" if [ $is_public -eq 0 ] @@ -260,14 +262,14 @@ fi #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="restart" --log_path="$final_path/log/production.log" --line_match="Creating process id file" #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -275,4 +277,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Upgrade of $app completed" +ynh_script_progression --message="Upgrade of $app completed" From bbe654850ee1174e3661e97bdf14b90d7e384d95 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Jun 2020 21:56:09 +0200 Subject: [PATCH 16/22] remove service restart during upgrade --- scripts/upgrade | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index daa21ac..aff997c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -190,9 +190,6 @@ if [ $need_migration_from_sqlite_to_psql -eq 1 ]; then chown -R $app: "$final_path/log/production.log" fi - # Restart with news parameters - ynh_systemd_action --service_name=$app --action="restart" --log_path="$final_path/log/production.log" --line_match="Creating process id file" - carton exec script/lufi sqliteToOtherDB fi From f33230ddf61dff405956cc6badd7b01c9fb69204 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 3 Jun 2020 21:07:49 +0200 Subject: [PATCH 17/22] fix Error: : must be owner of extension plpgsql --- scripts/remove | 2 +- scripts/restore | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/remove b/scripts/remove index 9db5cfb..9a16cb2 100644 --- a/scripts/remove +++ b/scripts/remove @@ -49,7 +49,7 @@ ynh_remove_systemd_config ynh_script_progression --message="Removing the PostgreSQL database..." # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_user --db_name=$db_name +ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" #================================================= # REMOVE DEPENDENCIES diff --git a/scripts/restore b/scripts/restore index 4f1945a..bc340ba 100644 --- a/scripts/restore +++ b/scripts/restore @@ -32,6 +32,7 @@ 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 +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -94,9 +95,8 @@ echo yes | cpanm Carton ynh_script_progression --message="Restoring the PostregSQL database..." ynh_psql_test_if_first_run -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= # RESTORE SYSTEMD From c1d0212fc457a805b2efc6460b91dcb94e8b98e8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Jun 2020 20:25:55 +0200 Subject: [PATCH 18/22] Update README_fr.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- README_fr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_fr.md b/README_fr.md index c51b73e..a6972a3 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,7 +5,7 @@ *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer Lufi rapidement et simplement sur un serveur Yunohost. +> *Ce package vous permet d'installer Lufi rapidement et simplement sur un serveur YunoHost. Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* ## Vue d'ensemble From 11e5ea135446a91d0ff71242b2f118a8ba40cfb3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Jun 2020 20:26:10 +0200 Subject: [PATCH 19/22] Update README_fr.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- README_fr.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README_fr.md b/README_fr.md index a6972a3..c9cdaee 100644 --- a/README_fr.md +++ b/README_fr.md @@ -37,8 +37,8 @@ Comment configurer cette application: un fichier brut en SSH. #### Support multi-utilisateur -L'authentification LDAP et HTTP est-elle prise en charge? **Oui** -L'application peut-elle être utilisée par plusieurs utilisateurs? **Oui** +* L'authentification LDAP et HTTP est-elle prise en charge ? **Oui** +* L'application peut-elle être utilisée par plusieurs utilisateurs ? **Oui** #### Architectures supportées From 449c0d4e23d664ee628aa43236c419a3b2c98d93 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Jun 2020 20:26:27 +0200 Subject: [PATCH 20/22] Update README_fr.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- README_fr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_fr.md b/README_fr.md index c9cdaee..4ec8c16 100644 --- a/README_fr.md +++ b/README_fr.md @@ -42,7 +42,7 @@ Comment configurer cette application: un fichier brut en SSH. #### Architectures supportées -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lufi%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/lufi/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lufi%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/lufi/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lufi%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lufi/) ## Liens From 121370c13763ea52c6323e3917f2a9763217c03b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Jun 2020 20:26:35 +0200 Subject: [PATCH 21/22] Update README_fr.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- README_fr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_fr.md b/README_fr.md index 4ec8c16..d1b0d93 100644 --- a/README_fr.md +++ b/README_fr.md @@ -47,7 +47,7 @@ Comment configurer cette application: un fichier brut en SSH. ## Liens - * Signaler un bug: https://github.com/YunoHost-Apps/lufi_ynh/issues + * Signaler un bug : https://github.com/YunoHost-Apps/lufi_ynh/issues * Dépôt de l'application principale: https://framagit.org/fiat-tux/hat-softwares/lufi * Site web YunoHost: https://yunohost.org/ From 4c4f04d6c5e08c361ebb71c5ac98755a3c71060b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Jun 2020 20:26:41 +0200 Subject: [PATCH 22/22] Update README_fr.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- README_fr.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README_fr.md b/README_fr.md index d1b0d93..4d31869 100644 --- a/README_fr.md +++ b/README_fr.md @@ -48,8 +48,8 @@ Comment configurer cette application: un fichier brut en SSH. ## Liens * Signaler un bug : https://github.com/YunoHost-Apps/lufi_ynh/issues - * Dépôt de l'application principale: https://framagit.org/fiat-tux/hat-softwares/lufi - * Site web YunoHost: https://yunohost.org/ + * Dépôt de l'application principale : https://framagit.org/fiat-tux/hat-softwares/lufi + * Site web YunoHost : https://yunohost.org/ ---