diff --git a/README.md b/README.md index ff7b1b7..3a60915 100644 --- a/README.md +++ b/README.md @@ -13,26 +13,11 @@ MobiliZon aims to solve existing platform's problems to organize events in a dec Mobilizon is a tool designed to create platforms for managing communities and events. Its purpose is to help as many people as possible to free themselves from Facebook groups and events, from Meetup, etc. -**Shipped version:** 1.0.0-rc1 +**Shipped version:** 1.0.0 ## Important points to read before installing -1. **Mobilizon** is in early development, like an Alpha, all functionalities are not available 1. **Mobilizon** require a dedicated **root domain**, eg. mobilizon.domain.tld -1. Even if requested during installation: admin, language and password variables are not used -1. Admin Dashboard is still not implemented -1. When your mobilizon instance is installed, you need to register. -1. When registered, to be admin you have to manually goes in PostgreSQL, database $app, table users, and change the role value to `administrator` instead of `user` (other role available: `moderator`) - -Example to manually put user with id=1 as administrator: -```bash -su -l postgres -psql -\c mobilizon -UPDATE public.users SET role='administrator' where id=1; -\q -exit -``` ## Screenshots @@ -44,7 +29,7 @@ exit ## YunoHost specific features -#### Supported architectures +#### Supported achitectures * x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mobilizon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mobilizon/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mobilizon%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mobilizon/) diff --git a/conf/app.src b/conf/app.src index 38ed806..6c7df20 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://framagit.org/framasoft/mobilizon/-/archive/1.0.0-rc.1/mobilizon-1.0.0-rc.1.tar.gz -SOURCE_SUM=26042e61963382d02819ac75d031dbf40cec8135b34b897b8c400e6395dbd724 +SOURCE_URL=https://framagit.org/framasoft/mobilizon/-/archive/1.0.0/mobilizon-1.0.0.tar.gz +SOURCE_SUM=a66712b859b923403945ad3e1e05f3ef537c7eb2a598f511dd99018ee4c06feb SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mobilizon-1.0.0-rc.1.tar.gz +SOURCE_FILENAME=mobilizon-1.0.0.tar.gz diff --git a/conf/ldap.exs b/conf/ldap.exs new file mode 100644 index 0000000..692720e --- /dev/null +++ b/conf/ldap.exs @@ -0,0 +1,11 @@ +config :mobilizon, Mobilizon.Service.Auth.Authenticator, Mobilizon.Service.Auth.LDAPAuthenticator +config :mobilizon, :ldap, + enabled: true, + host: "localhost", + port: 389, + ssl: false, + # sslopts: [], + tls: false, + # tlsopts: [], + base: "ou=users,dc=yunohost,dc=org", + uid: "uid" diff --git a/conf/nginx.conf b/conf/nginx.conf index f90d0fb..e21dafd 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,30 +4,40 @@ location / { rewrite ^ https://$server_name$request_uri? permanent; } - gzip off; - proxy_http_version 1.1; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + # the nginx default is 1m, not enough for large media uploads + client_max_body_size 16m; - # For Websocket support + proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; - - proxy_redirect off; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://localhost:__PORT__; - client_max_body_size 16m; - location ~* \.(css|js)$ { root __FINALPATH__/mobilizon/priv/static; etag off; - expires 1y; access_log off; - add_header Cache-Control public; + more_set_headers "Cache-Control: public, max-age=31536000, immutable"; } + location ~ ^/(media|proxy) { + etag off; + access_log off; + more_set_headers "Cache-Control: public, max-age=31536000, immutable"; + proxy_pass http://localhost:__PORT__; + } + + error_page 500 501 502 503 504 @error; + # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } + +location @error { + root __FINALPATH__/mobilizon/priv/errors; + try_files /error.html 502; +} diff --git a/issue_template.md b/issue_template.md index e7ad54a..4713927 100644 --- a/issue_template.md +++ b/issue_template.md @@ -1,22 +1,24 @@ --- 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. +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. --- **How to post a meaningful bug report** 1. *Read this whole template first.* -2. *Determine if you are on the right place:* +2. *Make sure 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 Mobilizon 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.* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* + - *In doubt, ask here and we will figure it out together.* +3. *Delete these italic comments as you write over them below, and remove this guide.* --- -**Describe the bug** +### Describe the bug + *A clear and concise description of what the bug is.* -**Versions** +### Context + - 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 | ...* @@ -25,8 +27,8 @@ about: Create a report to help us debug, it would be nice to fill the template a - 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.* +### Steps to reproduce + - *If you performed a command from the CLI, the command itself is enough. For example:* ```sh sudo yunohost app install mobilizon @@ -38,9 +40,16 @@ about: Create a report to help us debug, it would be nice to fill the template a 3. *Scroll down to '....'* 4. *See error* -**Expected behavior** +### 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.* +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + *If applicable and useful, add screenshots to help explain your problem.* diff --git a/manifest.json b/manifest.json index 6bf5035..19fcdec 100644 --- a/manifest.json +++ b/manifest.json @@ -6,14 +6,14 @@ "en": "A decentralized and federated platform to organize events", "fr": "Une plateforme décentralisée et fédérée pour organiser des événements" }, - "version": "1.0.0-rc1~ynh1", + "version": "1.0.0~ynh1", "url": "https://joinmobilizon.org/", "license": "AGPL-3.0-or-later", "maintainer": { "name": "yalh76" }, "requirements": { - "yunohost": ">= 3.5" + "yunohost": ">= 4.0" }, "multi_instance": true, "services": [ @@ -35,7 +35,7 @@ "type": "user", "ask": { "en": "Choose an admin user", - "fr": "Choisissez l’administrateur" + "fr": "Choisissez l'administrateur" }, "example": "johndoe" }, diff --git a/scripts/_common.sh b/scripts/_common.sh index f2efa95..4cb929b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="build-essential inotify-tools postgresql postgresql-client postgresql-contrib git curl gnupg openssl postgis make gcc libc-dev argon2 imagemagick webp gifsicle jpegoptim optipng pngquant cmake" +pkg_dependencies="build-essential inotify-tools postgresql postgresql-client postgresql-contrib git curl unzip gnupg openssl postgis make gcc libc-dev argon2 imagemagick webp gifsicle jpegoptim optipng pngquant cmake" extra_pkg_dependencies="elixir esl-erlang" NODEJS_VERSION=12 diff --git a/scripts/change_url b/scripts/change_url index ab619ce..8a9902b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -113,14 +113,10 @@ fi ynh_script_progression --message="Modifying a config file..." config="$final_path/$app/config/prod.secret.exs" +ynh_backup_if_checksum_is_different --file="$config" + ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$config" -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." - -ynh_backup_if_checksum_is_different --file="$config" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$config" diff --git a/scripts/install b/scripts/install index c930926..15c071a 100644 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ynh_clean_check_starting + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -144,7 +144,7 @@ chown -R "$app":"$app" "$final_path" config="$final_path/$app/config/prod.secret.exs" pushd $final_path/$app/js - ynh_use_nodejs + ynh_use_nodejs sudo -u $app env PATH=$PATH yarn install sudo -u $app env PATH=$PATH NODE_BUILD_MEMORY=1024 yarn run build popd @@ -155,6 +155,13 @@ pushd $final_path/$app sudo -u "$app" MIX_ENV=prod mix deps.get sudo -u "$app" MIX_ENV=prod mix compile sudo -u "$app" MIX_ENV=prod mix mobilizon.instance gen --force --output $config --output-psql /tmp/setup_db.psql --domain $domain --instance-name $name --admin-email $admin_email --dbhost localhost --dbname $db_name --dbuser $db_user --dbpass $db_pwd --listen-port $port +popd + +cat "../conf/ldap.exs" >> "$config" + +pushd $final_path/$app + chown o-rwx $config + ynh_secure_remove --file="/tmp/setup_db.psql" sudo -u "$app" MIX_ENV=prod mix ecto.migrate sudo -u "$app" MIX_ENV=prod mix mobilizon.users.new "$admin_email" --admin --password "$password" popd diff --git a/scripts/remove b/scripts/remove index 97cc9be..7a6b0af 100644 --- a/scripts/remove +++ b/scripts/remove @@ -31,7 +31,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # 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_script_progression --message="Removing $app service..." + ynh_script_progression --message="Removing $app service integration..." yunohost service remove $app fi @@ -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/upgrade b/scripts/upgrade index a6f80a3..bc5413d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_package_version source /usr/share/yunohost/helpers #================================================= @@ -37,6 +38,10 @@ ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) +abort_if_up_to_date +# previous function is what defines 'version', more precisely the 'previous version' +previous_version="${version}" + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -91,6 +96,23 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped" +#================================================= +# UPGRADE FROM PREVIOUS VERSION +#================================================= + +if ynh_version_gt "0.1.1" "${previous_version}" ; then + ynh_script_progression --message="Upgrade configuration to 1.0.0..." + + config="$final_path/$app/config/prod.secret.exs" + ynh_backup_if_checksum_is_different --file="$config" + + # Implement ldap + cat "../conf/ldap.exs" >> "$config" + + # Recalculate and store the checksum of the file for the next upgrade. + ynh_store_file_checksum --file="$config" +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -103,10 +125,7 @@ then tmpdir="$(mktemp -d)" # Backup the config file in the temp dir - if [ -s "$final_path/$app/config/prod.exs" ] - then - cp -a "$final_path/$app/config/prod.exs" "$tmpdir/prod.secret.exs" - fi + cp -a "$final_path/$app/config/prod.secret.exs" "$tmpdir/prod.secret.exs" # Remove the app directory securely ynh_secure_remove --file="$final_path/$app" @@ -115,10 +134,7 @@ then ynh_setup_source --dest_dir="$final_path/$app" #Copy the admin saved settings from tmp directory to final path - if [ -s "$tmpdir/prod.exs" ] - then - cp -a "$tmpdir/prod.exs" "$final_path/$app/config/prod.secret.exs" - fi + cp -a "$tmpdir/prod.secret.exs" "$final_path/$app/config/prod.secret.exs" # Remove the tmp directory securely ynh_secure_remove --file="$tmpdir" @@ -161,6 +177,7 @@ ynh_script_progression --message="Modifying a config file..." config="$final_path/$app/config/prod.secret.exs" ynh_backup_if_checksum_is_different --file="$config" +chown o-rwx $config #================================================= # MAKE SETUP @@ -171,9 +188,9 @@ chown -R "$app":"$app" "$final_path" pushd $final_path/$app/js ynh_script_progression --message="Building NodeJS..." - ynh_use_nodejs + ynh_use_nodejs sudo -u $app env PATH=$PATH yarn install - sudo -u $app env PATH=$PATH NODE_BUILD_MEMORY=1024 yarn run build + sudo -u $app env PATH=$PATH yarn run build popd pushd $final_path/$app @@ -183,12 +200,14 @@ pushd $final_path/$app sudo -u "$app" MIX_ENV=prod mix deps.get sudo -u "$app" MIX_ENV=prod mix compile sudo -u "$app" MIX_ENV=prod mix ecto.migrate + popd #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= ynh_script_progression --message="Storing the config file checksum..." + # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$config" @@ -210,6 +229,20 @@ ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R "$app":"$app" "$final_path" +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description "$app daemon for Mobilizon" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access Mobilizon.Web.Endpoint at" + #================================================= # SETUP SSOWAT #================================================= @@ -222,13 +255,6 @@ then ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." - -ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access Mobilizon.Web.Endpoint at" - #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/ynh_package_version b/scripts/ynh_package_version new file mode 100644 index 0000000..d6cdc4d --- /dev/null +++ b/scripts/ynh_package_version @@ -0,0 +1,26 @@ +#!/bin/bash + +read_json () { + sudo python3 -c "import sys, json;print(json.load(open('$1'))['$2'])" +} + +read_manifest () { + if [ -f '../manifest.json' ] ; then + read_json '../manifest.json' "$1" + else + read_json '../settings/manifest.json' "$1" + fi +} +abort_if_up_to_date () { + version=$(read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" 'version' 2> /dev/null || echo '20160501-7') + last_version=$(read_manifest 'version') + if [ "${version}" = "${last_version}" ]; then + ynh_print_info "Up-to-date, nothing to do" + ynh_die "" 0 + fi +} + +ynh_version_gt () +{ + dpkg --compare-versions "$1" gt "$2" +}