From 2e7e0166312d93404331bfb68eaf6308b4d91543 Mon Sep 17 00:00:00 2001 From: Augustin Trancart Date: Fri, 1 May 2020 17:40:51 +0200 Subject: [PATCH 1/8] Use more_set_headers instead of add_header in nginx conf Best practice enforced by linter --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 8faded4..8252c0b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -13,7 +13,7 @@ location __PATH__ { location __PATH__/assets/ { expires max; - add_header Cache-Control public; + more_set_headers 'Cache-Control: public'; } # Include SSOWAT user panel. From eec0f52ab0e6961631efb73f87d77437aacf2439 Mon Sep 17 00:00:00 2001 From: Augustin Trancart Date: Fri, 1 May 2020 17:41:25 +0200 Subject: [PATCH 2/8] Stop using rm -rf --- scripts/backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index 56849fa..7f9f399 100644 --- a/scripts/backup +++ b/scripts/backup @@ -28,7 +28,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # STANDARD BACKUP STEPS #================================================= # clean folder -rm -rf $final_path/backup +ynh_secure_remove --file="$final_path/backup" mkdir -p $final_path/backup #================================================= # BACKUP DIASPORA DATABASE From ad2aecc38f9c5541197fb1272fc661ea4cc86145 Mon Sep 17 00:00:00 2001 From: Augustin Trancart Date: Fri, 1 May 2020 17:41:38 +0200 Subject: [PATCH 3/8] update check_process --- check_process | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/check_process b/check_process index e2678ab..df53f79 100644 --- a/check_process +++ b/check_process @@ -1,22 +1,29 @@ ;; Test complet - auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) - is_public=1 (PUBLIC|public=1|private=0) + path="/path" (PATH) + admin="john" (USER) + admin_password="pass" ; Checks pkg_linter=1 - setup_sub_dir=0 + setup_sub_dir=1 setup_root=1 setup_nourl=0 - setup_private=1 setup_public=1 upgrade=1 - backup_restore=1 - multi_instance=0 - wrong_user=0 - wrong_path=1 - incorrect_path=0 - corrupt_source=0 - fail_download_source=0 + # upgrade=1 from_commit=CommitHash + backup_restore=0 + multi_instance=1 port_already_use=0 - final_path_already_use=0 + change_url=0 +;;; Levels + # If the level 5 (Package linter) is forced to 1. Please add justifications here. + Level 5=auto +;;; Options + Email= + Notification=none +;;; Upgrade options + ; commit=CommitHash + name=Name and date of the commit. + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& + From fc428b360dd2820f9d18fb0e19b0f1c63e77a875 Mon Sep 17 00:00:00 2001 From: Augustin Trancart Date: Fri, 1 May 2020 17:41:52 +0200 Subject: [PATCH 4/8] Remove some TODO --- scripts/install | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/install b/scripts/install index 0144c55..01f1659 100755 --- a/scripts/install +++ b/scripts/install @@ -4,8 +4,6 @@ # - which service to register to ynuhosto? diaspora.target only ? All of them ? # - backup / restore # - changeurl ? Is that possible ? or even a good idea ? -# - make an admin automatically -# - integration with ssowat? Or not? How exactly? # - a setting to enable / disable registration # - say something about the registration to https://the-federation.info/ From 16d1654d1319c574b0df37cb5d312d5ecafd5edb Mon Sep 17 00:00:00 2001 From: Augustin Trancart Date: Sun, 3 May 2020 13:36:48 +0200 Subject: [PATCH 5/8] Remove the possibility to install in path, not supported upstream from an irc conv on #diaspora: 17:38 hi! Can I run diaspora on a context_path, meaning on https://domain.tld/diaspora for instance? Or can I only do it on diaspora.domain.tld? 17:46 unfortunately only the latter is really supported --- check_process | 2 +- conf/diaspora.yml | 2 +- conf/nginx.conf | 4 ++-- manifest.json | 14 ++------------ scripts/install | 13 ++++--------- 5 files changed, 10 insertions(+), 25 deletions(-) diff --git a/check_process b/check_process index df53f79..9419dab 100644 --- a/check_process +++ b/check_process @@ -6,7 +6,7 @@ admin_password="pass" ; Checks pkg_linter=1 - setup_sub_dir=1 + setup_sub_dir=0 # not supported upstream setup_root=1 setup_nourl=0 setup_public=1 diff --git a/conf/diaspora.yml b/conf/diaspora.yml index 1f5b8d3..99fc9e0 100644 --- a/conf/diaspora.yml +++ b/conf/diaspora.yml @@ -36,7 +36,7 @@ configuration: ## Section ## However changing http to https is okay and has no consequences. ## If you do change the URL, you will have to start again as the URL ## will be hardcoded into the database. - url: "https://{{ domain }}{{ path_url }}" + url: "https://{{ domain }}" ## Set the bundle of certificate authorities (CA) certificates. ## This is specific to your operating system. diff --git a/conf/nginx.conf b/conf/nginx.conf index 8252c0b..46e560a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,5 @@ # Proxy if requested file not found -location __PATH__ { +location / { root __FINALPATH__/diaspora/public; @@ -11,7 +11,7 @@ location __PATH__ { # Proxy if requested file not found try_files $uri @diaspora; - location __PATH__/assets/ { + location /assets/ { expires max; more_set_headers 'Cache-Control: public'; } diff --git a/manifest.json b/manifest.json index dac2192..6153413 100644 --- a/manifest.json +++ b/manifest.json @@ -27,21 +27,11 @@ "name": "domain", "type": "domain", "ask": { - "en": "Choose a domain for diaspora*", - "fr": "Choisissez un domaine pour diaspora*" + "en": "Choose a domain for diaspora* (it needs its own domain)", + "fr": "Choisissez un domaine pour diaspora* (diaspora* a besoin de son propre domaine)" }, "example": "domain.org" }, - { - "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for ynhexample (only / is accepted for now)", - "fr": "Choisissez un chemin pour diaspora (pour l'instant, uniquement / est accepté)" - }, - "example": "/", - "default": "/" - }, { "name": "admin", "type": "user", diff --git a/scripts/install b/scripts/install index 01f1659..7e1cddd 100755 --- a/scripts/install +++ b/scripts/install @@ -28,7 +28,6 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN admin_password=$YNH_APP_ARG_ADMIN_PASSWORD admin_email=$(ynh_user_get_info --username=$admin --key=mail) @@ -49,25 +48,22 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --time --weight=1 - -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) +ynh_script_progression --message="Validating installation parameters..." --weight=1 # Check web path availability -ynh_webpath_available --domain=$domain --path_url=$path_url +ynh_webpath_available --domain=$domain --path_url=/ # check path availability final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" # Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url +ynh_webpath_register --app=$app --domain=$domain --path_url=/ #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression --message="Saving app settings..." --time --weight=1 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=path --value=/ ynh_app_setting_set --app=$app --key=final_path --value=$final_path #================================================= @@ -125,7 +121,6 @@ popd #================================================= export app export domain -export path_url export db_pass export final_path export admin From 28ddd19abb8cb2623d68418b7745252fad832b06 Mon Sep 17 00:00:00 2001 From: Augustin Trancart Date: Sun, 3 May 2020 13:37:40 +0200 Subject: [PATCH 6/8] Remove setup_public test, does not make sense for diaspora --- check_process | 1 - 1 file changed, 1 deletion(-) diff --git a/check_process b/check_process index 9419dab..8e56d3a 100644 --- a/check_process +++ b/check_process @@ -9,7 +9,6 @@ setup_sub_dir=0 # not supported upstream setup_root=1 setup_nourl=0 - setup_public=1 upgrade=1 # upgrade=1 from_commit=CommitHash backup_restore=0 From b760cb2af9d5643af2d1ec03adb57bdbac385fb1 Mon Sep 17 00:00:00 2001 From: Augustin Trancart Date: Sun, 3 May 2020 13:38:04 +0200 Subject: [PATCH 7/8] Remove some --time --- scripts/install | 31 +++++++++++++++---------------- scripts/restore | 4 ++-- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/scripts/install b/scripts/install index 7e1cddd..29e25f9 100755 --- a/scripts/install +++ b/scripts/install @@ -61,7 +61,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=/ #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Saving app settings..." --time --weight=1 +ynh_script_progression --message="Saving app settings..." --weight=1 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=/ ynh_app_setting_set --app=$app --key=final_path --value=$final_path @@ -73,13 +73,13 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --time --weight=27 +ynh_script_progression --message="Installing dependencies..." --weight=27 ynh_install_app_dependencies $pkg_dependencies $ruby_build_dependencies #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating database..." --time --weight=1 +ynh_script_progression --message="Creating database..." --weight=1 db_name=$(ynh_sanitize_dbid $app) ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_psql_test_if_first_run @@ -89,7 +89,7 @@ db_pass=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Creating user..." --time --weight=1 +ynh_script_progression --message="Creating user..." --weight=1 # Create a system user ynh_system_user_create --username=$app --home_dir=$final_path --use_shell mkdir -p $final_path @@ -100,11 +100,11 @@ chown $app:$app $final_path #================================================= # INSTALL RVM AND RUBY FOR CURRENT USER #================================================= -ynh_script_progression --message="Installing rvm..." --time --weight=10 +ynh_script_progression --message="Installing rvm..." --weight=10 sudo -u $app gpg --import ../conf/piotr.kuczynski\@gmail.com.pgp ../conf/mpapis\@gmail.com.pgp pushd $final_path sudo -u $app curl -sSL https://get.rvm.io | sudo -u $app bash -s stable -ynh_script_progression --message="Installing ruby 2.4 (this can take a long time)..." --time --weight=230 +ynh_script_progression --message="Installing ruby 2.4 (this can take a long time)..." --weight=230 sudo -u $app $final_path/.rvm/bin/rvm autolibs read-fail sudo -u $app $final_path/.rvm/bin/rvm install 2.4 @@ -112,7 +112,7 @@ sudo -u $app $final_path/.rvm/bin/rvm install 2.4 # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= # Download, check integrity, unucompress and patch the source from app.src -ynh_script_progression --message="Download the sources..." --time --weight=16 +ynh_script_progression --message="Download the sources..." --weight=16 sudo -u $app git clone https://github.com/diaspora/diaspora.git -b v0.7.13.0 popd @@ -128,7 +128,7 @@ export admin #================================================= # CONFIGURE DIASPORA #================================================= -ynh_script_progression --message="Configure diaspora..." --time --weight=1 +ynh_script_progression --message="Configure diaspora..." --weight=1 ynh_render_template ../conf/diaspora.yml $final_path/diaspora/config/diaspora.yml ynh_render_template ../conf/database.yml $final_path/diaspora/config/database.yml @@ -136,7 +136,7 @@ ynh_render_template ../conf/database.yml $final_path/diaspora/config/database.ym # Bundle the ruby app #================================================= pushd $final_path/diaspora -ynh_script_progression --message="bundle the app..." --time --weight=1000 +ynh_script_progression --message="bundle the app..." --weight=1000 # here we *absolutely* need bash (not dash) because dash does not understand what rvm puts in .profile # (wtf rvm for assuming everybody uses bash as default shell??) # we also need a login shell to make sure .profile is loaded @@ -146,7 +146,7 @@ rvm 2.4 do gem install bundler:1.17.3 script/configure_bundler bin/bundle install --full-index --with=postgresql EOF -ynh_script_progression --message="Create db schema..." --time --weight=22 +ynh_script_progression --message="Create db schema..." --weight=22 sudo -u $app /bin/bash --login << EOF RAILS_ENV=production bundle exec rake db:migrate EOF @@ -154,7 +154,7 @@ EOF #================================================= # ASSETS PRECOMPILATION #================================================= -ynh_script_progression --message="Precompile assets..." --time --weight=400 +ynh_script_progression --message="Precompile assets..." --weight=400 sudo -u $app /bin/bash --login << EOF RAILS_ENV=production bin/rake assets:precompile EOF @@ -163,9 +163,8 @@ popd #================================================= # NGINX CONFIGURATION #================================================= -# TODO serve public/ ? # Create a dedicated nginx config -ynh_script_progression --message="configure nginx..." --time --weight=1 +ynh_script_progression --message="configure nginx..." --weight=1 ynh_add_nginx_config #================================================= @@ -173,7 +172,7 @@ ynh_add_nginx_config #================================================= # Create a dedicated systemd config # TODO add service in yunohost panel ? -ynh_script_progression --message="configure systemd unit..." --time --weight=1 +ynh_script_progression --message="configure systemd unit..." --weight=1 ynh_render_template ../conf/diaspora_sidekiq.service /etc/systemd/system/${app}_sidekiq.service ynh_render_template ../conf/diaspora_web.service /etc/systemd/system/${app}_web.service ynh_render_template ../conf/diaspora.tmpfiles.d /etc/tmpfiles.d/${app}.conf @@ -221,13 +220,13 @@ ynh_app_setting_set $app unprotected_uris "/" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reload nginx..." --time --weight=1 +ynh_script_progression --message="Reload nginx..." --weight=1 systemctl reload nginx #================================================= # CREATE AN ADMIN #================================================= -ynh_script_progression --message="Create admin..." --time --weight=1 +ynh_script_progression --message="Create admin..." --weight=1 pushd $final_path/diaspora sudo -u diaspora /bin/bash --login << EOF RAILS_ENV=production bundle exec rails console << END diff --git a/scripts/restore b/scripts/restore index 0564351..0a40cc8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -18,7 +18,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --time --weight=1 +ynh_script_progression --message="Loading settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -31,7 +31,7 @@ db_user=$db_name #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 +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}" From bf7152bc1e7ef1df70dbb495902480ee8ceb9132 Mon Sep 17 00:00:00 2001 From: Augustin Trancart Date: Sun, 3 May 2020 14:38:50 +0200 Subject: [PATCH 8/8] Make linter happy about progress indicators --- scripts/backup | 4 ++-- scripts/remove | 14 ++++++++------ scripts/restore | 2 +- scripts/upgrade | 7 ++++++- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/scripts/backup b/scripts/backup index 7f9f399..da38930 100644 --- a/scripts/backup +++ b/scripts/backup @@ -18,7 +18,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -51,7 +51,7 @@ fi #================================================= # BACKUP CONF FILES #================================================= -ynh_script_progression --message="Backup configuration files of Diaspora..." --weight=10 +ynh_script_progression --message="Backup configuration files of Diaspora..." ynh_backup --src_path="$final_path/diaspora/config/database.yml" ynh_backup --src_path="$final_path/diaspora/config/diaspora.yml" diff --git a/scripts/remove b/scripts/remove index e151849..69673e2 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= - +ynh_script_progression --message="Load settings" app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) @@ -24,7 +24,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # STOP AND REMOVE SERVICE #================================================= - +ynh_script_progression --message="Remove services" yunohost service remove $app.target systemctl stop ${app}.target ${app}_sidekiq.service ${app}_web.service systemctl disable ${app}.target ${app}_sidekiq.service ${app}_web.service @@ -48,20 +48,21 @@ fi #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= - +ynh_script_progression --message="Remove database" # Remove a database if it exists, along with the associated user ynh_psql_remove_db $db_name $db_name #================================================= # REMOVE DEPENDENCIES #================================================= - +ynh_script_progression --message="Remove app dependencies" --weight=10 # Remove metapackage and its dependencies ynh_remove_app_dependencies #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Remove nginx config" # Remove the dedicated nginx config ynh_remove_nginx_config @@ -69,7 +70,7 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= - +ynh_script_progression --message="Remove logrotate config" # Remove the app-specific logrotate config # TODO setup logrotate ? ynh_remove_logrotate @@ -79,7 +80,7 @@ ynh_remove_logrotate #================================================= # REMOVE DEDICATED USER #================================================= - +ynh_script_progression --message="Remove $app user" # Delete a system user # because we use gpg, sometimes rogue processes (gpg an d dirmngr) stays a bit, # preventing the deletion of the user. Hence we kill all processes belonging to $app @@ -89,6 +90,7 @@ ynh_system_user_delete $app #================================================= # REMOVE APP MAIN DIR #================================================= +ynh_script_progression --message="Remove $final_path" # Remove the app directory securely ynh_secure_remove "$final_path" diff --git a/scripts/restore b/scripts/restore index 0a40cc8..fe626a3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -18,7 +18,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME diff --git a/scripts/upgrade b/scripts/upgrade index 264a496..9fb9430 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= - +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME # Retrieve arguments @@ -22,6 +22,11 @@ final_path=$(ynh_app_setting_get --app $app --key final_path) ynh_abort_if_errors + +#================================================= +# Check upgrade type +#================================================= +ynh_script_progression --message="Check upgrade type..." upgrade_type=$(ynh_check_app_version_changed) # nothing to do yet!! if [ "$upgrade_type" == "UPGRADE_APP" ]