diff --git a/check_process b/check_process index e2678ab..8e56d3a 100644 --- a/check_process +++ b/check_process @@ -1,22 +1,28 @@ ;; 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=0 # not supported upstream 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& + 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 8faded4..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,9 +11,9 @@ location __PATH__ { # Proxy if requested file not found try_files $uri @diaspora; - location __PATH__/assets/ { + location /assets/ { expires max; - add_header Cache-Control public; + more_set_headers 'Cache-Control: public'; } # Include SSOWAT user panel. 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/backup b/scripts/backup index 56849fa..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 @@ -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 @@ -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/install b/scripts/install index 0144c55..29e25f9 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/ @@ -30,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) @@ -51,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_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=$path_url +ynh_app_setting_set --app=$app --key=path --value=/ ynh_app_setting_set --app=$app --key=final_path --value=$final_path #================================================= @@ -79,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 @@ -95,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 @@ -106,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 @@ -118,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 @@ -127,7 +121,6 @@ popd #================================================= export app export domain -export path_url export db_pass export final_path export admin @@ -135,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 @@ -143,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 @@ -153,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 @@ -161,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 @@ -170,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 #================================================= @@ -180,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 @@ -228,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/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 0564351..fe626a3 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..." 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}" 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" ]