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

Upgrade to 1.0.0-beta.3

This commit is contained in:
yalh76 2020-08-03 23:19:04 +02:00
parent 6a9eda822f
commit 361b49c047
16 changed files with 197 additions and 310 deletions

View file

@ -1,10 +1,10 @@
# Mobilizon for YunoHost # Mobilizon for YunoHost
[![Integration level](https://dash.yunohost.org/integration/mobilizon.svg)](https://dash.yunohost.org/appci/app/mobilizon) [![Integration level](https://dash.yunohost.org/integration/mobilizon.svg)](https://dash.yunohost.org/appci/app/mobilizon) ![](https://ci-apps.yunohost.org/ci/badges/mobilizon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mobilizon.maintain.svg)
[![Install Mobilizon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mobilizon) [![Install Mobilizon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mobilizon)
> *This package allow you to install Mobilizon quickly and simply on a YunoHost server. > *This package allows you to install Mobilizon quickly and simply on a YunoHost server.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview ## Overview
MobiliZon is your federated organization and mobilization platform. Supported by [Framasoft](https://framasoft.org/en/) MobiliZon is your federated organization and mobilization platform. Supported by [Framasoft](https://framasoft.org/en/)
@ -13,7 +13,7 @@ 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. 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:** 0.1.0-2019-12-28 **Shipped version:** 1.0.0-beta.3
## Important points to read before installing ## Important points to read before installing
@ -46,7 +46,7 @@ exit
#### Supported architectures #### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mobilizon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mobilizon/) * 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/) * 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/)
## Links ## Links
@ -58,10 +58,10 @@ exit
--- ---
Developers info Developer info
---------------- ----------------
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing). Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing).
To try the testing branch, please proceed like that. To try the testing branch, please proceed like that.
``` ```

View file

@ -14,7 +14,10 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
# 0.1.0-2019-05-15~ynh1
upgrade=1 from_commit=185cc16e516076e340cca149e8e9140a8762e22e upgrade=1 from_commit=185cc16e516076e340cca149e8e9140a8762e22e
# 0.1.0-2019-12-28~ynh1
upgrade=1 from_commit=6b77f268d4e7e2cd525e11e11f3ed5a5162d0bd2
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
@ -27,3 +30,9 @@
;;; Options ;;; Options
Email=yalh@yahoo.com Email=yalh@yahoo.com
Notification=all Notification=all
;;; Upgrade options
; commit=185cc16e516076e340cca149e8e9140a8762e22e
name=0.1.0-2019-05-15~ynh1
; commit=6b77f268d4e7e2cd525e11e11f3ed5a5162d0bd2
name=0.1.0-2019-12-28~ynh1

View file

@ -1,22 +0,0 @@
# Settings
MOBILIZON_INSTANCE_NAME="__NAME__"
MOBILIZON_INSTANCE_HOST="__DOMAIN__"
MOBILIZON_INSTANCE_PORT=__PORT__
MOBILIZON_INSTANCE_EMAIL="__ADMIN_EMAIL__"
MOBILIZON_INSTANCE_REGISTRATIONS_OPEN=true
# API
GRAPHQL_API_ENDPOINT="https://__DOMAIN__"
GRAPHQL_API_FULL_PATH=""
# APP
MIX_ENV=prod
MOBILIZON_LOGLEVEL="error"
MOBILIZON_SECRET="__SECRET__"
# Database
MOBILIZON_DATABASE_USERNAME="__DB_USER__"
MOBILIZON_DATABASE_PASSWORD="__DB_PWD__"
MOBILIZON_DATABASE_DBNAME="__DB_NAME__"
MOBILIZON_DATABASE_HOST="localhost"
MOBILIZON_DATABASE_PORT=5432

View file

@ -1,6 +1,6 @@
SOURCE_URL=https://framagit.org/framasoft/mobilizon/-/archive/62ad69c53c1c0789e879ad04787121a27883639e/mobilizon-62ad69c53c1c0789e879ad04787121a27883639e.tar.gz SOURCE_URL=https://framagit.org/framasoft/mobilizon/-/archive/1.0.0-beta.3/mobilizon-1.0.0-beta.3.tar.gz
SOURCE_SUM=d9db8d987134cae240fbdc4b3fb207328eee168242b809ec3dc66d7bfd17660e SOURCE_SUM=5bf0f328f19fd182b0a02088bd9d53cd9e9042dde165328d42c9b12149b97c2d
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=0.1.0-2019-12-28.tar.gz SOURCE_FILENAME=mobilizon-1.0.0-beta.3.tar.gz

View file

@ -4,16 +4,30 @@ location / {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
# Standard nginx configuration gzip off;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# For Websocket support
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host; proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://localhost:__PORT__; proxy_pass http://localhost:__PORT__;
client_max_body_size 16m; client_max_body_size 16m;
location ~* \.(css|js)$ {
root /home/mobilizon/live/priv/static;
etag off;
expires 1y;
access_log off;
add_header Cache-Control public;
}
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
} }

View file

@ -1,88 +0,0 @@
import Config
config :mobilizon, MobilizonWeb.Endpoint,
load_from_system_env: true,
url: [
host: "__DOMAIN__",
port: 443,
scheme: "https"
],
http: [
ip: {127, 0, 0, 1},
port: __PORT__
],
secret_key_base:
"__SECRET__",
cache_static_manifest: "priv/static/manifest.json"
# Configure your database
config :mobilizon, Mobilizon.Storage.Repo,
types: Mobilizon.Storage.PostgresTypes,
username: "__DB_USER__",
password: "__DB_PWD__",
database: "__DB_NAME__",
hostname: "localhost",
port: "5432",
pool_size: 15
config :mobilizon, MobilizonWeb.Email.Mailer,
adapter: Bamboo.SMTPAdapter,
server: "localhost",
hostname: "localhost",
port: 25,
# or {:system, "SMTP_USERNAME"}
username: nil,
# or {:system, "SMTP_PASSWORD"}
password: nil,
# can be `:always` or `:never`
tls: :if_available,
# or {":system", ALLOWED_TLS_VERSIONS"} w/ comma seprated values (e.g. "tlsv1.1,tlsv1.2")
allowed_tls_versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"],
# can be `true`
ssl: false,
retries: 1,
# can be `true`
no_mx_lookups: false
# Do not print debug messages in production
#config :logger, level: System.get_env("MOBILIZON_LOGLEVEL") |> String.to_atom() || :info
config :mobilizon, Mobilizon.Service.Geospatial, service: Mobilizon.Service.Geospatial.Nominatim
# ## SSL Support
#
# To get SSL working, you will need to add the `https` key
# to the previous section and set your `:url` port to 443:
#
# config :mobilizon, MobilizonWeb.Endpoint,
# ...
# url: [host: "example.com", port: 443],
# https: [:inet6,
# port: 443,
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")]
#
# Where those two env variables return an absolute path to
# the key and cert in disk or a relative path inside priv,
# for example "priv/ssl/server.key".
#
# We also recommend setting `force_ssl`, ensuring no data is
# ever sent via http, always redirecting to https:
#
# config :mobilizon, MobilizonWeb.Endpoint,
# force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.
# ## Using releases
#
# If you are doing OTP releases, you need to instruct Phoenix
# to start the server for all endpoints:
#
# config :phoenix, :serve_endpoints, true
#
# Alternatively, you can configure exactly which server to
# start per endpoint:
#
# config :mobilizon, MobilizonWeb.Endpoint, server: true
#

View file

@ -3,17 +3,15 @@ Description=__APP__ Mobilizon Service
After=network.target postgresql.service After=network.target postgresql.service
[Service] [Service]
User=__APP__
WorkingDirectory=__FINALPATH__/__APP__/
ExecStart=/usr/bin/env mix phx.server
ExecReload=/bin/kill $MAINPID ExecReload=/bin/kill $MAINPID
KillMode=process KillMode=process
Restart=on-failure Restart=on-failure
User=__APP__ Environment=MIX_ENV=prod
Group=__APP__
Environment="MIX_ENV=prod" SyslogIdentifier=mobilizon
EnvironmentFile=__FINALPATH__/__APP__/.env
WorkingDirectory=__FINALPATH__/__APP__/
ExecStart=/usr/bin/mix phx.server
; Some security directives. ; Some security directives.
; 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.
@ -25,5 +23,6 @@ PrivateDevices=false
; Ensures that the service process and all its children can never gain new privileges through execve(). ; Ensures that the service process and all its children can never gain new privileges through execve().
NoNewPrivileges=true NoNewPrivileges=true
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

46
issue_template.md Normal file
View file

@ -0,0 +1,46 @@
---
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.
---
**How to post a meaningful bug report**
1. *Read this whole template first.*
2. *Determine if 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.*
---
**Describe the bug**
*A clear and concise description of what the bug is.*
**Versions**
- 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 | ...*
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes*
- If yes, please explain:
- 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.*
- *If you performed a command from the CLI, the command itself is enough. For example:*
```sh
sudo yunohost app install mobilizon
```
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:*
1. *Go to '...'*
2. *Click on '....'*
3. *Scroll down to '....'*
4. *See error*
**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.*
*If applicable and useful, add screenshots to help explain your problem.*

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": "0.1.0-2019-12-28~ynh1", "version": "1.0.0-beta.3~ynh1",
"url": "https://joinmobilizon.org/", "url": "https://joinmobilizon.org/",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"maintainer": { "maintainer": {
@ -74,8 +74,8 @@
"en": "Choose the instance name", "en": "Choose the instance name",
"fr": "Choisissez le nom de l'instance" "fr": "Choisissez le nom de l'instance"
}, },
"example": "My Mobilizon", "example": "Mobilizon",
"default": "My Mobilizon" "default": "Mobilizon"
} }
] ]
} }

View file

@ -5,9 +5,11 @@
#================================================= #=================================================
# dependencies used by the app # 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" 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"
extra_pkg_dependencies="elixir esl-erlang" extra_pkg_dependencies="elixir esl-erlang"
NODEJS_VERSION=12
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================

View file

@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
@ -33,28 +32,30 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#================================================= #=================================================
# STANDARD BACKUP STEPS # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
# STOP SYSTEMD SERVICE ynh_print_info --message="Declaring files to be backed up..."
#=================================================
ynh_print_info --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info --message="Backing up the main app directory..."
ynh_backup --src_path="$final_path" ynh_backup --src_path="$final_path"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Backing up nginx web server configuration..."
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
#================================================= #=================================================
# BACKUP THE POSTGRESQL DATABASE # BACKUP THE POSTGRESQL DATABASE
#================================================= #=================================================
@ -62,22 +63,6 @@ ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql ynh_psql_dump_db --database="$db_name" > db.sql
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_print_info --message="Backing up systemd configuration..."
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..."
# Needed for helper "ynh_add_nginx_config" # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
@ -37,7 +37,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_print_info --message="Backing up the app before changing its url (may take a while)..." ynh_script_progression --message="Backing up the app before changing its url (may take a while)..."
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -72,14 +72,14 @@ fi
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_print_info --message="Stopping a systemd service..." ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped" ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped"
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_print_info --message="Updating nginx web server configuration..." ynh_script_progression --message="Updating nginx web server configuration..."
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -110,33 +110,34 @@ fi
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_print_info --message="Modifying a config file..." ynh_script_progression --message="Modifying a config file..."
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$final_path/$app/.env" config="$final_path/$app/config/prod.secret.exs"
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$final_path/$app/config/prod.secret.exs" ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$config"
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
ynh_print_info --message="Storing the config file checksum..." ynh_script_progression --message="Storing the config file checksum..."
ynh_backup_if_checksum_is_different --file="$final_path/$app/.env" ynh_backup_if_checksum_is_different --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="$final_path/$app/.env" ynh_store_file_checksum --file="$config"
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_print_info --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at" ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info --message="Reloading nginx web server..." ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -144,4 +145,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Change of URL completed for $app" ynh_script_progression --message="Change of URL completed for $app"

View file

@ -12,10 +12,10 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting read -p "key"
ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -23,7 +23,6 @@ ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
ynh_print_info --message="Retrieving arguments from the manifest..."
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url="/" path_url="/"
@ -33,7 +32,6 @@ language=$YNH_APP_ARG_LANGUAGE
password=$YNH_APP_ARG_PASSWORD password=$YNH_APP_ARG_PASSWORD
name=$YNH_APP_ARG_NAME name=$YNH_APP_ARG_NAME
secret=$(ynh_string_random 30)
admin_email=$(ynh_user_get_info $admin 'mail') admin_email=$(ynh_user_get_info $admin 'mail')
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -41,7 +39,7 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_print_info --message="Validating installation parameters..." ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
@ -52,7 +50,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_print_info --message="Storing installation settings..." ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain 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=$path_url
@ -60,7 +58,6 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=language --value=$language
ynh_app_setting_set --app=$app --key=name --value=$name ynh_app_setting_set --app=$app --key=name --value=$name
ynh_app_setting_set --app=$app --key=secret --value=$secret
ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email
#================================================= #=================================================
@ -68,7 +65,7 @@ ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_print_info --message="Configuring firewall..." ynh_script_progression --message="Configuring firewall..."
# Find an available port # Find an available port
port=$(ynh_find_port --port=8095) port=$(ynh_find_port --port=8095)
@ -77,18 +74,18 @@ ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info --message="Installing dependencies..." ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version="10" 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' ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key='https://dl.yarnpkg.com/debian/pubkey.gpg'
#================================================= #=================================================
# INSTALL EXTRA DEPENDENCIES # INSTALL EXTRA DEPENDENCIES
#================================================= #=================================================
ynh_print_info --message="Installing extra dependencies ..." ynh_script_progression --message="Installing extra dependencies ..."
lsb_name="$(lsb_release --codename --short)" 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' 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'
@ -96,7 +93,7 @@ ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.
#================================================= #=================================================
# CREATE A POSTGRESQL DATABASE # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info --message="Creating a PostgreSQL database..." ynh_script_progression --message="Creating a PostgreSQL database..."
db_name=$(ynh_sanitize_dbid --db_name=$app) db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name db_user=$db_name
@ -113,7 +110,7 @@ ynh_psql_execute_as_root --sql="ALTER USER $db_user PASSWORD '$db_pwd';" --datab
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info --message="Setting up source files..." 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
@ -122,7 +119,7 @@ ynh_setup_source --dest_dir="$final_path/$app"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Configuring nginx web server..." ynh_script_progression --message="Configuring nginx web server..."
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
@ -130,50 +127,23 @@ ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info --message="Configuring system user..." ynh_script_progression --message="Configuring system user..."
# Create a system user # Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_print_info --message="Modifying a config file..."
config="$final_path/$app/.env"
cp ../conf/.env "$config"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config"
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config"
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config"
ynh_replace_string --match_string="__NAME__" --replace_string="$name" --target_file="$config"
ynh_replace_string --match_string="__ADMIN_EMAIL__" --replace_string="$admin_email" --target_file="$config"
#================================================= #=================================================
# MAKE SETUP # MAKE SETUP
#================================================= #=================================================
ynh_print_info --message="Making setup..." ynh_script_progression --message="Making setup..."
# Temporarly bypass error : WARNING ** (ArgumentError) argument error and System.get_env doesn't load environment variables
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__NAME__" --replace_string="$name" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__ADMIN_EMAIL__" --replace_string="$admin_email" --target_file="../conf/prod.exs"
cp ../conf/prod.exs "$final_path/$app/config/prod.exs"
# Give permission to the final_path # Give permission to the final_path
chown -R "$app":"$app" "$final_path" chown -R "$app":"$app" "$final_path"
config="$final_path/$app/config/prod.secret.exs"
pushd $final_path/$app/js 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 yarn install
@ -181,20 +151,18 @@ pushd $final_path/$app/js
popd popd
pushd $final_path/$app pushd $final_path/$app
ynh_replace_string --match_string="config :logger" --replace_string="#config :logger" --target_file="$final_path/$app/config/prod.exs"
source .env
sudo -u "$app" MIX_ENV=prod mix local.hex --force sudo -u "$app" MIX_ENV=prod mix local.hex --force
sudo -u "$app" MIX_ENV=prod mix local.rebar --force sudo -u "$app" MIX_ENV=prod mix local.rebar --force
sudo -u "$app" MIX_ENV=prod mix deps.get sudo -u "$app" MIX_ENV=prod mix deps.get
sudo -u "$app" MIX_ENV=prod mix ecto.migrate sudo -u "$app" MIX_ENV=prod mix compile
sudo -u "$app" MIX_ENV=prod mix phx.digest 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
ynh_replace_string --match_string="#config :logger" --replace_string="config :logger" --target_file="$final_path/$app/config/prod.exs" sudo -u "$app" MIX_ENV=prod mix mobilizon.users.new "$admin_email" --admin --password "$password"
popd popd
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_print_info --message="Configuring a systemd service..." 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
@ -202,7 +170,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
ynh_print_info --message="Storing the config file checksum..." ynh_script_progression --message="Storing the config file checksum..."
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$config" ynh_store_file_checksum --file="$config"
@ -212,7 +180,7 @@ ynh_store_file_checksum --file="$config"
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
ynh_print_info --message="Securing files and directories..." ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files # Set permissions to app files
chown -R "$app":"$app" "$final_path" chown -R "$app":"$app" "$final_path"
@ -220,14 +188,14 @@ chown -R "$app":"$app" "$final_path"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_print_info --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "$app daemon for Mobilizon" yunohost service add $app --description "$app daemon for Mobilizon"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_print_info --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at" ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
@ -235,7 +203,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_print_info --message="Configuring SSOwat..." ynh_script_progression --message="Configuring SSOwat..."
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
@ -247,7 +215,7 @@ fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info --message="Reloading nginx web server..." ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -255,4 +223,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Installation of $app completed" ynh_script_progression --message="Installation of $app completed"

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -27,19 +27,18 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST # REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
ynh_print_info --message="Removing service integration in YunoHost..."
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) # 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 if ynh_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_print_info --message="Removing $app service..." ynh_script_progression --message="Removing $app service..."
yunohost service remove $app yunohost service remove $app
fi fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_print_info --message="Stopping and removing the systemd service..." ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
@ -47,7 +46,7 @@ ynh_remove_systemd_config
#================================================= #=================================================
# REMOVE THE POSTGRESQL DATABASE # REMOVE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info --message="Removing the PostgreSQL database..." 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"
@ -55,7 +54,7 @@ ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name"
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_print_info --message="Removing dependencies..." ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -65,7 +64,7 @@ ynh_remove_nodejs
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_print_info --message="Removing app main directory..." 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"
@ -73,7 +72,7 @@ ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Removing nginx web server configuration..." 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
@ -81,33 +80,29 @@ ynh_remove_nginx_config
#================================================= #=================================================
# CLOSE A PORT # CLOSE A PORT
#================================================= #=================================================
ynh_print_info --message="Closing a port..."
if yunohost firewall list | grep -q "\- $port$" if yunohost firewall list | grep -q "\- $port$"
then then
ynh_print_info --message="Closing port $port..." ynh_script_progression --message="Closing port $port..."
ynh_exec_warn_less yunohost firewall disallow TCP $port ynh_exec_warn_less yunohost firewall disallow TCP $port
fi fi
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================
# REMOVE THE LOG FILE # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_print_info --message="Removing the log files..." ynh_script_progression --message="Removing various files..."
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
# Remove the GeoIP folder
ynh_secure_remove --file="/usr/share/GeoIP"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_print_info --message="Removing the dedicated system user..." ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app ynh_system_user_delete --username=$app
@ -116,4 +111,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Removal of $app completed" ynh_script_progression --message="Removal of $app completed"

View file

@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
@ -24,7 +23,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading settings..." ynh_script_progression --message="Loading settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -39,7 +38,7 @@ port=$(ynh_app_setting_get --app=$app --key=port)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_print_info --message="Validating restoration parameters..." ynh_script_progression --message="Validating restoration parameters..."
ynh_webpath_available --domain=$domain --path_url=$path_url \ ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}" || ynh_die --message="Path not available: ${domain}${path_url}"
@ -51,21 +50,21 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Restoring the nginx configuration..." ynh_script_progression --message="Restoring the nginx configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info --message="Restoring the app main directory..." ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_print_info --message="Recreating the dedicated system user..." ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path ynh_system_user_create --username=$app --home_dir=$final_path
@ -73,7 +72,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
#================================================= #=================================================
ynh_print_info --message="Restoring user rights..." ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files # Restore permissions on app files
chown -R "$app":"$app" "$final_path" chown -R "$app":"$app" "$final_path"
@ -83,12 +82,12 @@ chown -R "$app":"$app" "$final_path"
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info --message="Reinstalling dependencies..." ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version="10" 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' ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key='https://dl.yarnpkg.com/debian/pubkey.gpg'
@ -98,7 +97,7 @@ ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info --message="Restoring the PostgreSQL database..." ynh_script_progression --message="Restoring the PostgreSQL database..."
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
@ -110,7 +109,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_print_info --message="Restoring the systemd configuration..." ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service systemctl enable $app.service
@ -118,14 +117,14 @@ systemctl enable $app.service
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_print_info --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "$app daemon for Mobilizon" yunohost service add $app --description "$app daemon for Mobilizon"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_print_info --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at" ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
@ -134,7 +133,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================
ynh_print_info --message="Reloading nginx web server..." ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -142,4 +141,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Restoration completed for $app" ynh_script_progression --message="Restoration completed for $app"

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -33,14 +33,14 @@ admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_print_info --message="Checking version..." ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_print_info --message="Ensuring downward compatibility..." ynh_script_progression --message="Ensuring downward compatibility..."
# Fix is_public as a boolean value # Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then if [ "$is_public" = "Yes" ]; then
@ -70,7 +70,7 @@ ynh_secure_remove --file="/usr/share/GeoIP"
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_print_info --message="Backing up the app before upgrading (may take a while)..." ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -87,7 +87,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_print_info --message="Stopping a systemd service..." ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped" ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped"
@ -97,14 +97,16 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_print_info --message="Upgrading source files..." ynh_script_progression --message="Upgrading source files..."
# Create a temporary directory # Create a temporary directory
tmpdir="$(mktemp -d)" tmpdir="$(mktemp -d)"
# Backup the config file in the temp dir # Backup the config file in the temp dir
cp -a "$final_path/$app/.env" "$tmpdir/.env" if [ -s "$final_path/$app/config/prod.exs" ]
cp -a "$final_path/$app/config/prod.exs" "$tmpdir/prod.exs" then
cp -a "$final_path/$app/config/prod.exs" "$tmpdir/prod.secret.exs"
fi
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path/$app" ynh_secure_remove --file="$final_path/$app"
@ -113,8 +115,10 @@ then
ynh_setup_source --dest_dir="$final_path/$app" ynh_setup_source --dest_dir="$final_path/$app"
#Copy the admin saved settings from tmp directory to final path #Copy the admin saved settings from tmp directory to final path
cp -a "$tmpdir/.env" "$final_path/$app/.env" if [ -s "$tmpdir/prod.exs" ]
cp -a "$tmpdir/prod.exs" "$final_path/$app/config/prod.exs" then
cp -a "$tmpdir/prod.exs" "$final_path/$app/config/prod.secret.exs"
fi
# Remove the tmp directory securely # Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir" ynh_secure_remove --file="$tmpdir"
@ -123,7 +127,7 @@ fi
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Upgrading nginx web server configuration..." ynh_script_progression --message="Upgrading nginx web server configuration..."
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
@ -131,11 +135,11 @@ ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_print_info --message="Upgrading dependencies..." ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version="10" ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
lsb_name="$(lsb_release --codename --short)" 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' 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'
@ -143,7 +147,7 @@ ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info --message="Making sure dedicated system user exists..." ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path ynh_system_user_create --username=$app --home_dir=$final_path
@ -153,37 +157,15 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_print_info --message="Modifying a config file..." ynh_script_progression --message="Modifying a config file..."
config="$final_path/$app/.env" config="$final_path/$app/config/prod.secret.exs"
ynh_backup_if_checksum_is_different --file="$config" ynh_backup_if_checksum_is_different --file="$config"
cp ../conf/.env "$config"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config"
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config"
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config"
ynh_replace_string --match_string="__NAME__" --replace_string="$name" --target_file="$config"
ynh_replace_string --match_string="__ADMIN_EMAIL__" --replace_string="$admin_email" --target_file="$config"
#================================================= #=================================================
# MAKE SETUP # MAKE SETUP
#================================================= #=================================================
ynh_print_info --message="Making setup..." ynh_script_progression --message="Making setup..."
# Temporarly bypass error : WARNING ** (ArgumentError) argument error and System.get_env doesn't load environment variables
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__NAME__" --replace_string="$name" --target_file="../conf/prod.exs"
ynh_replace_string --match_string="__ADMIN_EMAIL__" --replace_string="$admin_email" --target_file="../conf/prod.exs"
cp ../conf/prod.exs "$final_path/$app/config/prod.exs"
# Give permission to the final_path # Give permission to the final_path
chown -R "$app":"$app" "$final_path" chown -R "$app":"$app" "$final_path"
@ -195,27 +177,24 @@ pushd $final_path/$app/js
popd popd
pushd $final_path/$app pushd $final_path/$app
ynh_replace_string --match_string="config :logger" --replace_string="#config :logger" --target_file="$final_path/$app/config/prod.exs"
source .env
sudo -u "$app" MIX_ENV=prod mix local.hex --force sudo -u "$app" MIX_ENV=prod mix local.hex --force
sudo -u "$app" MIX_ENV=prod mix local.rebar --force sudo -u "$app" MIX_ENV=prod mix local.rebar --force
sudo -u "$app" MIX_ENV=prod mix deps.get 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 sudo -u "$app" MIX_ENV=prod mix ecto.migrate
sudo -u "$app" MIX_ENV=prod mix phx.digest
ynh_replace_string --match_string="#config :logger" --replace_string="config :logger" --target_file="$final_path/$app/config/prod.exs"
popd popd
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
ynh_print_info --message="Storing 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. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$config" ynh_store_file_checksum --file="$config"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_print_info --message="Upgrading systemd configuration..." ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
@ -225,7 +204,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
ynh_print_info --message="Securing files and directories..." ynh_script_progression --message="Securing files and directories..."
# Set permissions on app files # Set permissions on app files
chown -R "$app":"$app" "$final_path" chown -R "$app":"$app" "$final_path"
@ -233,7 +212,7 @@ chown -R "$app":"$app" "$final_path"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_print_info --message="Upgrading SSOwat configuration..." ynh_script_progression --message="Upgrading SSOwat configuration..."
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
@ -245,14 +224,14 @@ fi
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_print_info --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at" ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info --message="Reloading nginx web server..." ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -260,4 +239,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Upgrade of $app completed" ynh_script_progression --message="Upgrade of $app completed"