1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mobilizon_ynh.git synced 2024-09-03 19:46:19 +02:00

Merge pull request #122 from YunoHost-Apps/testing

Upgrade to 2.0.2
This commit is contained in:
yalh76 2022-01-13 20:42:27 +01:00 committed by GitHub
commit aa3a3baa70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 174 additions and 216 deletions

View file

@ -17,7 +17,13 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
A decentralized and federated platform to organize events A decentralized and federated platform to organize events
**Shipped version:** 1.3.2~ynh1 - Mobilizon is a tool that helps you find, create and organize events.
- You can also create a page for your group where the members will be able to get organized together.
**Shipped version:** 2.0.2~ynh1
**Demo:** https://demo.mobilizon.org **Demo:** https://demo.mobilizon.org
@ -27,14 +33,12 @@ A decentralized and federated platform to organize events
## Disclaimers / important information ## Disclaimers / important information
* Any known limitations, constrains or stuff not working, such as (but not limited to): * **Mobilizon** require a dedicated **root domain**, eg. mobilizon.domain.tld
* **Mobilizon** require a dedicated **root domain**, eg. mobilizon.domain.tld * To connect as **Mobilizon** administrator, use the email address and password of the user you choose during install
* To connect as **Mobilizon** administrator, use the email address and password of the user you choose during install * By default registrations are closed
* By default registrations are closed * All YunoHost users are allowed to connect
* All YunoHost users are allowed to connect
* Other infos that people should be aware of, such as: * Configuration can be made in the Mobilizon administration panel.
* Configuration can be made in the Mobilizon administration panel.
## Documentation and resources ## Documentation and resources

View file

@ -11,9 +11,15 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
## Vue d'ensemble ## Vue d'ensemble
Une plateforme décentralisée et fédérée pour organiser des événements A decentralized and federated platform to organize events
**Version incluse :** 1.3.2~ynh1 - Mobilizon is a tool that helps you find, create and organize events.
- You can also create a page for your group where the members will be able to get organized together.
**Version incluse :** 2.0.2~ynh1
**Démo :** https://demo.mobilizon.org **Démo :** https://demo.mobilizon.org
@ -23,14 +29,12 @@ Une plateforme décentralisée et fédérée pour organiser des événements
## Avertissements / informations importantes ## Avertissements / informations importantes
* Any known limitations, constrains or stuff not working, such as (but not limited to): * **Mobilizon** require a dedicated **root domain**, eg. mobilizon.domain.tld
* **Mobilizon** require a dedicated **root domain**, eg. mobilizon.domain.tld * To connect as **Mobilizon** administrator, use the email address and password of the user you choose during install
* To connect as **Mobilizon** administrator, use the email address and password of the user you choose during install * By default registrations are closed
* By default registrations are closed * All YunoHost users are allowed to connect
* All YunoHost users are allowed to connect
* Other infos that people should be aware of, such as: * Configuration can be made in the Mobilizon administration panel.
* Configuration can be made in the Mobilizon administration panel.
## Documentations et ressources ## Documentations et ressources

View file

@ -22,8 +22,10 @@
upgrade=1 from_commit=b63c7833f80de56bbc4a255ddda3b865a5637afc upgrade=1 from_commit=b63c7833f80de56bbc4a255ddda3b865a5637afc
# 1.2.3~ynh1 # 1.2.3~ynh1
upgrade=1 from_commit=42d479d2cc5bcdc40806ac01802d8eac9df5b2ea upgrade=1 from_commit=42d479d2cc5bcdc40806ac01802d8eac9df5b2ea
# 1.3.2~ynh1
upgrade=1 from_commit=e3c0b208c0b76a55e8df2a3947f57bb762b017d4
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=0
port_already_use=0 port_already_use=0
change_url=1 change_url=1
;;; Options ;;; Options
@ -38,3 +40,5 @@ Notification=all
name=1.2.2~ynh1 name=1.2.2~ynh1
; commit=42d479d2cc5bcdc40806ac01802d8eac9df5b2ea ; commit=42d479d2cc5bcdc40806ac01802d8eac9df5b2ea
name=1.2.3~ynh1 name=1.2.3~ynh1
; commit=e3c0b208c0b76a55e8df2a3947f57bb762b017d4
name=1.3.2~ynh1

7
conf/amd64.src Normal file
View file

@ -0,0 +1,7 @@
SOURCE_URL=https://packages.joinmobilizon.org/2.0.2/mobilizon_2.0.2_amd64.tar.gz
SOURCE_SUM=1c734435f9e23e599de2de057a95b25a978ae5bd65ffbd95213c4e0da40fc592
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://framagit.org/framasoft/mobilizon/-/archive/1.3.2/mobilizon-1.3.2.tar.gz
SOURCE_SUM=74af9537ddd3ab4f549ee67e6e9b9b67946cf687c6f325b53947741348105e0a
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=mobilizon-1.3.2.tar.gz
SOURCE_EXTRACT=true

7
conf/arm.src Normal file
View file

@ -0,0 +1,7 @@
SOURCE_URL=https://packages.joinmobilizon.org/2.0.2/mobilizon_2.0.2_arm.tar.gz
SOURCE_SUM=1ac4241b46cf9b165a7fdf641af16310aceb36bbb411ac477332af4057826b3c
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

7
conf/arm64.src Normal file
View file

@ -0,0 +1,7 @@
SOURCE_URL=https://packages.joinmobilizon.org/2.0.2/mobilizon_2.0.2_arm64.tar.gz
SOURCE_SUM=f8dbc38c7d61f0f10001df3ddf934d9c6313af614d8980f2ff19624058e68d4a
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -19,15 +19,7 @@ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
location / { location / {
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
proxy_pass http://localhost:__PORT__; proxy_pass http://localhost:__PORT__;
# Include SSOWAT user panel.
# include conf.d/yunohost_panel.conf.inc;
} }
location ~ ^/(js|css) { location ~ ^/(js|css) {

View file

@ -5,8 +5,8 @@ After=network.target postgresql.service
[Service] [Service]
User=__APP__ User=__APP__
WorkingDirectory=__FINALPATH__/live/ WorkingDirectory=__FINALPATH__/live/
ExecStart=/usr/bin/env mix phx.server ExecStart=__FINALPATH__/live/bin/mobilizon start
ExecReload=/bin/kill $MAINPID ExecStop=__FINALPATH__/live/bin/mobilizon stop
KillMode=process KillMode=process
Restart=on-failure Restart=on-failure
Environment=MIX_ENV=prod Environment=MIX_ENV=prod
@ -14,14 +14,14 @@ Environment=MIX_ENV=prod
SyslogIdentifier=mobilizon SyslogIdentifier=mobilizon
; Some security directives. ; Some security directives.
; Ensures that the service process and all its children can never gain new privileges through execve().
NoNewPrivileges=yes
; Use private /tmp and /var/tmp folders inside a new file system namespace, which are discarded after the process stops. ; Use private /tmp and /var/tmp folders inside a new file system namespace, which are discarded after the process stops.
PrivateTmp=true PrivateTmp=yes
; Sets up a new /dev mount for the process and only adds API pseudo devices like /dev/null, /dev/zero or /dev/random but not physical devices. Disabled by default because it may not work on devices like the Raspberry Pi.
PrivateDevices=no
; Mount /usr, /boot, and /etc as read-only for processes invoked by this service. ; Mount /usr, /boot, and /etc as read-only for processes invoked by this service.
ProtectSystem=full ProtectSystem=full
; Sets up a new /dev mount for the process and only adds API pseudo devices like /dev/null, /dev/zero or /dev/random but not physical devices. Disabled by default because it may not work on devices like the Raspberry Pi.
PrivateDevices=false
; Ensures that the service process and all its children can never gain new privileges through execve().
NoNewPrivileges=true
[Install] [Install]

6
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1,6 @@
A decentralized and federated platform to organize events
- Mobilizon is a tool that helps you find, create and organize events.
- You can also create a page for your group where the members will be able to get organized together.

View file

@ -1,8 +1,6 @@
* Any known limitations, constrains or stuff not working, such as (but not limited to): * **Mobilizon** require a dedicated **root domain**, eg. mobilizon.domain.tld
* **Mobilizon** require a dedicated **root domain**, eg. mobilizon.domain.tld * To connect as **Mobilizon** administrator, use the email address and password of the user you choose during install
* To connect as **Mobilizon** administrator, use the email address and password of the user you choose during install * By default registrations are closed
* By default registrations are closed * All YunoHost users are allowed to connect
* All YunoHost users are allowed to connect
* Other infos that people should be aware of, such as: * Configuration can be made in the Mobilizon administration panel.
* Configuration can be made in the Mobilizon administration panel.

View file

@ -6,7 +6,7 @@
"en": "A decentralized and federated platform to organize events", "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" "fr": "Une plateforme décentralisée et fédérée pour organiser des événements"
}, },
"version": "1.3.2~ynh1", "version": "2.0.2~ynh1",
"url": "https://joinmobilizon.org/", "url": "https://joinmobilizon.org/",
"upstream": { "upstream": {
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
@ -20,9 +20,9 @@
"name": "yalh76" "name": "yalh76"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.1.3" "yunohost": ">= 4.3.0"
}, },
"multi_instance": true, "multi_instance": false,
"services": [ "services": [
"nginx" "nginx"
], ],
@ -30,13 +30,11 @@
"install" : [ "install" : [
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain"
"example": "example.com"
}, },
{ {
"name": "admin", "name": "admin",
"type": "user", "type": "user"
"example": "johndoe"
}, },
{ {
"name": "is_public", "name": "is_public",

View file

@ -5,10 +5,7 @@
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app
pkg_dependencies="build-essential inotify-tools postgresql postgresql-client postgresql-contrib postgis postgresql-postgis-scripts git curl unzip gnupg openssl make gcc libc-dev argon2 imagemagick webp gifsicle jpegoptim optipng pngquant cmake" pkg_dependencies="postgresql postgresql-client postgresql-contrib postgis postgresql-postgis-scripts argon2 imagemagick webp gifsicle jpegoptim optipng pngquant"
extra_pkg_dependencies="elixir esl-erlang"
NODEJS_VERSION=14
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS

View file

@ -63,6 +63,12 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/$app/"
#================================================= #=================================================
# BACKUP THE POSTGRESQL DATABASE # BACKUP THE POSTGRESQL DATABASE
#================================================= #=================================================

View file

@ -113,7 +113,7 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Modifying a config file..." ynh_script_progression --message="Modifying a config file..."
config="$final_path/live/config/runtime.exs" config="/etc/$app/config.exs"
ynh_backup_if_checksum_is_different --file="$config" ynh_backup_if_checksum_is_different --file="$config"
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$config" ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$config"

View file

@ -30,6 +30,8 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE language=$YNH_APP_ARG_LANGUAGE
admin_email=$(ynh_user_get_info $admin 'mail') admin_email=$(ynh_user_get_info $admin 'mail')
ynh_user_password=$(ynh_string_random --length=30) ynh_user_password=$(ynh_string_random --length=30)
architecture=$YNH_ARCH
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
@ -75,18 +77,6 @@ ynh_script_progression --message="Installing dependencies..."
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key='https://dl.yarnpkg.com/debian/pubkey.gpg'
if dpkg --compare-versions $(cat /etc/debian_version) ge 11.0
then
ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian buster contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
else
lsb_name="$(lsb_release --codename --short)"
ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian $lsb_name contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
@ -122,7 +112,7 @@ ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$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 # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path/live" ynh_setup_source --dest_dir="$final_path/live" --source_id=$architecture
chmod 750 "$final_path" chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
@ -153,62 +143,6 @@ chmod 750 "$datadir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir" chown -R $app:$app "$datadir"
#=================================================
# MAKE SETUP
#=================================================
ynh_script_progression --message="Installing dependencies and building app..." --weight=5
config="$final_path/live/config/runtime.exs"
pushd $final_path/live/js
ynh_use_nodejs
ynh_script_progression --message="Installing NodeJS dependencies (this is going to take a while...)"
ynh_exec_warn_less sudo -u $app env PATH=$PATH yarn install
ynh_script_progression --message="Building NodeJS application (this is going to take a while...)"
ynh_exec_warn_less sudo -u $app env PATH=$PATH NODE_BUILD_MEMORY=1024 yarn run build
popd
ynh_secure_remove --file="$final_path/live/js"
ynh_script_progression --message="Building Elixir application (this is going to take a while...)"
pushd $final_path/live
sudo -u "$app" MIX_ENV=prod mix local.hex --force
sudo -u "$app" MIX_ENV=prod mix local.rebar --force
ynh_exec_warn_less sudo -u "$app" MIX_ENV=prod mix deps.get
ynh_exec_warn_less 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 "Mobilizon" --admin-email "$app@$domain" --dbhost localhost --dbname $db_name --dbuser $db_user --dbpass $db_pwd --listen-port $port
popd
cat "../conf/ldap.exs" >> "$config"
cat "../conf/mail.exs" >> "$config"
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="../conf/uploads.exs"
cat "../conf/uploads.exs" >> "$config"
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
pushd $final_path/live
chmod o-rwx $config
ynh_replace_string --match_string="__YNH_USER__" --replace_string="${app}_notifs" --target_file="$config"
ynh_replace_string --match_string="__YNH_USER_PASSWORD__" --replace_string="${ynh_user_password}" --target_file="$config"
# Compile *again* because we added ldap conf in between... dunno if the first is relevant
sudo -u "$app" MIX_ENV=prod mix compile
ynh_secure_remove --file="/tmp/setup_db.psql"
sudo -u "$app" MIX_ENV=prod mix ecto.migrate
# We generate a dummy password ... this will actually *not* be used because the admin is supposed to connect via the ldap
password=$(ynh_string_random --length=30)
sudo -u "$app" MIX_ENV=prod mix mobilizon.users.new "$admin_email" --admin --password "$password"
popd
ynh_secure_remove --file="$final_path/.cache"
ynh_store_file_checksum --file="$config"
chmod 400 "$config"
chown $app:$app "$config"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
@ -217,6 +151,45 @@ ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# MAKE SETUP
#=================================================
ynh_script_progression --message="Making setup..."
mkdir -p /etc/$app
chown -R $app:$app /etc/$app
config="/etc/$app/config.exs"
pushd $final_path/live
ynh_exec_as $app MIX_ENV=prod ./bin/mobilizon_ctl instance gen --force --output $config --output-psql /tmp/setup_db.psql --domain $domain --instance-name "Mobilizon" --admin-email "$app@$domain" --dbhost localhost --dbname $db_name --dbuser $db_user --dbpass $db_pwd --listen-port $port
ynh_secure_remove --file="/tmp/setup_db.psql"
popd
cat "../conf/ldap.exs" >> "$config"
ynh_replace_string --match_string="__YNH_USER__" --replace_string="${app}_notifs" --target_file="../conf/mail.exs"
ynh_replace_string --match_string="__YNH_USER_PASSWORD__" --replace_string="${ynh_user_password}" --target_file="../conf/mail.exs"
cat "../conf/mail.exs" >> "$config"
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="../conf/uploads.exs"
cat "../conf/uploads.exs" >> "$config"
ynh_store_file_checksum --file="$config"
chmod 400 "$config"
chown $app:$app "$config"
pushd $final_path/live
ynh_exec_as $app ./bin/mobilizon_ctl migrate
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access Mobilizon.Web.Endpoint at"
# We generate a dummy password ... this will actually *not* be used because the admin is supposed to connect via the ldap
password=$(ynh_string_random --length=30)
ynh_exec_as $app ./bin/mobilizon_ctl users.new "$admin_email" --admin --password "$password"
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped"
popd
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -51,15 +51,6 @@ ynh_script_progression --message="Removing the PostgreSQL database..."
# Remove a database if it exists, along with the associated user # 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
#=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_nodejs
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
@ -68,6 +59,17 @@ ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..."
ynh_secure_remove --file="$datadir"
fi
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
@ -76,6 +78,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================
@ -83,6 +93,9 @@ ynh_remove_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Removing various files..." ynh_script_progression --message="Removing various files..."
# Remove a directory securely
ynh_secure_remove --file="/etc/$app"
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"

View file

@ -43,8 +43,6 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
ynh_script_progression --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}"
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
@ -103,18 +101,6 @@ ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies # Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key='https://dl.yarnpkg.com/debian/pubkey.gpg'
if dpkg --compare-versions $(cat /etc/debian_version) ge 11.0
then
ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian buster contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
else
lsb_name="$(lsb_release --codename --short)"
ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian $lsb_name contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
fi
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
@ -127,6 +113,13 @@ ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --datab
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
ynh_restore_file --origin_path="/etc/$app/"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================

View file

@ -29,6 +29,7 @@ port=$(ynh_app_setting_get --app=$app --key=port)
secret=$(ynh_app_setting_get --app=$app --key=secret) secret=$(ynh_app_setting_get --app=$app --key=secret)
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email) admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
architecture=$YNH_ARCH
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -111,11 +112,10 @@ if ynh_version_gt "1.0.0~ynh1" "${previous_version}" ; then
# Implement ldap and mail # Implement ldap and mail
cat "../conf/ldap.exs" >> "$config" cat "../conf/ldap.exs" >> "$config"
ynh_replace_string --match_string="__YNH_USER__" --replace_string="${app}_notifs" --target_file="../conf/mail.exs"
ynh_replace_string --match_string="__YNH_USER_PASSWORD__" --replace_string="${ynh_user_password}" --target_file="../conf/mail.exs"
cat "../conf/mail.exs" >> "$config" cat "../conf/mail.exs" >> "$config"
ynh_replace_string --match_string="__YNH_USER__" --replace_string="${app}_notifs" --target_file="$config"
ynh_replace_string --match_string="__YNH_USER_PASSWORD__" --replace_string="${ynh_user_password}" --target_file="$config"
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$config" ynh_store_file_checksum --file="$config"
fi fi
@ -161,12 +161,20 @@ if ynh_version_gt "1.2.3~ynh1" "${previous_version}" ; then
ynh_store_file_checksum --file="$final_path/live/config/runtime.exs" ynh_store_file_checksum --file="$final_path/live/config/runtime.exs"
fi fi
if [ ! -f "$final_path/live/config/runtime.exs" ]; then ynh_remove_nodejs
ynh_delete_file_checksum --file="$final_path/$app/config/prod.secret.exs"
if ynh_version_gt "2.0.2~ynh1" "${previous_version}" ; then
mkdir -p /etc/$app
if [ -f "$final_path/live/config/prod.secret.exs" ]; then
ynh_delete_file_checksum --file="$final_path/live/config/prod.secret.exs" ynh_delete_file_checksum --file="$final_path/live/config/prod.secret.exs"
mv "$final_path/live/config/prod.secret.exs" "$final_path/live/config/runtime.exs" mv -f "$final_path/live/config/prod.secret.exs" "/etc/$app/config.exs"
ynh_replace_string --match_string="server: true," --replace_string="" --target_file="$final_path/live/config/runtime.exs" fi
ynh_store_file_checksum --file="$final_path/live/config/runtime.exs" if [ -f "$final_path/live/config/runtime.exs" ]; then
ynh_delete_file_checksum --file="$final_path/live/config/runtime.exs"
mv -f "$final_path/live/config/runtime.exs" "/etc/$app/config.exs"
fi
chown -R $app:$app /etc/$app
ynh_store_file_checksum --file="/etc/$app/config.exs"
fi fi
#================================================= #=================================================
@ -185,23 +193,11 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." ynh_script_progression --message="Upgrading source files..."
# Create a temporary directory
tmpdir="$(mktemp -d)"
# Backup the config file in the temp dir
cp -af "$final_path/live/config/runtime.exs" "$tmpdir/runtime.exs"
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path/live" ynh_secure_remove --file="$final_path/live"
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path/live" ynh_setup_source --dest_dir="$final_path/live" --source_id=$architecture
# Restore the config file
cp -af "$tmpdir/runtime.exs" "$final_path/live/config/runtime.exs"
# Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir"
fi fi
chmod 750 "$final_path" chmod 750 "$final_path"
@ -223,18 +219,6 @@ ynh_script_progression --message="Upgrading dependencies..."
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key='https://dl.yarnpkg.com/debian/pubkey.gpg'
if dpkg --compare-versions $(cat /etc/debian_version) ge 11.0
then
ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian buster contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
else
lsb_name="$(lsb_release --codename --short)"
ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian $lsb_name contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
fi
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
@ -259,46 +243,18 @@ chown -R $app:$app "$datadir"
#================================================= #=================================================
# MAKE SETUP # MAKE SETUP
#================================================= #=================================================
ynh_script_progression --message="Making setup..."
pushd $final_path/live/js
ynh_use_nodejs
ynh_script_progression --message="Installing NodeJS dependencies (this is going to take a while...)"
ynh_exec_warn_less sudo -u $app env PATH=$PATH yarn install
ynh_script_progression --message="Building NodeJS application (this is going to take a while...)"
ynh_exec_warn_less sudo -u $app env PATH=$PATH NODE_BUILD_MEMORY=1024 yarn run build
sudo -u $app env PATH=$PATH yarn cache clean --all
popd
ynh_secure_remove --file="$final_path/live/js"
ynh_script_progression --message="Building Elixir application (this is going to take a while...)"
pushd $final_path/live pushd $final_path/live
sudo -u "$app" MIX_ENV=prod mix local.hex --force ynh_exec_as $app ./bin/mobilizon_ctl migrate
sudo -u "$app" MIX_ENV=prod mix local.rebar --force
ynh_exec_warn_less sudo -u "$app" MIX_ENV=prod mix deps.get
ynh_exec_warn_less sudo -u "$app" MIX_ENV=prod mix compile
sudo -u "$app" MIX_ENV=prod mix ecto.migrate
popd popd
ynh_secure_remove --file="$final_path/.cache"
#=================================================
# RUN APP MIGRATIONS
#=================================================
if ynh_version_gt "1.0.3~ynh1" "${previous_version}" ; then
ynh_script_progression --message="Mobilizon v1.0.3: Refresh remote profiles to save avatars locally"
pushd $final_path/live
sudo -u "$app" MIX_ENV=prod mix mobilizon.actors.refresh --all
popd
fi
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression --message="Updating a configuration file..."
config="$final_path/live/config/runtime.exs" config="/etc/$app/config.exs"
ynh_backup_if_checksum_is_different --file="$config" ynh_backup_if_checksum_is_different --file="$config"
ynh_store_file_checksum --file="$config" ynh_store_file_checksum --file="$config"