mirror of
https://github.com/YunoHost-Apps/mobilizon_ynh.git
synced 2024-09-03 19:46:19 +02:00
commit
aa3a3baa70
19 changed files with 174 additions and 216 deletions
20
README.md
20
README.md
|
@ -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
|
||||
|
||||
**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
|
||||
|
||||
|
@ -27,14 +33,12 @@ A decentralized and federated platform to organize events
|
|||
|
||||
## 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
|
||||
* To connect as **Mobilizon** administrator, use the email address and password of the user you choose during install
|
||||
* By default registrations are closed
|
||||
* All YunoHost users are allowed to connect
|
||||
* **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
|
||||
* By default registrations are closed
|
||||
* 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
|
||||
|
||||
|
|
22
README_fr.md
22
README_fr.md
|
@ -11,9 +11,15 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
|
|||
|
||||
## 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
|
||||
|
||||
|
@ -23,14 +29,12 @@ Une plateforme décentralisée et fédérée pour organiser des événements
|
|||
|
||||
## 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
|
||||
* To connect as **Mobilizon** administrator, use the email address and password of the user you choose during install
|
||||
* By default registrations are closed
|
||||
* All YunoHost users are allowed to connect
|
||||
* **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
|
||||
* By default registrations are closed
|
||||
* 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
|
||||
|
||||
|
|
|
@ -22,8 +22,10 @@
|
|||
upgrade=1 from_commit=b63c7833f80de56bbc4a255ddda3b865a5637afc
|
||||
# 1.2.3~ynh1
|
||||
upgrade=1 from_commit=42d479d2cc5bcdc40806ac01802d8eac9df5b2ea
|
||||
# 1.3.2~ynh1
|
||||
upgrade=1 from_commit=e3c0b208c0b76a55e8df2a3947f57bb762b017d4
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
multi_instance=0
|
||||
port_already_use=0
|
||||
change_url=1
|
||||
;;; Options
|
||||
|
@ -38,3 +40,5 @@ Notification=all
|
|||
name=1.2.2~ynh1
|
||||
; commit=42d479d2cc5bcdc40806ac01802d8eac9df5b2ea
|
||||
name=1.2.3~ynh1
|
||||
; commit=e3c0b208c0b76a55e8df2a3947f57bb762b017d4
|
||||
name=1.3.2~ynh1
|
||||
|
|
7
conf/amd64.src
Normal file
7
conf/amd64.src
Normal 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
|
|
@ -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
7
conf/arm.src
Normal 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
7
conf/arm64.src
Normal 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
|
|
@ -19,15 +19,7 @@ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
location / {
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
proxy_pass http://localhost:__PORT__;
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
# include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
||||
location ~ ^/(js|css) {
|
||||
|
|
|
@ -5,8 +5,8 @@ After=network.target postgresql.service
|
|||
[Service]
|
||||
User=__APP__
|
||||
WorkingDirectory=__FINALPATH__/live/
|
||||
ExecStart=/usr/bin/env mix phx.server
|
||||
ExecReload=/bin/kill $MAINPID
|
||||
ExecStart=__FINALPATH__/live/bin/mobilizon start
|
||||
ExecStop=__FINALPATH__/live/bin/mobilizon stop
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
Environment=MIX_ENV=prod
|
||||
|
@ -14,14 +14,14 @@ Environment=MIX_ENV=prod
|
|||
SyslogIdentifier=mobilizon
|
||||
|
||||
; 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.
|
||||
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.
|
||||
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]
|
||||
|
|
6
doc/DESCRIPTION.md
Normal file
6
doc/DESCRIPTION.md
Normal 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.
|
||||
|
|
@ -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
|
||||
* To connect as **Mobilizon** administrator, use the email address and password of the user you choose during install
|
||||
* By default registrations are closed
|
||||
* All YunoHost users are allowed to connect
|
||||
* **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
|
||||
* By default registrations are closed
|
||||
* 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.
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"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.3.2~ynh1",
|
||||
"version": "2.0.2~ynh1",
|
||||
"url": "https://joinmobilizon.org/",
|
||||
"upstream": {
|
||||
"license": "AGPL-3.0-or-later",
|
||||
|
@ -20,9 +20,9 @@
|
|||
"name": "yalh76"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.1.3"
|
||||
"yunohost": ">= 4.3.0"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
"nginx"
|
||||
],
|
||||
|
@ -30,13 +30,11 @@
|
|||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"example": "example.com"
|
||||
"type": "domain"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"example": "johndoe"
|
||||
"type": "user"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
|
|
|
@ -5,10 +5,7 @@
|
|||
#=================================================
|
||||
|
||||
# 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"
|
||||
extra_pkg_dependencies="elixir esl-erlang"
|
||||
|
||||
NODEJS_VERSION=14
|
||||
pkg_dependencies="postgresql postgresql-client postgresql-contrib postgis postgresql-postgis-scripts argon2 imagemagick webp gifsicle jpegoptim optipng pngquant"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
|
|
|
@ -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"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/$app/"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
|
|
|
@ -113,7 +113,7 @@ fi
|
|||
#=================================================
|
||||
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_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$config"
|
||||
|
|
111
scripts/install
111
scripts/install
|
@ -30,6 +30,8 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
|
|||
language=$YNH_APP_ARG_LANGUAGE
|
||||
admin_email=$(ynh_user_get_info $admin 'mail')
|
||||
ynh_user_password=$(ynh_string_random --length=30)
|
||||
architecture=$YNH_ARCH
|
||||
|
||||
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_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
|
||||
#=================================================
|
||||
|
@ -122,7 +112,7 @@ 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
|
||||
ynh_setup_source --dest_dir="$final_path/live"
|
||||
ynh_setup_source --dest_dir="$final_path/live" --source_id=$architecture
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
|
@ -153,62 +143,6 @@ chmod 750 "$datadir"
|
|||
chmod -R o-rwx "$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
|
||||
#=================================================
|
||||
|
@ -217,6 +151,45 @@ ynh_script_progression --message="Configuring a systemd service..."
|
|||
# Create a dedicated 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
|
||||
#=================================================
|
||||
|
|
|
@ -51,15 +51,6 @@ 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
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_nodejs
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
|
@ -68,6 +59,17 @@ ynh_script_progression --message="Removing app main directory..."
|
|||
# Remove the app directory securely
|
||||
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
|
||||
#=================================================
|
||||
|
@ -76,6 +78,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..."
|
|||
# Remove the dedicated 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
|
||||
#=================================================
|
||||
|
@ -83,6 +93,9 @@ ynh_remove_nginx_config
|
|||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..."
|
||||
|
||||
# Remove a directory securely
|
||||
ynh_secure_remove --file="/etc/$app"
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
||||
|
|
|
@ -43,8 +43,6 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|||
#=================================================
|
||||
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 \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
|
@ -103,18 +101,6 @@ ynh_script_progression --message="Reinstalling dependencies..."
|
|||
# Define and install 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
|
||||
#=================================================
|
||||
|
@ -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_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
|
||||
#=================================================
|
||||
|
|
|
@ -29,6 +29,7 @@ port=$(ynh_app_setting_get --app=$app --key=port)
|
|||
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
||||
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
architecture=$YNH_ARCH
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -111,10 +112,9 @@ if ynh_version_gt "1.0.0~ynh1" "${previous_version}" ; then
|
|||
|
||||
# Implement ldap and mail
|
||||
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="__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.
|
||||
ynh_store_file_checksum --file="$config"
|
||||
|
@ -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"
|
||||
fi
|
||||
|
||||
if [ ! -f "$final_path/live/config/runtime.exs" ]; then
|
||||
ynh_delete_file_checksum --file="$final_path/$app/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"
|
||||
ynh_replace_string --match_string="server: true," --replace_string="" --target_file="$final_path/live/config/runtime.exs"
|
||||
ynh_store_file_checksum --file="$final_path/live/config/runtime.exs"
|
||||
ynh_remove_nodejs
|
||||
|
||||
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"
|
||||
mv -f "$final_path/live/config/prod.secret.exs" "/etc/$app/config.exs"
|
||||
fi
|
||||
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
|
||||
|
||||
#=================================================
|
||||
|
@ -184,24 +192,12 @@ ynh_system_user_create --username=$app --home_dir=$final_path
|
|||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
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
|
||||
ynh_secure_remove --file="$final_path/live"
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path/live"
|
||||
|
||||
# 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"
|
||||
ynh_setup_source --dest_dir="$final_path/live" --source_id=$architecture
|
||||
fi
|
||||
|
||||
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_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
|
||||
#=================================================
|
||||
|
@ -259,46 +243,18 @@ chown -R $app:$app "$datadir"
|
|||
#=================================================
|
||||
# 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
|
||||
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 ecto.migrate
|
||||
ynh_exec_as $app ./bin/mobilizon_ctl migrate
|
||||
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
|
||||
#=================================================
|
||||
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_store_file_checksum --file="$config"
|
||||
|
|
Loading…
Add table
Reference in a new issue