mirror of
https://github.com/YunoHost-Apps/glitchsoc_ynh.git
synced 2024-09-03 19:15:59 +02:00
Fresh start
Rebase from Yunohost-Apps/mastodon_ynh and port to Glitch-soc again
This commit is contained in:
commit
e9292cd129
25 changed files with 881 additions and 1362 deletions
45
README.md
45
README.md
|
@ -1,21 +1,24 @@
|
|||
# [WIP] Glitch-Soc pour YunoHost
|
||||
# Glich-Soc for YunoHost
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/mastodon)  
|
||||
[](https://install-app.yunohost.org/?app=glitchsoc)
|
||||
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
||||
> *This package allow you to install Glitch-Soc 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.*
|
||||
> *This package allows you to install Glich-Soc quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
|
||||
|
||||
## Overview
|
||||
Glitch-Soc is a free, open-source social network. A decentralized alternative to commercial platforms, it avoids the risks of a single company monopolizing your communication. Pick a server that you trust — whichever you choose, you can interact with everyone else. Anyone can run their own Glitch-Soc instance and participate in the social network seamlessly.
|
||||
Glich-Soc is a free, open-source microblogging social network. It is a decentralized alternative to commercial platforms like Twitter and avoids the risks of a single company monopolizing your communication for commercial purposes.
|
||||
|
||||
**Shipped version:** 3.1.4
|
||||
**Shipped version:** 3.3.0
|
||||
|
||||
## Important points to read before installing
|
||||
|
||||
1. **Glitch-Soc** require a dedicated **root domain**, eg. glitch.domain.tld
|
||||
1. The user choosen during the installation is automatically created in Glitch-Soc with admin rights
|
||||
1. **Glich-Soc** require a dedicated **root domain**, eg. glitchsoc.domain.tld
|
||||
1. The user choosen during the installation is automatically created in Glich-Soc with admin rights
|
||||
1. At the end of the installation a mail is sent to the user with the automatically generated password
|
||||
1. It seems important to close the inscriptions for your Glitch-Soc, so that it remains a private body. We invite you to block remote malicious instances from the administration interface. You can also add text on your home page.
|
||||
1. It seems important to close the inscriptions for your Glich-Soc, so that it remains a private body. We invite you to block remote malicious instances from the administration interface. You can also add text on your home page.
|
||||
|
||||
## Screenshots
|
||||
|
||||
|
@ -25,11 +28,11 @@ Glitch-Soc is a free, open-source social network. A decentralized alternative to
|
|||
|
||||
### Install
|
||||
|
||||
#### Using __screen__ in case of disconnect
|
||||
#### Using *screen* in case of disconnect
|
||||
```
|
||||
$ sudo apt-get install screen
|
||||
$ screen
|
||||
$ sudo yunohost app install https://github.com/Tagadda/glitch-soc_ynh.git
|
||||
$ sudo yunohost app install https://github.com/YunoHost-Apps/glitch-soc_ynh.git
|
||||
```
|
||||
Recover after disconnect:
|
||||
```
|
||||
|
@ -39,9 +42,9 @@ $ screen -r
|
|||
|
||||
### Update
|
||||
|
||||
#### Using __screen__ highly recommended
|
||||
#### Using *screen* highly recommended
|
||||
|
||||
`$ sudo yunohost app upgrade glitch-soc -u https://github.com/Tagadda/glitch-soc_ynh --debug `
|
||||
`$ sudo yunohost app upgrade glitchsoc -u https://github.com/YunoHost-Apps/glitch-soc_ynh --debug `
|
||||
|
||||
## Documentation
|
||||
|
||||
|
@ -53,23 +56,27 @@ $ screen -r
|
|||
|
||||
LDAP authentication is activated. All YunoHost users can authenticate.
|
||||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64 - [](https://ci-apps.yunohost.org/ci/apps/mastodon/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/)
|
||||
|
||||
## Links
|
||||
|
||||
* Report a bug: https://github.com/Tagadda/glitch-soc_ynh/issues
|
||||
* App website: https://glitch-soc.github.io/docs/
|
||||
* Report a bug: https://github.com/YunoHost-Apps/glitch-soc_ynh/issues
|
||||
* App website: https://joinmastodon.org/
|
||||
* Upstream app repository: https://github.com/glitch-soc/mastodon
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
||||
Developers info
|
||||
----------------
|
||||
## Developer info
|
||||
|
||||
Please do your pull request to the [testing branch](https://github.com/Tagadda/glitch-soc_ynh/tree/testing).
|
||||
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/glitch-soc_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
sudo yunohost app install https://github.com/Tagadda/glitch-soc_ynh/tree/testing --debug
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/glitch-soc_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade glitch-soc -u https://github.com/Tagadda/glitch-soc_ynh/tree/testing --debug
|
||||
sudo yunohost app upgrade glitchsoc -u https://github.com/YunoHost-Apps/glitch-soc_ynh/tree/testing --debug
|
||||
```
|
||||
|
|
64
README_fr.md
64
README_fr.md
|
@ -1,21 +1,24 @@
|
|||
# [WIP] Glitch-Soc pour YunoHost
|
||||
# Glich-Soc pour YunoHost
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/mastodon)  
|
||||
[](https://install-app.yunohost.org/?app=glitchsoc)
|
||||
|
||||
*[Read this readme in english.](./README.md)*
|
||||
|
||||
> *Ce package vous permet d'installer Glitch-Soc rapidement et simplement sur un serveur Yunohost.
|
||||
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
|
||||
> *Ce package vous permet d'installer Glich-Soc rapidement et simplement sur un serveur YunoHost.
|
||||
Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.*
|
||||
|
||||
## Vue d'ensemble
|
||||
Glitch-Soc est un réseau social gratuit et open source. Une alternative décentralisée aux plates-formes commerciales, elle évite les risques d'une seule société qui monopolise votre communication. Choisissez un serveur sur lequel vous faites confiance - selon votre choix, vous pouvez interagir avec tous les autres. N'importe qui peut exécuter sa propre instance de Glitch-Soc et participer au réseau social de façon transparente.
|
||||
Glich-Soc est un réseau social de microblog auto-hébergé et open source. C'est une alternative décentralisée aux plates-formes commerciales comme Twitter. Glich-Soc évite ainsi les risques qu'une seule société monopolise votre communication à des fins commerciales.
|
||||
|
||||
**Version incluse:** 3.1.2
|
||||
**Version incluse:** 3.3.0
|
||||
|
||||
## Points importants à lire avant l'installation
|
||||
|
||||
1. **Glitch-Soc** nécessite un **nom de domaine** dédié, par exemple: glitch.domain.tld
|
||||
1. L'utilisateur sélectionné pendant l'installation sera créé automatiquement dans Glitch-Soc avec des droits d'administration.
|
||||
1. A la fin de l'installation, un mail est envoyé à cet utilisateur avec le mot de passe qui a été généré automatiquement.
|
||||
1. Il semble important de fermer les inscriptions pour votre Glitch-Soc, pour que ça reste une instance privé. Nous vous invitons à bloquer les instances distantes malfaisantes depuis l'interface d'administration. Vous pouvez également ajouter un texte sur votre page d'accueil dans l'administration.
|
||||
1. **Glich-Soc** nécessite un **nom de domaine** dédié, par exemple : glitchsoc.domain.tld
|
||||
1. L'utilisateur sélectionné pendant l'installation sera créé automatiquement dans Glich-Soc avec des droits d'administration.
|
||||
1. À la fin de l'installation, un mail est envoyé à cet utilisateur avec un mot de passe généré automatiquement.
|
||||
1. Pour que votre instance Glich-Soc reste privée, il est important de fermer les inscriptions. Nous vous invitons à bloquer les instances distantes indésirables depuis l'interface d'administration. Vous pouvez également ajouter un texte sur votre page d'accueil dans l'administration.
|
||||
|
||||
## Captures d'écran
|
||||
|
||||
|
@ -25,51 +28,56 @@ Glitch-Soc est un réseau social gratuit et open source. Une alternative décent
|
|||
|
||||
### Installation
|
||||
|
||||
#### Utilisation de __screen__ en cas de déconnection
|
||||
#### Utilisation de *screen* en cas de déconnection
|
||||
```
|
||||
$ sudo apt-get install screen
|
||||
$ screen
|
||||
$ sudo yunohost app install https://github.com/Tagadda/glitch-soc_ynh.git
|
||||
$ sudo yunohost app install https://github.com/YunoHost-Apps/glitch-soc_ynh.git
|
||||
```
|
||||
Récuperer l'installation après une deconnection:
|
||||
Récupérer l'installation après une deconnection :
|
||||
```
|
||||
$ screen -d
|
||||
$ screen -r
|
||||
```
|
||||
L'utilisateur admin est crée automatiquement comme: user@domain.tld
|
||||
L'utilisateur admin est créé automatiquement comme : user@domain.tld
|
||||
|
||||
### Mise à jour
|
||||
### Mise à jour
|
||||
|
||||
#### Utilisation de __screen__ fortement recommandée
|
||||
#### Utilisation de *screen* fortement recommandée
|
||||
|
||||
`$ sudo yunohost app upgrade glitch-soc -u https://github.com/Tagadda/glitch-soc_ynh --debug `
|
||||
`$ sudo yunohost app upgrade glitchsoc -u https://github.com/YunoHost-Apps/glitch-soc_ynh --debug `
|
||||
|
||||
## Documentation
|
||||
|
||||
* Documentation officielle: https://docs.joinmastodon.org/
|
||||
* Documentation officielle : https://docs.joinmastodon.org/
|
||||
|
||||
## Caractéristiques spécifiques YunoHost
|
||||
|
||||
#### Support multi-utilisateurs
|
||||
#### Support multi-utilisateur
|
||||
|
||||
L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'authentifier.
|
||||
|
||||
## Links
|
||||
#### Architectures supportées
|
||||
|
||||
* Signaler un bug: https://github.com/Tagadda/glitch-soc_ynh/issues
|
||||
* Site de l'application: https://glitch-soc.github.io/docs/
|
||||
* Dépôt de l'application principale: https://github.com/glitch-soc/mastodon
|
||||
* Site web YunoHost: https://yunohost.org/
|
||||
* x86-64 - [](https://ci-apps.yunohost.org/ci/apps/mastodon/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/)
|
||||
|
||||
## Liens
|
||||
|
||||
* Signaler un bug : https://github.com/YunoHost-Apps/glitch-soc_ynh/issues
|
||||
* Site de l'application : https://joinmastodon.org/
|
||||
* Dépôt de l'application principale : https://github.com/glitch-soc/mastodon
|
||||
* Site web YunoHost : https://yunohost.org/
|
||||
|
||||
---
|
||||
|
||||
Informations pour les développeurs
|
||||
----------------
|
||||
## Informations pour les développeurs
|
||||
|
||||
Merci de faire vos pull request sur la [branche testing](https://github.com/Tagadda/glitch-soc_ynh/tree/testing).
|
||||
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/glitch-soc_ynh/tree/testing).
|
||||
|
||||
Pour essayer la branche testing, procédez comme suit.
|
||||
```
|
||||
sudo yunohost app install https://github.com/Tagadda/glitch-soc_ynh/tree/testing
|
||||
sudo yunohost app upgrade glitch-soc -u https://github.com/Tagadda/glitch-soc_ynh/tree/testing --debug
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/glitch-soc_ynh/tree/testing --debug
|
||||
ou
|
||||
sudo yunohost app upgrade glitchsoc -u https://github.com/YunoHost-Apps/glitch-soc_ynh/tree/testing --debug
|
||||
```
|
||||
|
|
|
@ -1,26 +1,22 @@
|
|||
;; Nom du test
|
||||
auto_remove=1
|
||||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
admin="john" (USER)
|
||||
language="fr_FR"
|
||||
admin="john" (USER)
|
||||
language="fr_FR"
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=0
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=0
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
backup_restore=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.
|
||||
# incorrect_path=1
|
||||
port_already_use=0
|
||||
change_url=0
|
||||
;;; Levels
|
||||
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
|
||||
Level 5=auto
|
||||
change_url=1
|
||||
;;; Options
|
||||
Email=yalh@yahoo.com
|
||||
Notification=all
|
||||
;;; Upgrade options
|
||||
|
|
|
@ -1,54 +1,66 @@
|
|||
# Service dependencies
|
||||
# You may set REDIS_URL instead for more advanced options
|
||||
# You may also set REDIS_NAMESPACE to share Redis between multiple Mastodon servers
|
||||
# This is a sample configuration file. You can generate your configuration
|
||||
# with the `rake mastodon:setup` interactive setup wizard, but to customize
|
||||
# your setup even further, you'll need to edit it manually. This sample does
|
||||
# not demonstrate all available configuration options. Please look at
|
||||
# https://docs.joinmastodon.org/admin/config/ for the full documentation.
|
||||
|
||||
# Federation
|
||||
# ----------
|
||||
# This identifies your server and cannot be changed safely later
|
||||
# ----------
|
||||
LOCAL_DOMAIN=__DOMAIN__
|
||||
|
||||
# Redis
|
||||
# -----
|
||||
REDIS_HOST=localhost
|
||||
REDIS_PORT=6379
|
||||
# You may set DATABASE_URL instead for more advanced options
|
||||
|
||||
# PostgreSQL
|
||||
# ----------
|
||||
DB_HOST=localhost
|
||||
DB_USER=__DB_USER__
|
||||
DB_NAME=__DB_NAME__
|
||||
DB_PASS=__DB_PWD__
|
||||
DB_PORT=5432
|
||||
# Optional ElasticSearch configuration
|
||||
# You may also set ES_PREFIX to share the same cluster between multiple Mastodon servers (falls back to REDIS_NAMESPACE if not set)
|
||||
|
||||
# ElasticSearch (optional)
|
||||
# ------------------------
|
||||
# ES_ENABLED=true
|
||||
# ES_HOST=es
|
||||
# ES_PORT=9200
|
||||
|
||||
# Federation
|
||||
# Note: Changing LOCAL_DOMAIN at a later time will cause unwanted side effects, including breaking all existing federation.
|
||||
# LOCAL_DOMAIN should *NOT* contain the protocol part of the domain e.g https://example.com.
|
||||
LOCAL_DOMAIN=__DOMAIN__
|
||||
|
||||
# Changing LOCAL_HTTPS in production is no longer supported. (Mastodon will always serve https:// links)
|
||||
|
||||
# Use this only if you need to run mastodon on a different domain than the one used for federation.
|
||||
# You can read more about this option on https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Serving_a_different_domain.md
|
||||
# DO *NOT* USE THIS UNLESS YOU KNOW *EXACTLY* WHAT YOU ARE DOING.
|
||||
# WEB_DOMAIN=mastodon.example.com
|
||||
|
||||
# Use this if you want to have several aliases handler@example1.com
|
||||
# handler@example2.com etc. for the same user. LOCAL_DOMAIN should not
|
||||
# be added. Comma separated values
|
||||
# ALTERNATE_DOMAINS=example1.com,example2.com
|
||||
|
||||
# Application secrets
|
||||
# Generate each with the `RAILS_ENV=production bundle exec rake secret` task (`docker-compose run --rm web rake secret` if you use docker compose)
|
||||
# Secrets
|
||||
# -------
|
||||
# Make sure to use `rake secret` to generate secrets
|
||||
# -------
|
||||
SECRET_KEY_BASE=__SECRET_KEY_BASE__
|
||||
OTP_SECRET=__OTP_SECRET__
|
||||
|
||||
# VAPID keys (used for push notifications
|
||||
# You can generate the keys using the following command (first is the private key, second is the public one)
|
||||
# You should only generate this once per instance. If you later decide to change it, all push subscription will
|
||||
# be invalidated, requiring the users to access the website again to resubscribe.
|
||||
#
|
||||
# Generate with `RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key` task (`docker-compose run --rm web rake mastodon:webpush:generate_vapid_key` if you use docker compose)
|
||||
#
|
||||
# For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html
|
||||
# Web Push
|
||||
# --------
|
||||
# Generate with `rake mastodon:webpush:generate_vapid_key`
|
||||
# --------
|
||||
VAPID_PRIVATE_KEY=__VAPID_PRIVATE_KEY__
|
||||
VAPID_PUBLIC_KEY=__VAPID_PUBLIC_KEY__
|
||||
|
||||
# Sending mail
|
||||
# ------------
|
||||
SMTP_SERVER=localhost
|
||||
SMTP_PORT=25
|
||||
#SMTP_LOGIN=
|
||||
#SMTP_PASSWORD=
|
||||
SMTP_FROM_ADDRESS=__ADMIN_MAIL__
|
||||
#SMTP_REPLY_TO=
|
||||
#SMTP_DOMAIN= # defaults to LOCAL_DOMAIN
|
||||
SMTP_DELIVERY_METHOD=sendmail # delivery method can also be smtp
|
||||
SMTP_AUTH_METHOD=none
|
||||
#SMTP_CA_FILE=/etc/ssl/certs/ca-certificates.crt
|
||||
SMTP_OPENSSL_VERIFY_MODE=none
|
||||
#SMTP_ENABLE_STARTTLS_AUTO=true
|
||||
#SMTP_TLS=true
|
||||
|
||||
# Registrations
|
||||
# ------------
|
||||
# Single user mode will disable registrations and redirect frontpage to the first profile
|
||||
# SINGLE_USER_MODE=true
|
||||
# Prevent registrations with following e-mail domains
|
||||
|
@ -59,41 +71,8 @@ VAPID_PUBLIC_KEY=__VAPID_PUBLIC_KEY__
|
|||
# Optionally change default language
|
||||
DEFAULT_LOCALE=__LANGUAGE__
|
||||
|
||||
# E-mail configuration
|
||||
# Note: Mailgun and SparkPost (https://sparkpo.st/smtp) each have good free tiers
|
||||
# If you want to use an SMTP server without authentication (e.g local Postfix relay)
|
||||
# then set SMTP_AUTH_METHOD and SMTP_OPENSSL_VERIFY_MODE to 'none' and
|
||||
# *comment* SMTP_LOGIN and SMTP_PASSWORD (leaving them blank is not enough).
|
||||
SMTP_SERVER=localhost
|
||||
SMTP_PORT=25
|
||||
#SMTP_LOGIN=
|
||||
#SMTP_PASSWORD=
|
||||
SMTP_FROM_ADDRESS=__SMTP_FROM_ADDRESS__
|
||||
#SMTP_REPLY_TO=
|
||||
#SMTP_DOMAIN= # defaults to LOCAL_DOMAIN
|
||||
SMTP_DELIVERY_METHOD=sendmail # delivery method can also be smtp
|
||||
SMTP_AUTH_METHOD=none
|
||||
#SMTP_CA_FILE=/etc/ssl/certs/ca-certificates.crt
|
||||
SMTP_OPENSSL_VERIFY_MODE=none
|
||||
#SMTP_ENABLE_STARTTLS_AUTO=true
|
||||
#SMTP_TLS=true
|
||||
|
||||
# Optional user upload path and URL (images, avatars). Default is :rails_root/public/system. If you set this variable, you are responsible for making your HTTP server (eg. nginx) serve these files.
|
||||
# PAPERCLIP_ROOT_PATH=/var/lib/mastodon/public-system
|
||||
# PAPERCLIP_ROOT_URL=/system
|
||||
|
||||
# Optional asset host for multi-server setups
|
||||
# The asset host must allow cross origin request from WEB_DOMAIN or LOCAL_DOMAIN
|
||||
# if WEB_DOMAIN is not set. For example, the server may have the
|
||||
# following header field:
|
||||
# Access-Control-Allow-Origin: https://example.com/
|
||||
# CDN_HOST=https://assets.example.com
|
||||
|
||||
# S3 (optional)
|
||||
# The attachment host must allow cross origin request from WEB_DOMAIN or
|
||||
# LOCAL_DOMAIN if WEB_DOMAIN is not set. For example, the server may have the
|
||||
# following header field:
|
||||
# Access-Control-Allow-Origin: https://192.168.1.123:9000/
|
||||
# File storage (optional)
|
||||
# -----------------------
|
||||
# S3_ENABLED=true
|
||||
# S3_BUCKET=
|
||||
# AWS_ACCESS_KEY_ID=
|
||||
|
@ -101,75 +80,10 @@ SMTP_OPENSSL_VERIFY_MODE=none
|
|||
# S3_REGION=
|
||||
# S3_PROTOCOL=http
|
||||
# S3_HOSTNAME=192.168.1.123:9000
|
||||
|
||||
# S3 (Minio Config (optional) Please check Minio instance for details)
|
||||
# The attachment host must allow cross origin request - see the description
|
||||
# above.
|
||||
# S3_ENABLED=true
|
||||
# S3_BUCKET=
|
||||
# AWS_ACCESS_KEY_ID=
|
||||
# AWS_SECRET_ACCESS_KEY=
|
||||
# S3_REGION=
|
||||
# S3_PROTOCOL=https
|
||||
# S3_HOSTNAME=
|
||||
# S3_ENDPOINT=
|
||||
# S3_SIGNATURE_VERSION=
|
||||
|
||||
# Google Cloud Storage (optional)
|
||||
# Use S3 compatible API. Since GCS does not support Multipart Upload,
|
||||
# increase the value of S3_MULTIPART_THRESHOLD to disable Multipart Upload.
|
||||
# The attachment host must allow cross origin request - see the description
|
||||
# above.
|
||||
# S3_ENABLED=true
|
||||
# AWS_ACCESS_KEY_ID=
|
||||
# AWS_SECRET_ACCESS_KEY=
|
||||
# S3_REGION=
|
||||
# S3_PROTOCOL=https
|
||||
# S3_HOSTNAME=storage.googleapis.com
|
||||
# S3_ENDPOINT=https://storage.googleapis.com
|
||||
# S3_MULTIPART_THRESHOLD=52428801 # 50.megabytes
|
||||
|
||||
# Swift (optional)
|
||||
# The attachment host must allow cross origin request - see the description
|
||||
# above.
|
||||
# SWIFT_ENABLED=true
|
||||
# SWIFT_USERNAME=
|
||||
# For Keystone V3, the value for SWIFT_TENANT should be the project name
|
||||
# SWIFT_TENANT=
|
||||
# SWIFT_PASSWORD=
|
||||
# Some OpenStack V3 providers require PROJECT_ID (optional)
|
||||
# SWIFT_PROJECT_ID=
|
||||
# Keystone V2 and V3 URLs are supported. Use a V3 URL if possible to avoid
|
||||
# issues with token rate-limiting during high load.
|
||||
# SWIFT_AUTH_URL=
|
||||
# SWIFT_CONTAINER=
|
||||
# SWIFT_OBJECT_URL=
|
||||
# SWIFT_REGION=
|
||||
# Defaults to 'default'
|
||||
# SWIFT_DOMAIN_NAME=
|
||||
# Defaults to 60 seconds. Set to 0 to disable
|
||||
# SWIFT_CACHE_TTL=
|
||||
|
||||
# Optional alias for S3 (e.g. to serve files on a custom domain, possibly using Cloudfront or Cloudflare)
|
||||
# S3_ALIAS_HOST=
|
||||
|
||||
# Streaming API integration
|
||||
# STREAMING_API_BASE_URL=
|
||||
|
||||
# Advanced settings
|
||||
# If you need to use pgBouncer, you need to disable prepared statements:
|
||||
# PREPARED_STATEMENTS=false
|
||||
|
||||
# Cluster number setting for streaming API server.
|
||||
# If you comment out following line, cluster number will be `numOfCpuCores - 1`.
|
||||
STREAMING_CLUSTER_NUM=1
|
||||
|
||||
# Docker mastodon user
|
||||
# If you use Docker, you may want to assign UID/GID manually.
|
||||
# UID=1000
|
||||
# GID=1000
|
||||
|
||||
# LDAP authentication (optional)
|
||||
# -----------------------
|
||||
LDAP_ENABLED=true
|
||||
LDAP_HOST=localhost
|
||||
LDAP_PORT=389
|
||||
|
@ -184,107 +98,3 @@ LDAP_UID_CONVERSION_ENABLED=true
|
|||
LDAP_UID_CONVERSION_SEARCH=., -
|
||||
LDAP_UID_CONVERSION_REPLACE=_
|
||||
LDAP_TLS_NO_VERIFY=true
|
||||
|
||||
# PAM authentication (optional)
|
||||
# PAM authentication uses for the email generation the "email" pam variable
|
||||
# and optional as fallback PAM_DEFAULT_SUFFIX
|
||||
# The pam environment variable "email" is provided by:
|
||||
# https://github.com/devkral/pam_email_extractor
|
||||
# PAM_ENABLED=true
|
||||
# Fallback email domain for email address generation (LOCAL_DOMAIN by default)
|
||||
# PAM_EMAIL_DOMAIN=example.com
|
||||
# Name of the pam service (pam "auth" section is evaluated)
|
||||
# PAM_DEFAULT_SERVICE=rpam
|
||||
# Name of the pam service used for checking if an user can register (pam "account" section is evaluated) (nil (disabled) by default)
|
||||
# PAM_CONTROLLED_SERVICE=rpam
|
||||
|
||||
# Global OAuth settings (optional) :
|
||||
# If you have only one strategy, you may want to enable this
|
||||
# OAUTH_REDIRECT_AT_SIGN_IN=true
|
||||
|
||||
# Optional CAS authentication (cf. omniauth-cas) :
|
||||
# CAS_ENABLED=true
|
||||
# CAS_URL=https://sso.myserver.com/
|
||||
# CAS_HOST=sso.myserver.com/
|
||||
# CAS_PORT=443
|
||||
# CAS_SSL=true
|
||||
# CAS_VALIDATE_URL=
|
||||
# CAS_CALLBACK_URL=
|
||||
# CAS_LOGOUT_URL=
|
||||
# CAS_LOGIN_URL=
|
||||
# CAS_UID_FIELD='user'
|
||||
# CAS_CA_PATH=
|
||||
# CAS_DISABLE_SSL_VERIFICATION=false
|
||||
# CAS_UID_KEY='user'
|
||||
# CAS_NAME_KEY='name'
|
||||
# CAS_EMAIL_KEY='email'
|
||||
# CAS_NICKNAME_KEY='nickname'
|
||||
# CAS_FIRST_NAME_KEY='firstname'
|
||||
# CAS_LAST_NAME_KEY='lastname'
|
||||
# CAS_LOCATION_KEY='location'
|
||||
# CAS_IMAGE_KEY='image'
|
||||
# CAS_PHONE_KEY='phone'
|
||||
|
||||
# Optional SAML authentication (cf. omniauth-saml)
|
||||
# SAML_ENABLED=true
|
||||
# SAML_ACS_URL=http://localhost:3000/auth/auth/saml/callback
|
||||
# SAML_ISSUER=https://example.com
|
||||
# SAML_IDP_SSO_TARGET_URL=https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO
|
||||
# SAML_IDP_CERT=
|
||||
# SAML_IDP_CERT_FINGERPRINT=
|
||||
# SAML_NAME_IDENTIFIER_FORMAT=
|
||||
# SAML_CERT=
|
||||
# SAML_PRIVATE_KEY=
|
||||
# SAML_SECURITY_WANT_ASSERTION_SIGNED=true
|
||||
# SAML_SECURITY_WANT_ASSERTION_ENCRYPTED=true
|
||||
# SAML_SECURITY_ASSUME_EMAIL_IS_VERIFIED=true
|
||||
# SAML_ATTRIBUTES_STATEMENTS_UID="urn:oid:0.9.2342.19200300.100.1.1"
|
||||
# SAML_ATTRIBUTES_STATEMENTS_EMAIL="urn:oid:1.3.6.1.4.1.5923.1.1.1.6"
|
||||
# SAML_ATTRIBUTES_STATEMENTS_FULL_NAME="urn:oid:2.16.840.1.113730.3.1.241"
|
||||
# SAML_ATTRIBUTES_STATEMENTS_FIRST_NAME="urn:oid:2.5.4.42"
|
||||
# SAML_ATTRIBUTES_STATEMENTS_LAST_NAME="urn:oid:2.5.4.4"
|
||||
# SAML_UID_ATTRIBUTE="urn:oid:0.9.2342.19200300.100.1.1"
|
||||
# SAML_ATTRIBUTES_STATEMENTS_VERIFIED=
|
||||
# SAML_ATTRIBUTES_STATEMENTS_VERIFIED_EMAIL=
|
||||
|
||||
# Use HTTP proxy for outgoing request (optional)
|
||||
# http_proxy=http://gateway.local:8118
|
||||
# Access control for hidden service.
|
||||
# ALLOW_ACCESS_TO_HIDDEN_SERVICE=true
|
||||
|
||||
# Authorized fetch mode (optional)
|
||||
# Require remote servers to authentify when fetching toots, see
|
||||
# https://docs.joinmastodon.org/admin/config/#authorized_fetch
|
||||
# AUTHORIZED_FETCH=true
|
||||
|
||||
# Whitelist mode (optional)
|
||||
# Only allow federation with whitelisted domains, see
|
||||
# https://docs.joinmastodon.org/admin/config/#whitelist_mode
|
||||
# WHITELIST_MODE=true
|
||||
|
||||
# Glitch-Soc Specifics
|
||||
|
||||
# Maximum allowed character count
|
||||
# MAX_TOOT_CHARS=500
|
||||
|
||||
# Maximum number of pinned posts
|
||||
# MAX_PINNED_TOOTS=5
|
||||
|
||||
# Maximum allowed bio characters
|
||||
# MAX_BIO_CHARS=500
|
||||
|
||||
# Maximim number of profile fields allowed
|
||||
# MAX_PROFILE_FIELDS=4
|
||||
|
||||
# Maximum allowed display name characters
|
||||
# MAX_DISPLAY_NAME_CHARS=30
|
||||
|
||||
# Maximum image and video/audio upload sizes
|
||||
# Units are in bytes
|
||||
# 1048576 bytes equals 1 megabyte
|
||||
# MAX_IMAGE_SIZE=8388608
|
||||
# MAX_VIDEO_SIZE=41943040
|
||||
|
||||
# Maximum search results to display
|
||||
# Only relevant when elasticsearch is installed
|
||||
# MAX_SEARCH_RESULTS=20
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
SOURCE_URL=https://github.com/glitch-soc/mastodon/archive/b7e178d2e4102bdaa1ea41dfd8ed50093cf3f60a.tar.gz
|
||||
SOURCE_SUM=ff33ac8a06e8701a21fda86a568e0c1a320419adebb03967102b73bf6b7aa929
|
||||
SOURCE_URL=https://github.com/glitch-soc/mastodon/archive/df326b8b5c0659edb2aca77690a892f228b0e099.tar.gz
|
||||
SOURCE_SUM=9791bd00b76653908fd0d66533e5b31eecff6759f77794e8b64a4ebe2fe3ae50
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
SOURCE_EXTRACT=true
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
RAILS_ENV=production
|
||||
@daily cd __FINAL__PATH__/live && /opt/rbenv/versions/2.6.6/bin/bundle exec rake __USER__:media:remove_remote
|
||||
@daily cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl media remove
|
||||
@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl media remove-orphans
|
||||
@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl accounts cull
|
||||
@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl statuses remove
|
||||
@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl preview_cards remove
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
[Unit]
|
||||
Description=__APP__-sidekiq
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=__APP__
|
||||
WorkingDirectory=__FINALPATH__/live
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="DB_POOL=25"
|
||||
Environment="MALLOC_ARENA_MAX=2"
|
||||
ExecStart=/opt/rbenv/versions/2.6.6/bin/bundle exec sidekiq -c 25
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
StandardError=syslog
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,19 +0,0 @@
|
|||
[Unit]
|
||||
Description=__APP__-streaming
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=__APP__
|
||||
WorkingDirectory=__FINALPATH__/live
|
||||
Environment="NODE_ENV=production"
|
||||
Environment="PORT=__PORT_STREAM__"
|
||||
Environment="STREAMING_CLUSTER_NUM=1"
|
||||
Environment=PATH=__NODEJS_PATH__
|
||||
ExecStart=__NODEJS_PATH__/node ./streaming
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
StandardError=syslog
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,18 +0,0 @@
|
|||
[Unit]
|
||||
Description=__APP__-web
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=__APP__
|
||||
WorkingDirectory=__FINALPATH__/live
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="PORT=__PORT_WEB__"
|
||||
ExecStart=/opt/rbenv/versions/2.6.6/bin/bundle exec puma -C config/puma.rb
|
||||
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
StandardError=syslog
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
18
conf/glitchsoc-sidekiq.service
Normal file
18
conf/glitchsoc-sidekiq.service
Normal file
|
@ -0,0 +1,18 @@
|
|||
[Unit]
|
||||
Description=__APP__-sidekiq
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=__APP__
|
||||
WorkingDirectory=__FINALPATH__/live
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="DB_POOL=25"
|
||||
Environment="MALLOC_ARENA_MAX=2"
|
||||
ExecStart=__RBENV_ROOT__/versions/__APP__/bin/bundle exec sidekiq -c 25
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
StandardError=syslog
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
19
conf/glitchsoc-streaming.service
Normal file
19
conf/glitchsoc-streaming.service
Normal file
|
@ -0,0 +1,19 @@
|
|||
[Unit]
|
||||
Description=__APP__-streaming
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=__APP__
|
||||
WorkingDirectory=__FINALPATH__/live
|
||||
Environment="NODE_ENV=production"
|
||||
Environment="PORT=__PORT_STREAM__"
|
||||
Environment="STREAMING_CLUSTER_NUM=1"
|
||||
Environment="__YNH_NODE_LOAD_PATH__"
|
||||
ExecStart=__YNH_NODE__ ./streaming
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
StandardError=syslog
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
18
conf/glitchsoc-web.service
Normal file
18
conf/glitchsoc-web.service
Normal file
|
@ -0,0 +1,18 @@
|
|||
[Unit]
|
||||
Description=__APP__-web
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=__APP__
|
||||
WorkingDirectory=__FINALPATH__/live
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="PORT=__PORT_WEB__"
|
||||
ExecStart=__RBENV_ROOT__/versions/__APP__/bin/bundle exec puma -C config/puma.rb
|
||||
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
StandardError=syslog
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -19,14 +19,14 @@ location / {
|
|||
}
|
||||
|
||||
location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) {
|
||||
more_set_headers Cache-Control "public, max-age=31536000, immutable";
|
||||
more_set_headers Strict-Transport-Security "max-age=31536000";
|
||||
more_set_headers "Cache-Control: public, max-age=31536000, immutable";
|
||||
more_set_headers "Strict-Transport-Security: max-age=31536000";
|
||||
try_files $uri @proxy;
|
||||
}
|
||||
|
||||
location /sw.js {
|
||||
more_set_headers Cache-Control "public, max-age=0";
|
||||
more_set_headers Strict-Transport-Security "max-age=31536000";
|
||||
more_set_headers "Cache-Control: public, max-age=0";
|
||||
more_set_headers "Strict-Transport-Security: max-age=31536000";
|
||||
try_files $uri @proxy;
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ location @proxy {
|
|||
proxy_cache_valid 200 7d;
|
||||
proxy_cache_valid 410 24h;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
more_set_headers X-Cached $upstream_cache_status;
|
||||
# more_set_headers Strict-Transport-Security "max-age=31536000";
|
||||
more_set_headers "X-Cached: $upstream_cache_status";
|
||||
more_set_headers "Strict-Transport-Security: max-age=31536000";
|
||||
|
||||
tcp_nodelay on;
|
||||
}
|
||||
|
|
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. *Determine if you are on the right place:*
|
||||
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
|
||||
- *Otherwise, the issue may be due to Glich-Soc itself. Refer to its documentation or repository for help.*
|
||||
- *When in doubt, post here and we will figure it out together.*
|
||||
3. *Delete the italic comments as you write over them below, and remove this guide.*
|
||||
---
|
||||
|
||||
### Describe the bug
|
||||
|
||||
*A clear and concise description of what the bug is.*
|
||||
|
||||
### 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 glitchsoc
|
||||
```
|
||||
- *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.*
|
120
manifest.json
120
manifest.json
|
@ -1,65 +1,61 @@
|
|||
{
|
||||
"name": "Glitch-Soc",
|
||||
"id": "glitchsoc",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "A libre and federated social network.",
|
||||
"fr": "Un réseau social libre et fédéré."
|
||||
},
|
||||
"version": "2020-05-14~ynh1",
|
||||
"url": "https://glitch-soc.github.io/docs/",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"maintainer": [
|
||||
{
|
||||
"name": "Tagada"
|
||||
"name": "Glich-Soc",
|
||||
"id": "glitchsoc",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "A libre and federated social network.",
|
||||
"fr": "Un réseau social libre et fédéré."
|
||||
},
|
||||
"version": "2021-04-11-ynh2",
|
||||
"url": "https://github.com/glitch-soc/mastodon",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"maintainer": {
|
||||
"name": "yalh76"
|
||||
},
|
||||
"previous_maintainer": [
|
||||
{
|
||||
"name": "cyp",
|
||||
"email": "cyp@rouquin.me"
|
||||
},
|
||||
{
|
||||
"name": "nemsia",
|
||||
"email": "nemsia@nemsia.org"
|
||||
}
|
||||
],
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.1.3"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"example": "example.com"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"example": "johndoe"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "language",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose the application language",
|
||||
"fr": "Choisissez la langue de l'application"
|
||||
},
|
||||
"choices": ["en_EN", "fr_FR"],
|
||||
"default": "fr_FR"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.7"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for Mastodon",
|
||||
"fr": "Choisissez un domaine pour Mastodon"
|
||||
},
|
||||
"example": "example.com"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"ask": {
|
||||
"en": "Choose an admin user",
|
||||
"fr": "Choisissez l'administrateur"
|
||||
},
|
||||
"example": "johndoe"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Is it a public application?",
|
||||
"fr": "Est-ce une application publique ?"
|
||||
},
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "language",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose the application language",
|
||||
"fr": "Choisissez la langue de l'application"
|
||||
},
|
||||
"choices": ["en_EN", "fr_FR"],
|
||||
"default": "fr_FR"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@
|
|||
- [ ] Fix or enhancement tested.
|
||||
- [ ] Upgrade from last version tested.
|
||||
- [ ] Can be reviewed and tested.
|
||||
|
||||
## Package_check results
|
||||
---
|
||||
* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"*
|
||||
|
|
|
@ -5,7 +5,13 @@
|
|||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3|libgdbm6 libgdbm-dev postgresql postgresql-contrib libidn11-dev libicu-dev libjemalloc-dev curl apt-transport-https"
|
||||
pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3|libgdbm6 libgdbm-dev redis-server redis-tools postgresql postgresql-contrib libidn11-dev libicu-dev libjemalloc-dev curl apt-transport-https"
|
||||
|
||||
MEMORY_NEEDED="2560"
|
||||
|
||||
RUBY_VERSION="2.7.2"
|
||||
|
||||
NODEJS_VERSION="12"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
|
|
|
@ -6,14 +6,13 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
#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 /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Managing script failure..." --weight=1
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
|
@ -24,7 +23,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -33,43 +32,27 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|||
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_script_progression --message="Stopping a systemd service..." --weight=27
|
||||
|
||||
ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped"
|
||||
ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped"
|
||||
ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=systemd --line_match="Stopped"
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the main app directory..." --weight=2
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up nginx web server configuration..." --weight=2
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the PostgreSQL database..." --weight=4
|
||||
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up systemd configuration..." --weight=2
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app-web.service"
|
||||
ynh_backup --src_path="/etc/systemd/system/$app-sidekiq.service"
|
||||
|
@ -78,21 +61,18 @@ ynh_backup --src_path="/etc/systemd/system/$app-streaming.service"
|
|||
#=================================================
|
||||
# BACKUP A CRON FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up a cron file..." --weight=1
|
||||
|
||||
ynh_backup --src_path="/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||
|
||||
ynh_systemd_action --action=start --service_name=${app}-web --line_match="Listening on tcp" --log_path=systemd
|
||||
ynh_systemd_action --action=start --service_name=${app}-sidekiq --line_match="Starting processing" --log_path=systemd
|
||||
ynh_systemd_action --action=start --service_name=${app}-streaming --line_match="Worker 1 now listening" --log_path=systemd
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
269
scripts/install
269
scripts/install
|
@ -9,14 +9,11 @@
|
|||
source _common.sh
|
||||
source ynh_install_ruby__2
|
||||
source ynh_add_swap
|
||||
source ynh_check_ram
|
||||
source ynh_apt
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Managing script failure..." --weight=1
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
|
@ -27,7 +24,6 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Retrieving arguments from the manifest..." --weight=1
|
||||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url="/"
|
||||
|
@ -42,7 +38,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=2
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
@ -53,12 +49,11 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
|||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=2
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
|
||||
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=admin --value=$admin
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||
|
||||
#=================================================
|
||||
|
@ -66,40 +61,41 @@ ynh_app_setting_set --app=$app --key=language --value=$language
|
|||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring firewall..." --weight=1
|
||||
ynh_script_progression --message="Finding an available port..."
|
||||
|
||||
# Find an available port
|
||||
port_web=$(ynh_find_port --port=3000)
|
||||
port_stream=$(ynh_find_port --port=4000)
|
||||
# Open this port
|
||||
ynh_app_setting_set --app=$app --key=port_web --value=$port_web
|
||||
|
||||
port_stream=$(ynh_find_port --port=4000)
|
||||
ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=86
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
|
||||
ynh_install_nodejs --nodejs_version="10"
|
||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
|
||||
# Get Redis >= 4.0
|
||||
if [ "$(lsb_release --codename --short)" = "buster" ]; then
|
||||
ynh_add_app_dependencies "redis-server redis-tools"
|
||||
else
|
||||
ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian stretch-backports main" --package="redis-server redis-tools"
|
||||
fi
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=5
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..."
|
||||
|
||||
# Create postgresql database
|
||||
db_name="${app}_production"
|
||||
db_user=$app
|
||||
# Create PostgreSQL database
|
||||
db_name=$(ynh_sanitize_dbid --db_name="${app}_production")
|
||||
db_user=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_pwd=$(ynh_string_random --length=30)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||
|
@ -110,195 +106,174 @@ ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;"
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=5
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
mkdir $final_path
|
||||
ynh_setup_source --dest_dir="$final_path/live"
|
||||
ynh_setup_source --dest_dir="$final_path/live"
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring nginx web server..." --weight=3
|
||||
ynh_script_progression --message="Configuring NGINX web server..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config 'port_web port_stream'
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --weight=4
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# ADD SWAP IF NEEDED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding swap is needed..." --weight=4
|
||||
ynh_script_progression --message="Adding swap if needed..."
|
||||
|
||||
total_memory=$(ynh_check_ram)
|
||||
total_swap=$(ynh_check_ram --only_swap)
|
||||
total_memory=$(ynh_get_ram --total)
|
||||
swap_needed=0
|
||||
|
||||
if [ $total_memory -lt 2560 ]; then
|
||||
# Need a minimum of 8Go of memory
|
||||
swap_needed=$((2560 - $total_memory))
|
||||
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
||||
# Need a minimum of 2.5Go of memory
|
||||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# INSTALLING RUBY AND BUNDLER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=424
|
||||
|
||||
ynh_install_ruby --ruby_version=2.6.6
|
||||
/opt/rbenv/versions/2.6.6/bin/gem update --system
|
||||
/opt/rbenv/versions/2.6.6/bin/gem install bundler:1.17.3 --no-document
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Modifying a config file..." --weight=2
|
||||
|
||||
cp -f ../conf/.env.production.sample "$final_path/live/.env.production"
|
||||
ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target_file="$final_path/live/.env.production"
|
||||
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/live/.env.production"
|
||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/live/.env.production"
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/live/.env.production"
|
||||
ynh_replace_string --match_string="__SMTP_FROM_ADDRESS__" --replace_string="$admin_mail" --target_file="${final_path}/live/.env.production"
|
||||
|
||||
language="$(echo $language | head -c 2)"
|
||||
ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/live/.env.production"
|
||||
|
||||
paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128)
|
||||
ynh_replace_string --match_string="PAPERCLIP_SECRET=" --replace_string="PAPERCLIP_SECRET=$paperclip_secret" --target_file="${final_path}/live/.env.production"
|
||||
ynh_app_setting_set --app="$app" --key=paperclip_secret --value="$paperclip_secret"
|
||||
|
||||
secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128)
|
||||
ynh_replace_string --match_string="__SECRET_KEY_BASE__" --replace_string="$secret_key_base" --target_file="$final_path/live/.env.production"
|
||||
ynh_app_setting_set --app="$app" --key=secret_key_base --value="$secret_key_base"
|
||||
|
||||
otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128)
|
||||
ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret" --target_file="$final_path/live/.env.production"
|
||||
ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret"
|
||||
|
||||
ynh_replace_string --match_string="dev.glitch.social" --replace_string="$domain" --target_file="$final_path/live/config/settings.yml"
|
||||
ynh_replace_string --match_string="registrations_mode: 'open'" --replace_string="registrations_mode: 'none'" --target_file="$final_path/live/config/settings.yml"
|
||||
|
||||
#=================================================
|
||||
# INSTALLING Glitch-Soc
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Glitch-Soc..." --weight=2230
|
||||
|
||||
chown -R "$app": "$final_path"
|
||||
ynh_script_progression --message="Installing Ruby..."
|
||||
|
||||
pushd "$final_path/live"
|
||||
ynh_use_nodejs
|
||||
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.6/bin/bundle config deployment 'true'
|
||||
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.6/bin/bundle config without 'development test'
|
||||
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.6/bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
|
||||
sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile
|
||||
sudo -u "$app" echo "SAFETY_ASSURED=1">> .env.production
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails db:setup --quiet
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails assets:precompile --quiet
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > acc.txt
|
||||
ynh_use_ruby
|
||||
ynh_gem update --system
|
||||
ynh_gem install bundler --no-document
|
||||
popd
|
||||
|
||||
admin_pass=$( tail -1 $final_path/live/acc.txt | head -1 | cut -c 15- )
|
||||
ynh_secure_remove --file="$final_path/live/acc.txt"
|
||||
|
||||
vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt")
|
||||
vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$final_path/live/key.txt")
|
||||
|
||||
ynh_replace_string --match_string="__VAPID_PRIVATE_KEY__" --replace_string="$vapid_private_key" --target_file="${final_path}/live/.env.production"
|
||||
ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapid_public_key" --target_file="${final_path}/live/.env.production"
|
||||
|
||||
ynh_app_setting_set --app="$app" --key=vapid_private_key --value="$vapid_private_key"
|
||||
ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_key"
|
||||
|
||||
ynh_secure_remove --file="$final_path/live/key.txt"
|
||||
|
||||
#=================================================
|
||||
# SETUP CRON JOB FOR REMOVING CACHE
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setuping a cron job for removing cache..." --weight=1
|
||||
ynh_script_progression --message="Adding a config file..."
|
||||
|
||||
ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron"
|
||||
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron"
|
||||
cp -f ../conf/cron /etc/cron.d/$app
|
||||
config="$final_path/live/.env.production"
|
||||
|
||||
language="$(echo $language | head -c 2)"
|
||||
|
||||
secret_key_base=$(ynh_string_random --length=128)
|
||||
ynh_app_setting_set --app="$app" --key=secret_key_base --value="$secret_key_base"
|
||||
|
||||
otp_secret=$(ynh_string_random --length=128)
|
||||
ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret"
|
||||
|
||||
vapid_private_key=""
|
||||
vapid_public_key=""
|
||||
|
||||
ynh_add_config --template="../conf/.env.production.sample" --destination="$config"
|
||||
|
||||
chmod 400 "$config"
|
||||
chown $app:$app "$config"
|
||||
|
||||
ynh_replace_string --match_string="registrations_mode: 'open'" --replace_string="registrations_mode: 'none'" --target_file="$final_path/live/config/settings.yml"
|
||||
ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="min_invite_role: 'none'" --target_file="$final_path/live/config/settings.yml"
|
||||
|
||||
ynh_store_file_checksum --file="$final_path/live/config/settings.yml"
|
||||
|
||||
chmod 400 "$final_path/live/config/settings.yml"
|
||||
chown $app:$app "$final_path/live/config/settings.yml"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=5
|
||||
ynh_script_progression --message="Configuring a systemd service..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/glitch-web.service"
|
||||
ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/glitch-streaming.service"
|
||||
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/glitch-streaming.service"
|
||||
ynh_add_systemd_config --service="$app-web" --template="glitch-web.service"
|
||||
ynh_add_systemd_config --service="$app-sidekiq" --template="glitch-sidekiq.service"
|
||||
ynh_add_systemd_config --service="$app-streaming" --template="glitch-streaming.service"
|
||||
ynh_add_systemd_config --service="$app-web" --template="glitchsoc-web.service" --others_var="port_web RBENV_ROOT"
|
||||
ynh_add_systemd_config --service="$app-sidekiq" --template="glitchsoc-sidekiq.service" --others_var="RBENV_ROOT"
|
||||
ynh_add_systemd_config --service="$app-streaming" --template="glitchsoc-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
# INSTALLING GLITCH-SOC
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing the config file checksum..." --weight=1
|
||||
ynh_script_progression --message="Installing Glich-Soc..."
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="${final_path}/live/.env.production"
|
||||
pushd "$final_path/live"
|
||||
sudo -u $app $ynh_ruby_load_path bin/bundle config deployment 'true'
|
||||
sudo -u $app $ynh_ruby_load_path bin/bundle config without 'development test'
|
||||
sudo -u $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
|
||||
ynh_use_nodejs
|
||||
sudo -u $app $ynh_node_load_PATH yarn install --pure-lockfile
|
||||
echo "SAFETY_ASSURED=1">> $config
|
||||
sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:setup --quiet
|
||||
sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet
|
||||
sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
|
||||
sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null
|
||||
sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts modify "$admin" --approve
|
||||
popd
|
||||
|
||||
vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt")
|
||||
ynh_app_setting_set --app="$app" --key=vapid_private_key --value="$vapid_private_key"
|
||||
|
||||
vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$final_path/live/key.txt")
|
||||
ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_key"
|
||||
|
||||
ynh_secure_remove --file="$final_path/live/key.txt"
|
||||
|
||||
ynh_delete_file_checksum --file="$config"
|
||||
|
||||
ynh_add_config --template="../conf/.env.production.sample" --destination="$config"
|
||||
|
||||
chmod 400 "$config"
|
||||
chown $app:$app "$config"
|
||||
|
||||
#=================================================
|
||||
# SETUP THE CRON FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setuping the cron file..."
|
||||
|
||||
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Securing files and directories..." --weight=9
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R "$app": "$final_path"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=3
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add "$app-web"
|
||||
yunohost service add "$app-sidekiq"
|
||||
yunohost service add "$app-streaming"
|
||||
yunohost service add "$app-web" --description="$app web service"
|
||||
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
||||
yunohost service add "$app-streaming" --description="$app streaming service"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=47
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on tcp"
|
||||
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Starting processing"
|
||||
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
||||
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
|
||||
ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=systemd --line_match="Worker 1 now listening"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring SSOwat..." --weight=2
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=2
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -306,4 +281,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression --message="Installation of $app completed"
|
||||
|
|
|
@ -9,19 +9,18 @@
|
|||
source _common.sh
|
||||
source ynh_install_ruby__2
|
||||
source ynh_add_swap
|
||||
source ynh_apt
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=6
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$app
|
||||
db_user=$(ynh_sanitize_dbid --db_name=$app)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
|
@ -29,31 +28,30 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing service integration in YunoHost..." --weight=2
|
||||
|
||||
# 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-web" >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app-web service..." --weight=2
|
||||
ynh_script_progression --message="Removing $app-web service integration..."
|
||||
yunohost service remove "$app-web"
|
||||
fi
|
||||
|
||||
if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app-sidekiq service..." --weight=2
|
||||
ynh_script_progression --message="Removing $app-sidekiq service integration..."
|
||||
yunohost service remove "$app-sidekiq"
|
||||
fi
|
||||
|
||||
if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app-streaming service..." --weight=2
|
||||
ynh_script_progression --message="Removing $app-streaming service integration..."
|
||||
yunohost service remove "$app-streaming"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=27
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config --service="$app-web"
|
||||
|
@ -63,26 +61,26 @@ ynh_remove_systemd_config --service="$app-streaming"
|
|||
#=================================================
|
||||
# REMOVE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4
|
||||
ynh_script_progression --message="Removing the PostgreSQL database..."
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name"
|
||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=28
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_ruby
|
||||
ynh_remove_app_dependencies
|
||||
ynh_remove_nodejs
|
||||
ynh_remove_app_dependencies
|
||||
ynh_remove_extra_repo
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=16
|
||||
ynh_script_progression --message="Removing app main directory..."
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
@ -90,9 +88,9 @@ ynh_secure_remove --file="$final_path"
|
|||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing nginx web server configuration..." --weight=2
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
|
@ -100,7 +98,7 @@ ynh_remove_nginx_config
|
|||
#=================================================
|
||||
# REMOVE THE CRON FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the cron file..." --weight=2
|
||||
ynh_script_progression --message="Removing the cron file..."
|
||||
|
||||
# Remove a cron file
|
||||
ynh_secure_remove --file="/etc/cron.d/$app"
|
||||
|
@ -113,7 +111,7 @@ ynh_del_swap
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=2
|
||||
ynh_script_progression --message="Removing the dedicated system user..."
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
|
@ -122,4 +120,4 @@ ynh_system_user_delete --username=$app
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
ynh_script_progression --message="Removal of $app completed"
|
||||
|
|
107
scripts/restore
107
scripts/restore
|
@ -6,18 +6,15 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
#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/ynh_install_ruby__2
|
||||
source ../settings/scripts/ynh_add_swap
|
||||
source ../settings/scripts/ynh_check_ram
|
||||
source ../settings/scripts/ynh_apt
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Managing script failure..." --weight=2
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
|
@ -28,7 +25,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..." --weight=2
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -36,13 +33,13 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$app
|
||||
db_user=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=2
|
||||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
|
@ -54,74 +51,79 @@ test ! -d $final_path \
|
|||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring nginx configuration..." --weight=1
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=105
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=5
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring users rights..." --weight=4
|
||||
|
||||
# Restore permissions on app files
|
||||
chown -R $app: $final_path
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# ADD SWAP IF NEEDED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding swap if needed..." --weight=4
|
||||
ynh_script_progression --message="Adding swap if needed..."
|
||||
|
||||
total_memory=$(ynh_check_ram)
|
||||
total_swap=$(ynh_check_ram --only_swap)
|
||||
total_memory=$(ynh_get_ram --total)
|
||||
swap_needed=0
|
||||
|
||||
if [ $total_memory -lt 2560 ]; then
|
||||
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
||||
# Need a minimum of 8Go of memory
|
||||
swap_needed=$((2560 - $total_memory))
|
||||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE CRON FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the cron file..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=63
|
||||
ynh_script_progression --message="Reinstalling dependencies..."
|
||||
|
||||
ynh_install_nodejs --nodejs_version="10"
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||
|
||||
#=================================================
|
||||
# INSTALLING RUBY AND BUNDLER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=393
|
||||
ynh_script_progression --message="Installing Ruby..."
|
||||
|
||||
ynh_install_ruby --ruby_version=2.6.6
|
||||
/opt/rbenv/versions/2.6.6/bin/gem update --system
|
||||
/opt/rbenv/versions/2.6.6/bin/gem install bundler:1.17.3 --no-document
|
||||
pushd "$final_path/live"
|
||||
ynh_use_ruby
|
||||
ynh_gem update --system
|
||||
ynh_gem install bundler --no-document
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=18
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
||||
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
|
@ -131,44 +133,37 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
|||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=3
|
||||
ynh_script_progression --message="Restoring the systemd configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service"
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-streaming.service"
|
||||
systemctl enable "$app-web" "$app-sidekiq" "$app-streaming"
|
||||
systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" --quiet
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=3
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app-web
|
||||
yunohost service add $app-sidekiq
|
||||
yunohost service add $app-streaming
|
||||
yunohost service add "$app-web" --description="$app web service"
|
||||
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
||||
yunohost service add "$app-streaming" --description="$app streaming service"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=41
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on tcp"
|
||||
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Starting processing"
|
||||
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
||||
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
|
||||
ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=systemd --line_match="Worker 1 now listening"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE CRON FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring a cron job for removing cache..." --weight=2
|
||||
|
||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=2
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -176,4 +171,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
ynh_script_progression --message="Restoration completed for $app"
|
||||
|
|
305
scripts/upgrade
305
scripts/upgrade
|
@ -9,118 +9,104 @@
|
|||
source _common.sh
|
||||
source ynh_install_ruby__2
|
||||
source ynh_add_swap
|
||||
source ynh_check_ram
|
||||
source ynh_apt
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=4
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
||||
db_user=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
admin_mail=$(ynh_user_get_info --username=$admin --key='mail')
|
||||
port_web=$(ynh_app_setting_get --app=$app --key=port_web)
|
||||
port_stream=$(ynh_app_setting_get --app=$app --key=port_stream)
|
||||
|
||||
paperclip_secret=$(ynh_app_setting_get --app=$app --key=paperclip_secret)
|
||||
secret_key_base=$(ynh_app_setting_get --app=$app --key=secret_key_base)
|
||||
otp_secret=$(ynh_app_setting_get --app=$app --key=otp_secret)
|
||||
vapid_private_key=$(ynh_app_setting_get --app=$app --key=vapid_private_key)
|
||||
vapid_public_key=$(ynh_app_setting_get --app=$app --key=vapid_public_key)
|
||||
|
||||
config="$final_path/live/.env.production"
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking version..." --weight=1
|
||||
ynh_script_progression --message="Checking version..."
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z "$db_name" ]; then
|
||||
db_name="${app}_production"
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Create a permission if needed
|
||||
if ! ynh_permission_exists --permission="api"; then
|
||||
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true"
|
||||
fi
|
||||
|
||||
# Check if admin is not null
|
||||
if [[ "$admin" = "" || "$language" = "" ]]; then
|
||||
echo "Unable to upgrade, please contact support"
|
||||
ynh_die
|
||||
fi
|
||||
|
||||
# If port_web doesn't exist, create it, need for old install
|
||||
# If port_web doesn't exist, create it, needed for old install
|
||||
if [[ -z "$port_web" ]]; then
|
||||
port_web=3000
|
||||
ynh_app_setting_set --app=$app --key=port_web --value=$port_web
|
||||
fi
|
||||
|
||||
# If port_web doesn't exist, create it, need for old install
|
||||
# If port_web doesn't exist, create it, needed for old install
|
||||
if [[ -z "$port_stream" ]]; then
|
||||
port_stream=4000
|
||||
ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
|
||||
fi
|
||||
|
||||
# If db_pwd doesn't exist, create it, need for old install
|
||||
# If db_pwd doesn't exist, create it, needed for old install
|
||||
if [[ -z "$db_pwd" ]]; then
|
||||
db_pwd=$(ynh_string_random)
|
||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||
ynh_psql_test_if_first_run
|
||||
sudo --login --user=postgres psql -c"ALTER user $app WITH PASSWORD '$db_pwd'" postgres
|
||||
ynh_replace_string --match_string="DB_PASS=" --replace_string="DB_PASS=${db_pwd}" --target_file="${final_path}/live/.env.production"
|
||||
ynh_replace_string --match_string="DB_PASS=" --replace_string="DB_PASS=${db_pwd}" --target_file="$config"
|
||||
fi
|
||||
|
||||
# If paperclip_secret doesn't exist, retrieve it or create it
|
||||
if [[ -z "$paperclip_secret" ]]; then
|
||||
paperclip_secret=$(grep -oP "PAPERCLIP_SECRET=\K\w+" ${final_path}/live/.env.production)
|
||||
if [[ -z "$paperclip_secret" ]]; then
|
||||
paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128)
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=paperclip_secret --value="$paperclip_secret"
|
||||
fi
|
||||
# Remove paperclip_secret
|
||||
ynh_app_setting_delete --app=$app --key=paperclip_secret
|
||||
|
||||
# If secret_key_base doesn't exist, retrieve it or create it
|
||||
if [[ -z "$secret_key_base" ]]; then
|
||||
secret_key_base=$(grep -oP "SECRET_KEY_BASE=\K\w+" ${final_path}/live/.env.production)
|
||||
secret_key_base=$(grep -oP "SECRET_KEY_BASE=\K\w+" $config)
|
||||
if [[ -z "$secret_key_base" ]]; then
|
||||
secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128)
|
||||
secret_key_base=$(ynh_string_random --length=128)
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=secret_key_base --value="$secret_key_base"
|
||||
fi
|
||||
|
||||
# If otp_secret doesn't exist, retrieve it or create it
|
||||
if [[ -z "$otp_secret" ]]; then
|
||||
otp_secret=$(grep -oP "OTP_SECRET=\K\w+" ${final_path}/live/.env.production)
|
||||
otp_secret=$(grep -oP "OTP_SECRET=\K\w+" $config)
|
||||
if [[ -z "$otp_secret" ]]; then
|
||||
otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128)
|
||||
otp_secret=$(ynh_string_random --length=128)
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=otp_secret --value="$otp_secret"
|
||||
fi
|
||||
|
||||
# If vapid_private_key doesn't exist, retrieve it or create it
|
||||
if [[ -z "$vapid_private_key" ]]; then
|
||||
vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" ${final_path}/live/.env.production)
|
||||
vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" ${final_path}/live/.env.production)
|
||||
vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" $config)
|
||||
vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" $config)
|
||||
ynh_app_setting_set "$app" vapid_private_key "$vapid_private_key"
|
||||
ynh_app_setting_set "$app" vapid_public_key "$vapid_public_key"
|
||||
fi
|
||||
|
@ -131,237 +117,190 @@ ynh_remove_extra_repo
|
|||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=442
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
# restore it if the upgrade fails
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK THE PATH
|
||||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
# N.B. : this is for app installations before YunoHost 2.7
|
||||
# where this value might be something like /foo/ or foo/
|
||||
# instead of /foo ....
|
||||
# If nobody installed your app before 2.7, then you may
|
||||
# safely remove this line
|
||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=22
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped"
|
||||
ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped"
|
||||
ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=systemd --line_match="Stopped"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=14
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
|
||||
# Download Glitch-Soc
|
||||
tmpdir="$(mktemp -d)"
|
||||
# Download Glich-Soc
|
||||
tmpdir="$(mktemp -d)"
|
||||
|
||||
mkdir $tmpdir/system
|
||||
if [ -d "$final_path/live/public/system" ]; then
|
||||
rsync -a "$final_path/live/public/system" "$tmpdir/."
|
||||
fi
|
||||
rsync -a "$final_path/live/.env.production" "$tmpdir/."
|
||||
ynh_secure_remove --file="$final_path/live"
|
||||
ynh_setup_source --dest_dir="$final_path/live"
|
||||
mkdir $tmpdir/system
|
||||
if [ -d "$final_path/live/public/system" ]; then
|
||||
mv --verbose --no-target-directory --backup=numbered "$final_path/live/public/system" "$final_path/system.tmp"
|
||||
fi
|
||||
rsync -a "$config" "$tmpdir/."
|
||||
ynh_secure_remove --file="$final_path/live"
|
||||
|
||||
ynh_setup_source --dest_dir="$final_path/live"
|
||||
|
||||
if [ -d "$tmpdir/system" ]; then
|
||||
rsync -a "$tmpdir/system" "$final_path/live/public/."
|
||||
fi
|
||||
rsync -a "$tmpdir/.env.production" "$final_path/live/."
|
||||
ynh_secure_remove --file="$tmpdir"
|
||||
if [ -d "$final_path/system.tmp" ]; then
|
||||
mv --verbose --no-target-directory "$final_path/system.tmp" "$final_path/live/public/system"
|
||||
fi
|
||||
rsync -a "$tmpdir/.env.production" "$final_path/live/."
|
||||
ynh_secure_remove --file="$tmpdir"
|
||||
|
||||
# Clean files which are not needed anymore
|
||||
ynh_secure_remove --file="$final_path/live/config/initializers/timeout.rb"
|
||||
# Clean files which are not needed anymore
|
||||
ynh_secure_remove --file="$final_path/live/config/initializers/timeout.rb"
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=3
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config 'port_web port_stream'
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=24
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
ynh_remove_nodejs
|
||||
ynh_install_nodejs --nodejs_version="10"
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=7
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# ADD SWAP IF NEEDED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding swap if needed..." --weight=7
|
||||
ynh_script_progression --message="Adding swap if needed..."
|
||||
|
||||
total_memory=$(ynh_check_ram)
|
||||
total_swap=$(ynh_check_ram --only_swap)
|
||||
total_memory=$(ynh_get_ram --total)
|
||||
swap_needed=0
|
||||
|
||||
if [ $total_memory -lt 2560 ]; then
|
||||
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
||||
# Need a minimum of 8Go of memory
|
||||
swap_needed=$((2560 - $total_memory))
|
||||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# INSTALLING RUBY AND BUNDLER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=424
|
||||
|
||||
ynh_install_ruby --ruby_version=2.6.6
|
||||
/opt/rbenv/versions/2.6.6/bin/gem update --system
|
||||
/opt/rbenv/versions/2.6.6/bin/gem install bundler:1.17.3 --no-document
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Modifying a config file..." --weight=1
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$final_path/live/.env.production"
|
||||
cp -f ../conf/.env.production.sample "$final_path/live/.env.production"
|
||||
ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target_file="$final_path/live/.env.production"
|
||||
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/live/.env.production"
|
||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/live/.env.production"
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/live/.env.production"
|
||||
ynh_replace_string --match_string="__SMTP_FROM_ADDRESS__" --replace_string="$admin_mail" --target_file="${final_path}/live/.env.production"
|
||||
|
||||
language="$(echo $language | head -c 2)"
|
||||
ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/live/.env.production"
|
||||
|
||||
ynh_replace_string --match_string="PAPERCLIP_SECRET=" --replace_string="PAPERCLIP_SECRET=$paperclip_secret" --target_file="${final_path}/live/.env.production"
|
||||
|
||||
ynh_replace_string --match_string="__SECRET_KEY_BASE__" --replace_string="$secret_key_base" --target_file="$final_path/live/.env.production"
|
||||
|
||||
ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret" --target_file="$final_path/live/.env.production"
|
||||
|
||||
ynh_replace_string "__VAPID_PRIVATE_KEY__" "$vapid_private_key" "$final_path/live/.env.production"
|
||||
ynh_replace_string "__VAPID_PUBLIC_KEY__" "$vapid_public_key" "$final_path/live/.env.production"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE Glitch-Soc
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading Glitch-Soc..." --weight=2640
|
||||
|
||||
chown -R "$app": "$final_path"
|
||||
ynh_script_progression --message="Installing Ruby..."
|
||||
|
||||
pushd "$final_path/live"
|
||||
ynh_use_nodejs
|
||||
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.6/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test
|
||||
sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails db:migrate
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails assets:clean
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails assets:precompile
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl cache clear
|
||||
ynh_use_ruby
|
||||
ynh_gem update --system
|
||||
ynh_gem install bundler --no-document
|
||||
popd
|
||||
|
||||
# If vapid_private_key doesn't exist, retrieve it or create it
|
||||
#if [[ -z "$vapid_private_key" ]]; then
|
||||
# sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
|
||||
# vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt")
|
||||
# vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$final_path/live/key.txt")
|
||||
# ynh_app_setting_set "$app" vapid_private_key "$vapid_private_key"
|
||||
# ynh_app_setting_set "$app" vapid_public_key "$vapid_public_key"
|
||||
# ynh_secure_remove "$final_path/live/key.txt"
|
||||
# ynh_replace_string "__VAPID_PRIVATE_KEY__" "$vapid_private_key" "${final_path}/live/.env.production"
|
||||
# ynh_replace_string "__VAPID_PUBLIC_KEY__" "$vapid_public_key" "${final_path}/live/.env.production"
|
||||
#fi
|
||||
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum --file="${final_path}/live/.env.production"
|
||||
|
||||
#=================================================
|
||||
# SETUP CRON JOB FOR REMOVING CACHE
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setuping a cron job for removing cache..." --weight=1
|
||||
ynh_script_progression --message="Updating a config file..."
|
||||
|
||||
ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron"
|
||||
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron"
|
||||
cp -f ../conf/cron /etc/cron.d/$app
|
||||
language="$(echo $language | head -c 2)"
|
||||
|
||||
ynh_add_config --template="../conf/.env.production.sample" --destination="$config"
|
||||
|
||||
chmod 400 "$config"
|
||||
chown $app:$app "$config"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=13
|
||||
ynh_script_progression --message="Upgrading systemd configuration..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/glitch-web.service"
|
||||
ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/glitch-streaming.service"
|
||||
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/glitch-streaming.service"
|
||||
ynh_add_systemd_config --service="$app-web" --template="glitch-web.service"
|
||||
ynh_add_systemd_config --service="$app-sidekiq" --template="glitch-sidekiq.service"
|
||||
ynh_add_systemd_config --service="$app-streaming" --template="glitch-streaming.service"
|
||||
ynh_add_systemd_config --service="$app-web" --template="glitchsoc-web.service" --others_var="port_web RBENV_ROOT"
|
||||
ynh_add_systemd_config --service="$app-sidekiq" --template="glitchsoc-sidekiq.service" --others_var="RBENV_ROOT"
|
||||
ynh_add_systemd_config --service="$app-streaming" --template="glitchsoc-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE GLITCH-SOC
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading Glich-Soc..."
|
||||
|
||||
chown -R "$app": "$final_path"
|
||||
|
||||
pushd "$final_path/live"
|
||||
sudo -u $app $ynh_ruby_load_path bin/bundle config deployment 'true'
|
||||
sudo -u $app $ynh_ruby_load_path bin/bundle config without 'development test'
|
||||
sudo -u $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
|
||||
ynh_use_nodejs
|
||||
sudo -u $app $ynh_node_load_PATH yarn install --pure-lockfile
|
||||
sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:clean
|
||||
sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile
|
||||
sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:migrate
|
||||
sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl cache clear
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# SETUP THE CRON FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setuping the cron file..."
|
||||
|
||||
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Securing files and directories..." --weight=9
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R $app: $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway
|
||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||
fi
|
||||
yunohost service add "$app-web" --description="$app web service"
|
||||
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
||||
yunohost service add "$app-streaming" --description="$app streaming service"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=48
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on tcp"
|
||||
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Starting processing"
|
||||
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
||||
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
|
||||
ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=systemd --line_match="Worker 1 now listening"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=2
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -369,4 +308,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
ynh_script_progression --message="Upgrade of $app completed"
|
||||
|
|
343
scripts/ynh_apt
343
scripts/ynh_apt
|
@ -1,343 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Define and install dependencies with a equivs control file
|
||||
#
|
||||
# This helper can/should only be called once per app
|
||||
#
|
||||
# example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5"
|
||||
#
|
||||
# usage: ynh_install_app_dependencies dep [dep [...]]
|
||||
# | arg: dep - the package name to install in dependence. Writing "dep3|dep4|dep5" can be used to specify alternatives. For example : dep1 dep2 "dep3|dep4|dep5" will require to install dep1 and dep 2 and (dep3 or dep4 or dep5).
|
||||
#
|
||||
# Requires YunoHost version 2.6.4 or higher.
|
||||
ynh_install_app_dependencies () {
|
||||
local dependencies=$@
|
||||
# Add a comma for each space between packages. But not add a comma if the space separate a version specification. (See below)
|
||||
dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')"
|
||||
local 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 --delimiter='"' --fields=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
|
||||
|
||||
#
|
||||
# Epic ugly hack to fix the goddamn dependency nightmare of sury
|
||||
# Sponsored by the "Djeezusse Fokin Kraiste Why Do Adminsys Has To Be So Fucking Complicated I Should Go Grow Potatoes Instead Of This Shit" collective
|
||||
# https://github.com/YunoHost/issues/issues/1407
|
||||
#
|
||||
# If we require to install php dependency
|
||||
if echo $dependencies | grep --quiet 'php'
|
||||
then
|
||||
# And we have packages from sury installed (7.0.33-10+weirdshiftafter instead of 7.0.33-0 on debian)
|
||||
if dpkg --list | grep "php7.0" | grep --quiet --invert-match "7.0.33-0+deb9"
|
||||
then
|
||||
# And sury ain't already installed
|
||||
if ! grep --line-number --recursive --quiet "sury" /etc/apt/sources.list*
|
||||
then
|
||||
# Re-add sury
|
||||
ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(ynh_get_debian_release) main" --key="https://packages.sury.org/php/apt.gpg" --name=extra_php_version
|
||||
|
||||
# Pin this sury repository to prevent sury of doing shit
|
||||
ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" --priority=200 --name=extra_php_version
|
||||
ynh_pin_repo --package="php${YNH_DEFAULT_PHP_VERSION}*" --pin="origin \"packages.sury.org\"" --priority=600 --name=extra_php_version --append
|
||||
fi
|
||||
fi
|
||||
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"
|
||||
}
|
||||
|
||||
# Add dependencies to install with ynh_install_app_dependencies
|
||||
#
|
||||
# usage: ynh_add_app_dependencies --package=phpversion [--replace]
|
||||
# | arg: -p, --package= - Packages to add as dependencies for the app.
|
||||
# | arg: -r, --replace - Replace dependencies instead of adding to existing ones.
|
||||
#
|
||||
# Requires YunoHost version 3.8.1 or higher.
|
||||
ynh_add_app_dependencies () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=pr
|
||||
local -A 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}"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
||||
# 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.
|
||||
#
|
||||
# Requires YunoHost version 3.8.1 or higher.
|
||||
ynh_install_extra_app_dependencies () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=rpkn
|
||||
local -A 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:-}
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
# Add an extra repository correctly, pin it and get the key.
|
||||
#
|
||||
# [internal]
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Requires YunoHost version 3.8.1 or higher.
|
||||
ynh_install_extra_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=rkpna
|
||||
local -A 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:-}
|
||||
priority=${priority:-}
|
||||
|
||||
if [ $append -eq 1 ]
|
||||
then
|
||||
append="--append"
|
||||
wget_append="tee --append"
|
||||
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 --parents "/etc/apt/trusted.gpg.d"
|
||||
# Timeout option is here to enforce the timeout on dns query and tcp connect (c.f. man wget)
|
||||
wget --timeout 900 --quiet "$key" --output-document=- | 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.
|
||||
#
|
||||
# [internal]
|
||||
#
|
||||
# usage: ynh_remove_extra_repo [--name=name]
|
||||
# | arg: -n, --name= - Name for the files for this repo, $app as default value.
|
||||
#
|
||||
# Requires YunoHost version 3.8.1 or higher.
|
||||
ynh_remove_extra_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=n
|
||||
local -A args_array=( [n]=name= )
|
||||
local name
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
name="${name:-$app}"
|
||||
|
||||
ynh_secure_remove "/etc/apt/sources.list.d/$name.list"
|
||||
ynh_secure_remove "/etc/apt/preferences.d/$name"
|
||||
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg"
|
||||
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc"
|
||||
|
||||
# Update the list of package to exclude the old repo
|
||||
ynh_package_update
|
||||
}
|
||||
|
||||
# Add a repository.
|
||||
#
|
||||
# [internal]
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# Requires YunoHost version 3.8.1 or higher.
|
||||
ynh_add_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=uscna
|
||||
local -A 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 --append"
|
||||
else
|
||||
append="tee"
|
||||
fi
|
||||
|
||||
mkdir --parents "/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"
|
||||
}
|
||||
|
||||
# Pin a repository.
|
||||
#
|
||||
# [internal]
|
||||
#
|
||||
# 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#How_APT_Interprets_Priorities for information about pinning.
|
||||
#
|
||||
# Requires YunoHost version 3.8.1 or higher.
|
||||
ynh_pin_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=pirna
|
||||
local -A 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 --append"
|
||||
else
|
||||
append="tee"
|
||||
fi
|
||||
|
||||
mkdir --parents "/etc/apt/preferences.d"
|
||||
echo "Package: $package
|
||||
Pin: $pin
|
||||
Pin-Priority: $priority
|
||||
" \
|
||||
| $append "/etc/apt/preferences.d/$name"
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check the amount of available RAM
|
||||
#
|
||||
# usage: ynh_check_ram [--required=RAM required in Mb] [--no_swap|--only_swap] [--free_ram]
|
||||
# | arg: -r, --required= - Amount of RAM required in Mb. The helper will return 0 is there's enough RAM, or 1 otherwise.
|
||||
# If --required isn't set, the helper will print the amount of RAM, in Mb.
|
||||
# | arg: -s, --no_swap - Ignore swap
|
||||
# | arg: -o, --only_swap - Ignore real RAM, consider only swap.
|
||||
# | arg: -f, --free_ram - Count only free RAM, not the total amount of RAM available.
|
||||
ynh_check_ram () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [r]=required= [s]=no_swap [o]=only_swap [f]=free_ram )
|
||||
local required
|
||||
local no_swap
|
||||
local only_swap
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
required=${required:-}
|
||||
no_swap=${no_swap:-0}
|
||||
only_swap=${only_swap:-0}
|
||||
|
||||
local total_ram=$(vmstat --stats --unit M | grep "total memory" | awk '{print $1}')
|
||||
local total_swap=$(vmstat --stats --unit M | grep "total swap" | awk '{print $1}')
|
||||
local total_ram_swap=$(( total_ram + total_swap ))
|
||||
|
||||
local free_ram=$(vmstat --stats --unit M | grep "free memory" | awk '{print $1}')
|
||||
local free_swap=$(vmstat --stats --unit M | grep "free swap" | awk '{print $1}')
|
||||
local free_ram_swap=$(( free_ram + free_swap ))
|
||||
|
||||
# Use the total amount of ram
|
||||
local ram=$total_ram_swap
|
||||
if [ $free_ram -eq 1 ]
|
||||
then
|
||||
# Use the total amount of free ram
|
||||
ram=$free_ram_swap
|
||||
if [ $no_swap -eq 1 ]
|
||||
then
|
||||
# Use only the amount of free ram
|
||||
ram=$free_ram
|
||||
elif [ $only_swap -eq 1 ]
|
||||
then
|
||||
# Use only the amount of free swap
|
||||
ram=$free_swap
|
||||
fi
|
||||
else
|
||||
if [ $no_swap -eq 1 ]
|
||||
then
|
||||
# Use only the amount of free ram
|
||||
ram=$total_ram
|
||||
elif [ $only_swap -eq 1 ]
|
||||
then
|
||||
# Use only the amount of free swap
|
||||
ram=$total_swap
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$required" ]
|
||||
then
|
||||
# Return 1 if the amount of ram isn't enough.
|
||||
if [ $ram -lt $required ]
|
||||
then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
|
||||
# If no RAM is required, return the amount of available ram.
|
||||
else
|
||||
echo $ram
|
||||
fi
|
||||
}
|
|
@ -1,47 +1,88 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args
|
||||
ynh_ruby_try_bash_extension() {
|
||||
if [ -x src/configure ]; then
|
||||
src/configure && make -C src || {
|
||||
ynh_print_info --message="Optional bash extension failed to build, but things will still work normally."
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
rbenv_install_dir="/opt/rbenv"
|
||||
ruby_version_path="$rbenv_install_dir/versions"
|
||||
# RBENV_ROOT is the directory of rbenv, it needs to be loaded as a environment variable.
|
||||
export RBENV_ROOT="$rbenv_install_dir"
|
||||
|
||||
# Install ruby version management
|
||||
# Load the version of Ruby for an app, and set variables.
|
||||
#
|
||||
# [internal]
|
||||
# ynh_use_ruby has to be used in any app scripts before using Ruby for the first time.
|
||||
# This helper will provide alias and variables to use in your scripts.
|
||||
#
|
||||
# usage: ynh_install_rbenv
|
||||
ynh_install_rbenv () {
|
||||
echo "Installation of rbenv - ruby version management" >&2
|
||||
# Build an app.src for rbenv
|
||||
mkdir -p "../conf"
|
||||
echo "SOURCE_URL=https://github.com/rbenv/rbenv/archive/v1.1.2.tar.gz
|
||||
SOURCE_SUM=80ad89ffe04c0b481503bd375f05c212bbc7d44ef5f5e649e0acdf25eba86736" > "../conf/rbenv.src"
|
||||
# Download and extract rbenv
|
||||
ynh_setup_source "$rbenv_install_dir" rbenv
|
||||
# To use gem or Ruby, use the alias `ynh_gem` and `ynh_ruby`
|
||||
# Those alias will use the correct version installed for the app
|
||||
# For example: use `ynh_gem install` instead of `gem install`
|
||||
#
|
||||
# With `sudo` or `ynh_exec_as`, use instead the fallback variables `$ynh_gem` and `$ynh_ruby`
|
||||
# And propagate $PATH to sudo with $ynh_ruby_load_path
|
||||
# Exemple: `ynh_exec_as $app $ynh_ruby_load_path $ynh_gem install`
|
||||
#
|
||||
# $PATH contains the path of the requested version of Ruby.
|
||||
# However, $PATH is duplicated into $ruby_path to outlast any manipulation of $PATH
|
||||
# You can use the variable `$ynh_ruby_load_path` to quickly load your Ruby version
|
||||
# in $PATH for an usage into a separate script.
|
||||
# Exemple: $ynh_ruby_load_path $final_path/script_that_use_gem.sh`
|
||||
#
|
||||
#
|
||||
# Finally, to start a Ruby service with the correct version, 2 solutions
|
||||
# Either the app is dependent of Ruby or gem, but does not called it directly.
|
||||
# In such situation, you need to load PATH
|
||||
# `Environment="__YNH_RUBY_LOAD_ENV_PATH__"`
|
||||
# `ExecStart=__FINALPATH__/my_app`
|
||||
# You will replace __YNH_RUBY_LOAD_ENV_PATH__ with $ynh_ruby_load_path
|
||||
#
|
||||
# Or Ruby start the app directly, then you don't need to load the PATH variable
|
||||
# `ExecStart=__YNH_RUBY__ my_app run`
|
||||
# You will replace __YNH_RUBY__ with $ynh_ruby
|
||||
#
|
||||
#
|
||||
# one other variable is also available
|
||||
# - $ruby_path: The absolute path to Ruby binaries for the chosen version.
|
||||
#
|
||||
# usage: ynh_use_ruby
|
||||
#
|
||||
# Requires YunoHost version 3.2.2 or higher.
|
||||
ynh_use_ruby () {
|
||||
ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
|
||||
|
||||
# Build an app.src for ruby-build
|
||||
mkdir -p "../conf"
|
||||
echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20200401.tar.gz
|
||||
SOURCE_SUM=c67517e8c6b015134b1ae4b19a5a15728054a642fad7223cd28af3ba4cc1828e" > "../conf/ruby-build.src"
|
||||
# Download and extract ruby-build
|
||||
ynh_setup_source "$rbenv_install_dir/plugins/ruby-build" ruby-build
|
||||
# Get the absolute path of this version of Ruby
|
||||
ruby_path="$ruby_version_path/$YNH_APP_INSTANCE_NAME/bin"
|
||||
|
||||
(cd $rbenv_install_dir
|
||||
./src/configure && make -C src)
|
||||
# Allow alias to be used into bash script
|
||||
shopt -s expand_aliases
|
||||
|
||||
# Create shims directory if needed
|
||||
if [ ! -d $rbenv_install_dir/shims ] ; then
|
||||
mkdir $rbenv_install_dir/shims
|
||||
fi
|
||||
# Create an alias for the specific version of Ruby and a variable as fallback
|
||||
ynh_ruby="$ruby_path/ruby"
|
||||
alias ynh_ruby="$ynh_ruby"
|
||||
# And gem
|
||||
ynh_gem="$ruby_path/gem"
|
||||
alias ynh_gem="$ynh_gem"
|
||||
|
||||
# Load the path of this version of Ruby in $PATH
|
||||
if [[ :$PATH: != *":$ruby_path"* ]]; then
|
||||
PATH="$ruby_path:$PATH"
|
||||
fi
|
||||
# Create an alias to easily load the PATH
|
||||
ynh_ruby_load_path="PATH=$PATH"
|
||||
|
||||
# Sets the local application-specific Ruby version
|
||||
pushd $final_path
|
||||
$rbenv_install_dir/bin/rbenv local $ruby_version
|
||||
popd
|
||||
}
|
||||
|
||||
# Install a specific version of ruby
|
||||
# Install a specific version of Ruby
|
||||
#
|
||||
# ynh_install_ruby will install the version of ruby provided as argument by using rbenv.
|
||||
#
|
||||
# rbenv (ruby version management) stores the target ruby version in a .ruby_version file created in the target folder (using rbenv local <version>)
|
||||
# It then uses that information for every ruby user that uses rbenv provided ruby command
|
||||
# ynh_install_ruby will install the version of Ruby provided as argument by using rbenv.
|
||||
#
|
||||
# This helper creates a /etc/profile.d/rbenv.sh that configures PATH environment for rbenv
|
||||
# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin)
|
||||
|
@ -51,93 +92,213 @@ fi
|
|||
# When not possible (e.g. in systemd service definition), please use direct path
|
||||
# to rbenv shims (e.g. $RBENV_ROOT/shims/bundle)
|
||||
#
|
||||
# usage: ynh_install_ruby ruby_version user
|
||||
# usage: ynh_install_ruby --ruby_version=ruby_version
|
||||
# | arg: -v, --ruby_version= - Version of ruby to install.
|
||||
# If possible, prefer to use major version number (e.g. 8 instead of 8.10.0).
|
||||
# The crontab will handle the update of minor versions when needed.
|
||||
#
|
||||
# Requires YunoHost version 3.2.2 or higher.
|
||||
ynh_install_ruby () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [v]=ruby_version= )
|
||||
# Use rbenv, https://github.com/rbenv/rbenv to manage the ruby versions
|
||||
local ruby_version
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=v
|
||||
local -A args_array=( [v]=ruby_version= )
|
||||
local ruby_version
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
# Create $rbenv_install_dir
|
||||
mkdir -p "$rbenv_install_dir/plugins/ruby-build"
|
||||
# Load rbenv path in PATH
|
||||
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
||||
|
||||
# Load rbenv path in PATH
|
||||
CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
||||
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||
|
||||
# Remove /usr/local/bin in PATH in case of ruby prior installation
|
||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||
# Move an existing Ruby binary, to avoid to block rbenv
|
||||
test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv
|
||||
|
||||
# Move an existing ruby binary, to avoid to block rbenv
|
||||
test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv
|
||||
# Install or update rbenv
|
||||
rbenv="$(command -v rbenv $rbenv_install_dir/bin/rbenv | grep "$rbenv_install_dir/bin/rbenv" | head -1)"
|
||||
if [ -n "$rbenv" ]; then
|
||||
ynh_print_info --message="rbenv already seems installed in \`$rbenv'."
|
||||
pushd "${rbenv%/*/*}"
|
||||
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/rbenv.git"; then
|
||||
ynh_print_info --message="Trying to update with git..."
|
||||
git pull -q --tags origin master
|
||||
ynh_ruby_try_bash_extension
|
||||
else
|
||||
ynh_print_info --message="Reinstalling rbenv with git..."
|
||||
cd ..
|
||||
ynh_secure_remove --file=$rbenv_install_dir
|
||||
mkdir -p $rbenv_install_dir
|
||||
cd $rbenv_install_dir
|
||||
git init -q
|
||||
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||
git checkout -q -b master origin/master
|
||||
ynh_ruby_try_bash_extension
|
||||
rbenv=$rbenv_install_dir/bin/rbenv
|
||||
fi
|
||||
popd
|
||||
else
|
||||
ynh_print_info --message="Installing rbenv with git..."
|
||||
mkdir -p $rbenv_install_dir
|
||||
pushd $rbenv_install_dir
|
||||
git init -q
|
||||
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||
git checkout -q -b master origin/master
|
||||
ynh_ruby_try_bash_extension
|
||||
rbenv=$rbenv_install_dir/bin/rbenv
|
||||
popd
|
||||
fi
|
||||
|
||||
# If rbenv is not previously setup, install it
|
||||
if ! type rbenv > /dev/null 2>&1
|
||||
then
|
||||
ynh_install_rbenv
|
||||
elif dpkg --compare-versions "$(/opt/rbenv/bin/rbenv --version | cut -d" " -f2)" lt "1.1.2"
|
||||
then
|
||||
ynh_install_rbenv
|
||||
fi
|
||||
ruby_build="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
|
||||
if [ -n "$ruby_build" ]; then
|
||||
ynh_print_info --message="\`rbenv install' command already available in \`$ruby_build'."
|
||||
pushd "${ruby_build%/*/*}"
|
||||
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/ruby-build.git"; then
|
||||
ynh_print_info --message="Trying to update rbenv with git..."
|
||||
git pull -q origin master
|
||||
fi
|
||||
popd
|
||||
else
|
||||
ynh_print_info --message="Installing ruby-build with git..."
|
||||
mkdir -p "${rbenv_install_dir}/plugins"
|
||||
git clone -q https://github.com/rbenv/ruby-build.git "${rbenv_install_dir}/plugins/ruby-build"
|
||||
fi
|
||||
|
||||
# Restore /usr/local/bin in PATH (if needed)
|
||||
PATH=$CLEAR_PATH
|
||||
rbenv_alias="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)"
|
||||
if [ -n "$rbenv_alias" ]; then
|
||||
ynh_print_info --message="\`rbenv alias' command already available in \`$rbenv_alias'."
|
||||
pushd "${rbenv_alias%/*/*}"
|
||||
if git remote -v 2>/dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then
|
||||
ynh_print_info --message="Trying to update rbenv-aliases with git..."
|
||||
git pull -q origin master
|
||||
fi
|
||||
popd
|
||||
else
|
||||
ynh_print_info --message="Installing rbenv-aliases with git..."
|
||||
mkdir -p "${rbenv_install_dir}/plugins"
|
||||
git clone -q https://github.com/tpope/rbenv-aliases.git "${rbenv_install_dir}/plugins/rbenv-aliase"
|
||||
fi
|
||||
|
||||
# And replace the old ruby binary
|
||||
test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby
|
||||
rbenv_latest="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)"
|
||||
if [ -n "$rbenv_latest" ]; then
|
||||
ynh_print_info --message="\`rbenv latest' command already available in \`$rbenv_latest'."
|
||||
pushd "${rbenv_latest%/*/*}"
|
||||
if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
|
||||
ynh_print_info --message="Trying to update xxenv-latest with git..."
|
||||
git pull -q origin master
|
||||
fi
|
||||
popd
|
||||
else
|
||||
ynh_print_info --message="Installing xxenv-latest with git..."
|
||||
mkdir -p "${rbenv_install_dir}/plugins"
|
||||
git clone -q https://github.com/momo-lab/xxenv-latest.git "${rbenv_install_dir}/plugins/xxenv-latest"
|
||||
fi
|
||||
|
||||
# Install the requested version of ruby
|
||||
CONFIGURE_OPTS="--disable-install-doc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version
|
||||
# Enable caching
|
||||
mkdir -p "${rbenv_install_dir}/cache"
|
||||
|
||||
# Store the ID of this app and the version of ruby requested for it
|
||||
echo "$YNH_APP_ID:$ruby_version" | tee --append "$rbenv_install_dir/ynh_app_version"
|
||||
# Create shims directory if needed
|
||||
mkdir -p "${rbenv_install_dir}/shims"
|
||||
|
||||
# Store ruby_version into the config of this app
|
||||
ynh_app_setting_set $app ruby_version $ruby_version
|
||||
# Restore /usr/local/bin in PATH
|
||||
PATH=$CLEAR_PATH
|
||||
|
||||
# Set environment for ruby users
|
||||
echo "#rbenv
|
||||
# And replace the old Ruby binary
|
||||
test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby
|
||||
|
||||
# Install the requested version of Ruby
|
||||
local final_ruby_version=$(rbenv latest --print $ruby_version)
|
||||
if ! [ -n "$final_ruby_version" ]; then
|
||||
final_ruby_version=$ruby_version
|
||||
fi
|
||||
ynh_print_info --message="Installing Ruby-$final_ruby_version"
|
||||
CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $final_ruby_version > /dev/null 2>&1
|
||||
|
||||
# Store ruby_version into the config of this app
|
||||
ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$final_ruby_version
|
||||
|
||||
# Remove app virtualenv
|
||||
if `rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME " 1>/dev/null 2>&1`
|
||||
then
|
||||
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||
fi
|
||||
|
||||
# Create app virtualenv
|
||||
rbenv alias $YNH_APP_INSTANCE_NAME $final_ruby_version
|
||||
|
||||
# Cleanup Ruby versions
|
||||
ynh_cleanup_ruby
|
||||
|
||||
# Set environment for Ruby users
|
||||
echo "#rbenv
|
||||
export RBENV_ROOT=$rbenv_install_dir
|
||||
export PATH=\"$rbenv_install_dir/bin:$PATH\"
|
||||
eval \"\$(rbenv init -)\"
|
||||
#rbenv" > /etc/profile.d/rbenv.sh
|
||||
|
||||
# Load the right environment for the Installation
|
||||
eval "$(rbenv init -)"
|
||||
|
||||
(cd $final_path
|
||||
rbenv local $ruby_version)
|
||||
# Load the environment
|
||||
eval "$(rbenv init -)"
|
||||
}
|
||||
|
||||
# Remove the version of ruby used by the app.
|
||||
# Remove the version of Ruby used by the app.
|
||||
#
|
||||
# This helper will check if another app uses the same version of ruby,
|
||||
# if not, this version of ruby will be removed.
|
||||
# If no other app uses ruby, rbenv will be also removed.
|
||||
# This helper will also cleanup Ruby versions
|
||||
#
|
||||
# usage: ynh_remove_ruby
|
||||
ynh_remove_ruby () {
|
||||
ruby_version=$(ynh_app_setting_get $app ruby_version)
|
||||
local ruby_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=ruby_version)
|
||||
|
||||
# Remove the line for this app
|
||||
sed --in-place "/$YNH_APP_ID:$ruby_version/d" "$rbenv_install_dir/ynh_app_version"
|
||||
# Load rbenv path in PATH
|
||||
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
||||
|
||||
# If no other app uses this version of ruby, remove it.
|
||||
if ! grep --quiet "$ruby_version" "$rbenv_install_dir/ynh_app_version"
|
||||
then
|
||||
$rbenv_install_dir/bin/rbenv uninstall --force $ruby_version
|
||||
fi
|
||||
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||
|
||||
# Remove rbenv environment configuration
|
||||
rm /etc/profile.d/rbenv.sh
|
||||
rbenv alias $YNH_APP_INSTANCE_NAME --remove
|
||||
|
||||
# If no other app uses rbenv, remove rbenv and dedicated group
|
||||
if [ ! -s "$rbenv_install_dir/ynh_app_version" ]
|
||||
then
|
||||
ynh_secure_remove "$rbenv_install_dir"
|
||||
fi
|
||||
# Remove the line for this app
|
||||
ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=ruby_version
|
||||
|
||||
# Cleanup Ruby versions
|
||||
ynh_cleanup_ruby
|
||||
}
|
||||
|
||||
# Remove no more needed versions of Ruby used by the app.
|
||||
#
|
||||
# This helper will check what Ruby version are no more required,
|
||||
# and uninstall them
|
||||
# If no app uses Ruby, rbenv will be also removed.
|
||||
#
|
||||
# usage: ynh_cleanup_ruby
|
||||
ynh_cleanup_ruby () {
|
||||
|
||||
# List required Ruby versions
|
||||
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
||||
local required_ruby_versions=""
|
||||
for installed_app in $installed_apps
|
||||
do
|
||||
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
||||
if [[ $installed_app_ruby_version ]]
|
||||
then
|
||||
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove no more needed Ruby versions
|
||||
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
||||
for installed_ruby_version in $installed_ruby_versions
|
||||
do
|
||||
if ! `echo ${required_ruby_versions} | grep "${installed_ruby_version}" 1>/dev/null 2>&1`
|
||||
then
|
||||
ynh_print_info --message="Removing of Ruby-$installed_ruby_version"
|
||||
$rbenv_install_dir/bin/rbenv uninstall --force $installed_ruby_version
|
||||
fi
|
||||
done
|
||||
|
||||
# If none Ruby version is required
|
||||
if [[ ! $required_ruby_versions ]]
|
||||
then
|
||||
# Remove rbenv environment configuration
|
||||
ynh_print_info --message="Removing of rbenv-$rbenv_version"
|
||||
ynh_secure_remove --file="$rbenv_install_dir"
|
||||
ynh_secure_remove --file="/etc/profile.d/rbenv.sh"
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue