mirror of
https://github.com/YunoHost-Apps/mobilizon_ynh.git
synced 2024-09-03 19:46:19 +02:00
commit
72a3fad52c
21 changed files with 404 additions and 674 deletions
33
README.md
33
README.md
|
@ -1,10 +1,10 @@
|
||||||
# Mobilizon for YunoHost
|
# Mobilizon for YunoHost
|
||||||
|
|
||||||
[](https://dash.yunohost.org/appci/app/mobilizon)
|
[](https://dash.yunohost.org/appci/app/mobilizon)  
|
||||||
[](https://install-app.yunohost.org/?app=mobilizon)
|
[](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,26 +13,11 @@ MobiliZon aims to solve existing platform's problems to organize events in a dec
|
||||||
|
|
||||||
Mobilizon is a tool designed to create platforms for managing communities and events. Its purpose is to help as many people as possible to free themselves from Facebook groups and events, from Meetup, etc.
|
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
|
||||||
|
|
||||||
## Important points to read before installing
|
## Important points to read before installing
|
||||||
|
|
||||||
1. **Mobilizon** is in early development, like an Alpha, all functionalities are not available
|
|
||||||
1. **Mobilizon** require a dedicated **root domain**, eg. mobilizon.domain.tld
|
1. **Mobilizon** require a dedicated **root domain**, eg. mobilizon.domain.tld
|
||||||
1. Even if requested during installation: admin, language and password variables are not used
|
|
||||||
1. Admin Dashboard is still not implemented
|
|
||||||
1. When your mobilizon instance is installed, you need to register.
|
|
||||||
1. When registered, to be admin you have to manually goes in PostgreSQL, database $app, table users, and change the role value to `administrator` instead of `user` (other role available: `moderator`)
|
|
||||||
|
|
||||||
Example to manually put user with id=1 as administrator:
|
|
||||||
```bash
|
|
||||||
su -l postgres
|
|
||||||
psql
|
|
||||||
\c mobilizon
|
|
||||||
UPDATE public.users SET role='administrator' where id=1;
|
|
||||||
\q
|
|
||||||
exit
|
|
||||||
```
|
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
|
@ -40,13 +25,13 @@ exit
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
* Official documentation: https://framasoft.frama.io/mobilizon/
|
* Official documentation: https://docs.joinmobilizon.org
|
||||||
|
|
||||||
## YunoHost specific features
|
## YunoHost specific features
|
||||||
|
|
||||||
#### Supported architectures
|
#### Supported achitectures
|
||||||
|
|
||||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/mobilizon/)
|
* x86-64 - [](https://ci-apps.yunohost.org/ci/apps/mobilizon/)
|
||||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/mobilizon/)
|
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/mobilizon/)
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
@ -58,10 +43,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.
|
||||||
```
|
```
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
admin="john" (USER)
|
admin="john" (USER)
|
||||||
language="fr"
|
language="fr"
|
||||||
is_public=1 (PUBLIC|public=1|private=0)
|
is_public=1 (PUBLIC|public=1|private=0)
|
||||||
password="pass"
|
password="password"
|
||||||
name="My Mobilizon"
|
name="My_Mobilizon"
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=0
|
setup_sub_dir=0
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
|
22
conf/.env
22
conf/.env
|
@ -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
|
|
|
@ -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/mobilizon-1.0.0.tar.gz
|
||||||
SOURCE_SUM=d9db8d987134cae240fbdc4b3fb207328eee168242b809ec3dc66d7bfd17660e
|
SOURCE_SUM=a66712b859b923403945ad3e1e05f3ef537c7eb2a598f511dd99018ee4c06feb
|
||||||
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.tar.gz
|
||||||
|
|
16
conf/ldap.exs
Normal file
16
conf/ldap.exs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
config :mobilizon, Mobilizon.Service.Auth.Authenticator, Mobilizon.Service.Auth.LDAPAuthenticator
|
||||||
|
config :mobilizon, :ldap,
|
||||||
|
enabled: true,
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 389,
|
||||||
|
ssl: false,
|
||||||
|
# sslopts: [],
|
||||||
|
tls: false,
|
||||||
|
# tlsopts: [],
|
||||||
|
base: "ou=users,dc=yunohost,dc=org",
|
||||||
|
uid: "uid",
|
||||||
|
require_bind_for_search: false,
|
||||||
|
bind_uid: nil,
|
||||||
|
bind_password: nil
|
||||||
|
|
18
conf/mail.exs
Normal file
18
conf/mail.exs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
config :mobilizon, Mobilizon.Web.Email.Mailer,
|
||||||
|
adapter: Bamboo.SMTPAdapter,
|
||||||
|
server: "127.0.0.1",
|
||||||
|
#hostname: "127.0.0.1",
|
||||||
|
# usually 25, 465 or 587
|
||||||
|
port: 25,
|
||||||
|
username: "__YNH_USER__",
|
||||||
|
password: "__YNH_USER_PASSWORD__",
|
||||||
|
# can be `:always` or `:never`
|
||||||
|
tls: :if_available,
|
||||||
|
allowed_tls_versions: [:"tlsv1.2"],
|
||||||
|
retries: 1,
|
||||||
|
# can be `true`
|
||||||
|
no_mx_lookups: false,
|
||||||
|
# can be `:always`. If your smtp relay requires authentication set it to `:always`.
|
||||||
|
auth: :always
|
||||||
|
|
|
@ -4,16 +4,40 @@ location / {
|
||||||
rewrite ^ https://$server_name$request_uri? permanent;
|
rewrite ^ https://$server_name$request_uri? permanent;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Standard nginx configuration
|
# the nginx default is 1m, not enough for large media uploads
|
||||||
|
client_max_body_size 16m;
|
||||||
|
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
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_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
proxy_pass http://localhost:__PORT__;
|
proxy_pass http://localhost:__PORT__;
|
||||||
|
|
||||||
client_max_body_size 16m;
|
location ~* \.(css|js)$ {
|
||||||
|
root __FINALPATH__/mobilizon/priv/static;
|
||||||
|
etag off;
|
||||||
|
access_log off;
|
||||||
|
more_set_headers "Cache-Control: public, max-age=31536000, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/(media|proxy) {
|
||||||
|
etag off;
|
||||||
|
access_log off;
|
||||||
|
more_set_headers "Cache-Control: public, max-age=31536000, immutable";
|
||||||
|
proxy_pass http://localhost:__PORT__;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_page 500 501 502 503 504 @error;
|
||||||
|
|
||||||
# Include SSOWAT user panel.
|
# Include SSOWAT user panel.
|
||||||
include conf.d/yunohost_panel.conf.inc;
|
include conf.d/yunohost_panel.conf.inc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location @error {
|
||||||
|
root __FINALPATH__/mobilizon/priv/errors;
|
||||||
|
try_files /error.html 502;
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
|
||||||
#
|
|
31
conf/prod.secret.exs
Normal file
31
conf/prod.secret.exs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# Mobilizon instance configuration
|
||||||
|
|
||||||
|
import Config
|
||||||
|
|
||||||
|
config :mobilizon, Mobilizon.Web.Endpoint,
|
||||||
|
url: [host: "__DOMAIN__"],
|
||||||
|
http: [port: __PORT__],
|
||||||
|
secret_key_base: "__SECRET__"
|
||||||
|
|
||||||
|
config :mobilizon, Mobilizon.Web.Auth.Guardian,
|
||||||
|
secret_key: ""
|
||||||
|
|
||||||
|
config :mobilizon, :instance,
|
||||||
|
name: "Mobilizon",
|
||||||
|
description: "Change this to a proper description of your instance",
|
||||||
|
hostname: "__DOMAIN__",
|
||||||
|
registrations_open: false,
|
||||||
|
demo: false,
|
||||||
|
allow_relay: true,
|
||||||
|
federating: true,
|
||||||
|
email_from: "__APP__@__DOMAIN__",
|
||||||
|
email_reply_to: "__APP__@__DOMAIN__"
|
||||||
|
|
||||||
|
config :mobilizon, Mobilizon.Storage.Repo,
|
||||||
|
adapter: Ecto.Adapters.Postgres,
|
||||||
|
username: "__DB_USER__",
|
||||||
|
password: "__DB_PWD__",
|
||||||
|
database: "__DB_NAME__",
|
||||||
|
hostname: "localhost",
|
||||||
|
port: "5432",
|
||||||
|
pool_size: 10
|
|
@ -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
|
||||||
|
|
55
issue_template.md
Normal file
55
issue_template.md
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**How to post a meaningful bug report**
|
||||||
|
1. *Read this whole template first.*
|
||||||
|
2. *Make sure you are on the right place:*
|
||||||
|
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!*
|
||||||
|
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
|
||||||
|
- *In doubt, ask here and we will figure it out together.*
|
||||||
|
3. *Delete these italic comments as you write over them below, and remove this guide.*
|
||||||
|
---
|
||||||
|
|
||||||
|
### Describe the bug
|
||||||
|
|
||||||
|
*A clear and concise description of what the bug is.*
|
||||||
|
|
||||||
|
### Context
|
||||||
|
|
||||||
|
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
|
||||||
|
- YunoHost version: x.x.x
|
||||||
|
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
|
||||||
|
- 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`*
|
||||||
|
|
||||||
|
### Steps to reproduce
|
||||||
|
|
||||||
|
- *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
|
||||||
|
|
||||||
|
*When an operation fails, YunoHost provides a simple way to share the logs.*
|
||||||
|
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
|
||||||
|
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
|
||||||
|
|
||||||
|
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
|
||||||
|
|
||||||
|
*If applicable and useful, add screenshots to help explain your problem.*
|
|
@ -6,14 +6,14 @@
|
||||||
"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~ynh1",
|
||||||
"url": "https://joinmobilizon.org/",
|
"url": "https://joinmobilizon.org/",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "yalh76"
|
"name": "yalh76"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.5"
|
"yunohost": ">= 4.0"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
|
@ -30,15 +30,6 @@
|
||||||
},
|
},
|
||||||
"example": "example.com"
|
"example": "example.com"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "admin",
|
|
||||||
"type": "user",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose an admin user",
|
|
||||||
"fr": "Choisissez l’administrateur"
|
|
||||||
},
|
|
||||||
"example": "johndoe"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
@ -59,23 +50,13 @@
|
||||||
"default": "fr"
|
"default": "fr"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "password",
|
"name": "admin",
|
||||||
"type": "password",
|
"type": "user",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Set the administrator password",
|
"en": "Choose an admin user",
|
||||||
"fr": "Définissez le mot de passe administrateur"
|
"fr": "Choisissez l'administrateur"
|
||||||
},
|
},
|
||||||
"example": "Choose a password"
|
"example": "johndoe"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "name",
|
|
||||||
"type": "string",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose the instance name",
|
|
||||||
"fr": "Choisissez le nom de l'instance"
|
|
||||||
},
|
|
||||||
"example": "My Mobilizon",
|
|
||||||
"default": "My Mobilizon"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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"
|
extra_pkg_dependencies="elixir esl-erlang"
|
||||||
|
|
||||||
|
NODEJS_VERSION=12
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -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,50 +32,36 @@ 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"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP THE POSTGRESQL DATABASE
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
|
||||||
|
|
||||||
ynh_psql_dump_db --database=$db_name > db.sql
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC BACKUP
|
# SPECIFIC BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP SYSTEMD
|
# BACKUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Backing up systemd configuration..."
|
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# BACKUP THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Starting a systemd service..."
|
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
|
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
@ -103,6 +103,7 @@ then
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
# Store file checksum for the new config file location
|
# Store file checksum for the new config file location
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
|
yunohost user update "${app}_notifs" --mail ${app}_notifs@{$new_domain} --remove-mailalias ${app}@${old_domain} --add-mailalias ${app}@${new_domain}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -110,33 +111,30 @@ 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_backup_if_checksum_is_different --file="$config"
|
||||||
|
|
||||||
#=================================================
|
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$config"
|
||||||
# STORE THE CONFIG FILE CHECKSUM
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Storing the config file checksum..."
|
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/$app/.env"
|
|
||||||
# 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..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
|
# Start a systemd service
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access Mobilizon.Web.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 +142,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"
|
||||||
|
|
117
scripts/install
117
scripts/install
|
@ -7,13 +7,11 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source ynh_add_extra_apt_repos__3
|
|
||||||
source /usr/share/yunohost/helpers
|
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,25 +22,20 @@ 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="/"
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
language=$YNH_APP_ARG_LANGUAGE
|
language=$YNH_APP_ARG_LANGUAGE
|
||||||
password=$YNH_APP_ARG_PASSWORD
|
|
||||||
|
|
||||||
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')
|
||||||
|
ynh_user_password=$(ynh_string_random --length=30)
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
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"
|
||||||
|
@ -50,26 +43,27 @@ test ! -e "$final_path" || ynh_die --message="This path already contains a folde
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||||
|
|
||||||
|
[ -n "$admin_email" ] || ynh_die --message="Did not found the email address for the admin user ?"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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
|
||||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
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=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
|
||||||
|
ynh_app_setting_set --app=$app --key=ynh_user_password --value=$ynh_user_password
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIND AND OPEN A PORT
|
# FIND AND OPEN A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Configuring firewall..."
|
ynh_script_progression --message="Finding an available port..."
|
||||||
|
|
||||||
# Find an available port
|
# Find an available port
|
||||||
port=$(ynh_find_port --port=8095)
|
port=$(ynh_find_port --port=8095)
|
||||||
|
@ -78,18 +72,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'
|
||||||
|
@ -97,7 +91,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
|
||||||
|
@ -114,7 +108,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
|
||||||
|
@ -123,7 +117,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
|
||||||
|
@ -131,71 +125,64 @@ 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
|
||||||
|
|
||||||
|
yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0
|
||||||
|
yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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="Installing dependencies and building app..." --weight=5
|
||||||
|
|
||||||
# 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
|
||||||
|
ynh_script_progression --message="Installing NodeJS dependencies (this is going to take a while...)"
|
||||||
sudo -u $app env PATH=$PATH yarn install
|
sudo -u $app env PATH=$PATH yarn install
|
||||||
sudo -u $app env PATH=$PATH yarn run build
|
ynh_script_progression --message="Building NodeJS application (this is going to take a while...)"
|
||||||
|
sudo -u $app env PATH=$PATH NODE_BUILD_MEMORY=1024 yarn run build
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
ynh_script_progression --message="Building Elixir application (this is going to take a while...)"
|
||||||
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 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"
|
||||||
|
|
||||||
|
pushd $final_path/$app
|
||||||
|
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
|
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"
|
# 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
|
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
|
||||||
|
@ -203,7 +190,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"
|
||||||
|
@ -213,7 +200,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"
|
||||||
|
@ -221,22 +208,22 @@ 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 Mobilizon.Web.Endpoint at"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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 ]
|
||||||
|
@ -248,7 +235,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
|
||||||
|
|
||||||
|
@ -256,4 +243,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"
|
||||||
|
|
|
@ -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 integration..."
|
||||||
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,47 +72,35 @@ 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
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CLOSE A PORT
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Closing a port..."
|
|
||||||
|
|
||||||
if yunohost firewall list | grep -q "\- $port$"
|
|
||||||
then
|
|
||||||
ynh_print_info --message="Closing port $port..."
|
|
||||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
|
||||||
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
|
||||||
|
|
||||||
|
yunohost user delete ${app}_notifs
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info --message="Removal of $app completed"
|
ynh_script_progression --message="Removal of $app completed"
|
||||||
|
|
|
@ -8,13 +8,11 @@
|
||||||
|
|
||||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source ../settings/scripts/ynh_add_extra_apt_repos__3
|
|
||||||
source /usr/share/yunohost/helpers
|
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
|
||||||
|
@ -25,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
|
||||||
|
|
||||||
|
@ -36,11 +34,13 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
|
ynh_user_password=$(ynh_app_setting_get --app=$app --key=ynh_user_password)
|
||||||
|
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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}"
|
||||||
|
@ -52,29 +52,32 @@ 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
|
||||||
|
|
||||||
|
yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0
|
||||||
|
yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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"
|
||||||
|
@ -84,12 +87,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'
|
||||||
|
|
||||||
|
@ -99,7 +102,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
|
||||||
|
@ -111,7 +114,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
|
||||||
|
@ -119,23 +122,23 @@ 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 Mobilizon.Web.Endpoint at"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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
|
||||||
|
|
||||||
|
@ -143,4 +146,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"
|
||||||
|
|
148
scripts/upgrade
148
scripts/upgrade
|
@ -7,13 +7,13 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source ynh_add_extra_apt_repos__3
|
source ynh_package_version
|
||||||
source /usr/share/yunohost/helpers
|
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
|
||||||
|
|
||||||
|
@ -28,20 +28,23 @@ db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
||||||
name=$(ynh_app_setting_get --app=$app --key=name)
|
|
||||||
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
|
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)
|
||||||
|
|
||||||
|
abort_if_up_to_date
|
||||||
|
# previous function is what defines 'version', more precisely the 'previous version'
|
||||||
|
previous_version="${version}"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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
|
||||||
|
@ -71,7 +74,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
|
||||||
|
@ -88,24 +91,64 @@ 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"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE FROM PREVIOUS VERSION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if ynh_version_gt "1.0.0~ynh1" "${previous_version}" ; then
|
||||||
|
ynh_script_progression --message="Upgrade configuration to 1.0.0..."
|
||||||
|
|
||||||
|
ynh_user_password=$(ynh_string_random --length=30)
|
||||||
|
ynh_app_setting_set --app=$app --key=ynh_user_password --value=$ynh_user_password
|
||||||
|
|
||||||
|
yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0
|
||||||
|
yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email
|
||||||
|
|
||||||
|
# Manage previous .env file
|
||||||
|
ynh_backup_if_checksum_is_different --file="$final_path/$app/.env"
|
||||||
|
ynh_delete_file_checksum --file="$final_path/$app/.env"
|
||||||
|
ynh_secure_remove --file="$final_path/$app/.env"
|
||||||
|
|
||||||
|
# Configure Mobilizon
|
||||||
|
config="$final_path/$app/config/prod.secret.exs"
|
||||||
|
cp ../conf/prod.secret.exs "$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="__APP__" --replace_string="$app" --target_file="$config"
|
||||||
|
ynh_replace_string --match_string="__ADMIN_EMAIL__" --replace_string="$admin_email" --target_file="$config"
|
||||||
|
|
||||||
|
# Implement ldap and mail
|
||||||
|
cat "../conf/ldap.exs" >> "$config"
|
||||||
|
cat "../conf/mail.exs" >> "$config"
|
||||||
|
|
||||||
|
ynh_replace_string --match_string="__YNH_USER__" --replace_string="${app}_notifs" --target_file="$config"
|
||||||
|
ynh_replace_string --match_string="__YNH_USER_PASSWORD__" --replace_string="${ynh_user_password}" --target_file="$config"
|
||||||
|
|
||||||
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
|
ynh_store_file_checksum --file="$config"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
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"
|
cp -a "$final_path/$app/config/prod.secret.exs" "$tmpdir/prod.secret.exs"
|
||||||
cp -a "$final_path/$app/config/prod.exs" "$tmpdir/prod.exs"
|
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove --file="$final_path/$app"
|
ynh_secure_remove --file="$final_path/$app"
|
||||||
|
@ -114,8 +157,7 @@ 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"
|
cp -a "$tmpdir/prod.secret.exs" "$final_path/$app/config/prod.secret.exs"
|
||||||
cp -a "$tmpdir/prod.exs" "$final_path/$app/config/prod.exs"
|
|
||||||
|
|
||||||
# Remove the tmp directory securely
|
# Remove the tmp directory securely
|
||||||
ynh_secure_remove --file="$tmpdir"
|
ynh_secure_remove --file="$tmpdir"
|
||||||
|
@ -124,7 +166,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
|
||||||
|
@ -132,11 +174,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'
|
||||||
|
@ -144,7 +186,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
|
||||||
|
@ -154,69 +196,48 @@ 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"
|
chmod o-rwx $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..."
|
|
||||||
|
|
||||||
# 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"
|
||||||
|
|
||||||
pushd $final_path/$app/js
|
pushd $final_path/$app/js
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
|
ynh_script_progression --message="Installing NodeJS dependencies (this is going to take a while...)"
|
||||||
sudo -u $app env PATH=$PATH yarn install
|
sudo -u $app env PATH=$PATH yarn install
|
||||||
sudo -u $app env PATH=$PATH yarn run build
|
ynh_script_progression --message="Building NodeJS application (this is going to take a while...)"
|
||||||
|
sudo -u $app env PATH=$PATH NODE_BUILD_MEMORY=1024 yarn run build
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
ynh_script_progression --message="Building Elixir application (this is going to take a while...)"
|
||||||
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
|
||||||
|
@ -226,15 +247,29 @@ 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"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
|
yunohost service add $app --description "$app daemon for Mobilizon"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access Mobilizon.Web.Endpoint at"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# 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 ]
|
||||||
|
@ -243,17 +278,10 @@ then
|
||||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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
|
||||||
|
|
||||||
|
@ -261,4 +289,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"
|
||||||
|
|
|
@ -1,294 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Pin a repository.
|
|
||||||
#
|
|
||||||
# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append]
|
|
||||||
# | arg: -p, --package - Packages concerned by the pin. Or all, *.
|
|
||||||
# | arg: -i, --pin - Filter for the pin.
|
|
||||||
# | arg: -p, --priority - Priority for the pin
|
|
||||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
|
||||||
# | arg: -a, --append - Do not overwrite existing files.
|
|
||||||
#
|
|
||||||
# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning.
|
|
||||||
#
|
|
||||||
ynh_pin_repo () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=pirna
|
|
||||||
declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append )
|
|
||||||
local package
|
|
||||||
local pin
|
|
||||||
local priority
|
|
||||||
local name
|
|
||||||
local append
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
package="${package:-*}"
|
|
||||||
priority=${priority:-50}
|
|
||||||
name="${name:-$app}"
|
|
||||||
append=${append:-0}
|
|
||||||
|
|
||||||
if [ $append -eq 1 ]
|
|
||||||
then
|
|
||||||
append="tee -a"
|
|
||||||
else
|
|
||||||
append="tee"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "/etc/apt/preferences.d"
|
|
||||||
echo "Package: $package
|
|
||||||
Pin: $pin
|
|
||||||
Pin-Priority: $priority" \
|
|
||||||
| $append "/etc/apt/preferences.d/$name"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add a repository.
|
|
||||||
#
|
|
||||||
# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append]
|
|
||||||
# | arg: -u, --uri - Uri of the repository.
|
|
||||||
# | arg: -s, --suite - Suite of the repository.
|
|
||||||
# | arg: -c, --component - Component of the repository.
|
|
||||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
|
||||||
# | arg: -a, --append - Do not overwrite existing files.
|
|
||||||
#
|
|
||||||
# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable
|
|
||||||
# uri suite component
|
|
||||||
# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable
|
|
||||||
#
|
|
||||||
ynh_add_repo () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=uscna
|
|
||||||
declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append )
|
|
||||||
local uri
|
|
||||||
local suite
|
|
||||||
local component
|
|
||||||
local name
|
|
||||||
local append
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
name="${name:-$app}"
|
|
||||||
append=${append:-0}
|
|
||||||
|
|
||||||
if [ $append -eq 1 ]
|
|
||||||
then
|
|
||||||
append="tee -a"
|
|
||||||
else
|
|
||||||
append="tee"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "/etc/apt/sources.list.d"
|
|
||||||
# Add the new repo in sources.list.d
|
|
||||||
echo "deb $uri $suite $component" \
|
|
||||||
| $append "/etc/apt/sources.list.d/$name.list"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add an extra repository correctly, pin it and get the key.
|
|
||||||
#
|
|
||||||
# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append]
|
|
||||||
# | arg: -r, --repo - Complete url of the extra repository.
|
|
||||||
# | arg: -k, --key - url to get the public key.
|
|
||||||
# | arg: -p, --priority - Priority for the pin
|
|
||||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
|
||||||
# | arg: -a, --append - Do not overwrite existing files.
|
|
||||||
ynh_install_extra_repo () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=rkpna
|
|
||||||
declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append )
|
|
||||||
local repo
|
|
||||||
local key
|
|
||||||
local priority
|
|
||||||
local name
|
|
||||||
local append
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
name="${name:-$app}"
|
|
||||||
append=${append:-0}
|
|
||||||
key=${key:-0}
|
|
||||||
priority=${priority:-}
|
|
||||||
|
|
||||||
if [ $append -eq 1 ]
|
|
||||||
then
|
|
||||||
append="--append"
|
|
||||||
wget_append="tee -a"
|
|
||||||
else
|
|
||||||
append=""
|
|
||||||
wget_append="tee"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Split the repository into uri, suite and components.
|
|
||||||
# Remove "deb " at the beginning of the repo.
|
|
||||||
repo="${repo#deb }"
|
|
||||||
|
|
||||||
# Get the uri
|
|
||||||
local uri="$(echo "$repo" | awk '{ print $1 }')"
|
|
||||||
|
|
||||||
# Get the suite
|
|
||||||
local suite="$(echo "$repo" | awk '{ print $2 }')"
|
|
||||||
|
|
||||||
# Get the components
|
|
||||||
local component="${repo##$uri $suite }"
|
|
||||||
|
|
||||||
# Add the repository into sources.list.d
|
|
||||||
ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append
|
|
||||||
|
|
||||||
# Pin the new repo with the default priority, so it won't be used for upgrades.
|
|
||||||
# Build $pin from the uri without http and any sub path
|
|
||||||
local pin="${uri#*://}"
|
|
||||||
pin="${pin%%/*}"
|
|
||||||
# Set a priority only if asked
|
|
||||||
if [ -n "$priority" ]
|
|
||||||
then
|
|
||||||
priority="--priority=$priority"
|
|
||||||
fi
|
|
||||||
ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append
|
|
||||||
|
|
||||||
# Get the public key for the repo
|
|
||||||
if [ -n "$key" ]
|
|
||||||
then
|
|
||||||
mkdir -p "/etc/apt/trusted.gpg.d"
|
|
||||||
wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update the list of package with the new repo
|
|
||||||
ynh_package_update
|
|
||||||
}
|
|
||||||
|
|
||||||
# Remove an extra repository and the assiociated configuration.
|
|
||||||
#
|
|
||||||
# usage: ynh_remove_extra_repo [--name=name]
|
|
||||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
|
||||||
ynh_remove_extra_repo () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=n
|
|
||||||
declare -Ar args_array=( [n]=name= )
|
|
||||||
local name
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
name="${name:-$app}"
|
|
||||||
|
|
||||||
ynh_secure_remove --file="/etc/apt/sources.list.d/$name.list"
|
|
||||||
ynh_secure_remove --file="/etc/apt/preferences.d/$name"
|
|
||||||
ynh_secure_remove --file="/etc/apt/trusted.gpg.d/$name.gpg"
|
|
||||||
ynh_secure_remove --file="/etc/apt/trusted.gpg.d/$name.asc"
|
|
||||||
|
|
||||||
# Update the list of package to exclude the old repo
|
|
||||||
ynh_package_update
|
|
||||||
}
|
|
||||||
|
|
||||||
# Install packages from an extra repository properly.
|
|
||||||
#
|
|
||||||
# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name]
|
|
||||||
# | arg: -r, --repo - Complete url of the extra repository.
|
|
||||||
# | arg: -p, --package - The packages to install from this extra repository
|
|
||||||
# | arg: -k, --key - url to get the public key.
|
|
||||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
|
||||||
ynh_install_extra_app_dependencies () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=rpkn
|
|
||||||
declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= )
|
|
||||||
local repo
|
|
||||||
local package
|
|
||||||
local key
|
|
||||||
local name
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
name="${name:-$app}"
|
|
||||||
key=${key:-0}
|
|
||||||
|
|
||||||
# Set a key only if asked
|
|
||||||
if [ -n "$key" ]
|
|
||||||
then
|
|
||||||
key="--key=$key"
|
|
||||||
fi
|
|
||||||
# Add an extra repository for those packages
|
|
||||||
ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name
|
|
||||||
|
|
||||||
# Install requested dependencies from this extra repository.
|
|
||||||
ynh_add_app_dependencies --package="$package"
|
|
||||||
|
|
||||||
# Remove this extra repository after packages are installed
|
|
||||||
ynh_remove_extra_repo --name=$app
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies
|
|
||||||
|
|
||||||
# Define and install dependencies with a equivs control file
|
|
||||||
# This helper can/should only be called once per app
|
|
||||||
#
|
|
||||||
# usage: ynh_install_app_dependencies dep [dep [...]]
|
|
||||||
# | arg: dep - the package name to install in dependence
|
|
||||||
# You can give a choice between some package with this syntax : "dep1|dep2"
|
|
||||||
# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5"
|
|
||||||
# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5)
|
|
||||||
#
|
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
|
||||||
ynh_install_app_dependencies () {
|
|
||||||
local dependencies=$@
|
|
||||||
dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')"
|
|
||||||
dependencies=${dependencies//|/ | }
|
|
||||||
local manifest_path="../manifest.json"
|
|
||||||
if [ ! -e "$manifest_path" ]; then
|
|
||||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
|
||||||
fi
|
|
||||||
|
|
||||||
local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
|
|
||||||
if [ ${#version} -eq 0 ]; then
|
|
||||||
version="1.0"
|
|
||||||
fi
|
|
||||||
local dep_app=${app//_/-} # Replace all '_' by '-'
|
|
||||||
|
|
||||||
# Handle specific versions
|
|
||||||
if [[ "$dependencies" =~ [\<=\>] ]]
|
|
||||||
then
|
|
||||||
# Replace version specifications by relationships syntax
|
|
||||||
# https://www.debian.org/doc/debian-policy/ch-relationships.html
|
|
||||||
# Sed clarification
|
|
||||||
# [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice.
|
|
||||||
# [\<=\>] matches < = or >
|
|
||||||
# \+ matches one or more occurence of the previous characters, for >= or >>.
|
|
||||||
# [^,]\+ matches all characters except ','
|
|
||||||
# Ex: package>=1.0 will be replaced by package (>= 1.0)
|
|
||||||
dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
|
|
||||||
Section: misc
|
|
||||||
Priority: optional
|
|
||||||
Package: ${dep_app}-ynh-deps
|
|
||||||
Version: ${version}
|
|
||||||
Depends: ${dependencies}
|
|
||||||
Architecture: all
|
|
||||||
Description: Fake package for $app (YunoHost app) dependencies
|
|
||||||
This meta-package is only responsible of installing its dependencies.
|
|
||||||
EOF
|
|
||||||
ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \
|
|
||||||
|| ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies
|
|
||||||
rm /tmp/${dep_app}-ynh-deps.control
|
|
||||||
ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies"
|
|
||||||
}
|
|
||||||
|
|
||||||
ynh_add_app_dependencies () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=pr
|
|
||||||
declare -Ar args_array=( [p]=package= [r]=replace)
|
|
||||||
local package
|
|
||||||
local replace
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
replace=${replace:-0}
|
|
||||||
|
|
||||||
local current_dependencies=""
|
|
||||||
if [ $replace -eq 0 ]
|
|
||||||
then
|
|
||||||
local dep_app=${app//_/-} # Replace all '_' by '-'
|
|
||||||
if ynh_package_is_installed --package="${dep_app}-ynh-deps"
|
|
||||||
then
|
|
||||||
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
|
|
||||||
fi
|
|
||||||
|
|
||||||
current_dependencies=${current_dependencies// | /|}
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_install_app_dependencies "${current_dependencies}${package}"
|
|
||||||
}
|
|
26
scripts/ynh_package_version
Normal file
26
scripts/ynh_package_version
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
read_json () {
|
||||||
|
sudo python3 -c "import sys, json;print(json.load(open('$1'))['$2'])"
|
||||||
|
}
|
||||||
|
|
||||||
|
read_manifest () {
|
||||||
|
if [ -f '../manifest.json' ] ; then
|
||||||
|
read_json '../manifest.json' "$1"
|
||||||
|
else
|
||||||
|
read_json '../settings/manifest.json' "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
abort_if_up_to_date () {
|
||||||
|
version=$(read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" 'version' 2> /dev/null || echo '20160501-7')
|
||||||
|
last_version=$(read_manifest 'version')
|
||||||
|
if [ "${version}" = "${last_version}" ]; then
|
||||||
|
ynh_print_info "Up-to-date, nothing to do"
|
||||||
|
ynh_die "" 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ynh_version_gt ()
|
||||||
|
{
|
||||||
|
dpkg --compare-versions "$1" gt "$2"
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue