1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mastodon_ynh.git synced 2024-09-03 19:46:02 +02:00
This commit is contained in:
Tagadda 2023-05-19 15:46:03 +02:00
parent 7903402c63
commit 282ae0cf48
16 changed files with 218 additions and 410 deletions

22
check_process Normal file
View file

@ -0,0 +1,22 @@
;; Test complet
; Manifest
domain="domain.tld"
is_public=1
admin="john"
language="fr_FR"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
# 4.02~ynh2
upgrade=1 from_commit=94381183ca2d14da72234b53c9a83972ffb16e54
backup_restore=1
multi_instance=0
change_url=0
;;; Options
Email=yalh@yahoo.com
Notification=all

View file

@ -30,11 +30,14 @@ DB_NAME=__DB_NAME__
DB_PASS=__DB_PWD__
DB_PORT=5432
# ElasticSearch (optional)
# Elasticsearch (optional)
# ------------------------
# ES_ENABLED=true
# ES_HOST=es
ES_ENABLED=false
# ES_HOST=localhost
# ES_PORT=9200
# Authentication for ES (optional)
# ES_USER=elastic
# ES_PASS=password
# Secrets
# -------
@ -54,17 +57,10 @@ VAPID_PUBLIC_KEY=__VAPID_PUBLIC_KEY__
# ------------
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
# ------------
@ -80,16 +76,13 @@ DEFAULT_LOCALE=__LANGUAGE__
# File storage (optional)
# -----------------------
# S3_ENABLED=true
# S3_BUCKET=
S3_ENABLED=false
# S3_BUCKET=files.example.com
# AWS_ACCESS_KEY_ID=
# AWS_SECRET_ACCESS_KEY=
# S3_REGION=
# S3_PROTOCOL=http
# S3_HOSTNAME=192.168.1.123:9000
# S3_ALIAS_HOST=
# S3_ALIAS_HOST=files.example.com
# LDAP authentication (optional)
# IP and session retention
# -----------------------
LDAP_ENABLED=true
LDAP_HOST=localhost
@ -105,3 +98,9 @@ LDAP_UID_CONVERSION_ENABLED=true
LDAP_UID_CONVERSION_SEARCH=., -
LDAP_UID_CONVERSION_REPLACE=_
LDAP_TLS_NO_VERIFY=true
# Make sure to modify the scheduling of ip_cleanup_scheduler in config/sidekiq.yml
# to be less than daily if you lower IP_RETENTION_PERIOD below two days (172800).
# -----------------------
IP_RETENTION_PERIOD=1209600
SESSION_RETENTION_PERIOD=1209600

13
doc/ADMIN.md Normal file
View file

@ -0,0 +1,13 @@
## Update
### Using *screen* highly recommended
`$ sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh --debug `
## Administrate with tooctl
`$ (cd /var/www/mastodon/live && sudo -u mastodon RAILS_ENV=production PATH=/opt/rbenv/versions/mastodon/bin bin/tootctl --help)`
## Known Bugs
- Log-out from YunoHost's portal doesn't log out from Mastodon. See https://github.com/YunoHost/issues/issues/501

13
doc/ADMIN_fr.md Normal file
View file

@ -0,0 +1,13 @@
## Mise à jour
### Utilisation de *screen* fortement recommandée
`$ sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh --debug `
## Administration avec tooctl
`$ (cd /var/www/mastodon/live && sudo -u mastodon RAILS_ENV=production PATH=/opt/rbenv/versions/mastodon/bin bin/tootctl --help)`
## Bugs connus
- Se déconnecter depuis le portail YunoHost ne vous déconnecte pas de Mastodon. Voir https://github.com/YunoHost/issues/issues/501

View file

@ -1,45 +0,0 @@
## Points importants à lire avant l'installation
1. **Mastodon** nécessite un **nom de domaine** dédié, par exemple : mastodon.domain.tld
1. L'utilisateur sélectionné pendant l'installation sera créé automatiquement dans Mastodon 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 Mastodon 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
![](https://framalibre.org/sites/default/files/mastodon.png)
## Configuration
### Installation
#### Utilisation de *screen* en cas de déconnection
```
$ sudo apt-get install screen
$ screen
$ sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh.git
```
Récupérer l'installation après une deconnection :
```
$ screen -d
$ screen -r
```
L'utilisateur admin est créé automatiquement comme : user@domain.tld
### Mise à jour
#### Utilisation de *screen* fortement recommandée
`$ sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh --debug `
### Administration avec tooctl
`$ (cd /var/www/mastodon/live && sudo -u mastodon RAILS_ENV=production PATH=/opt/rbenv/versions/mastodon/bin bin/tootctl --help)`
## Caractéristiques spécifiques YunoHost
#### Support multi-utilisateur
L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'authentifier.
Se déconnecter depuis le portail YunoHost ne vous déconnecte pas de Mastodon. Voir https://github.com/YunoHost/issues/issues/501

View file

@ -5,11 +5,8 @@
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 Mastodon, 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.
## Configuration
## Using *screen* in case of disconnect
### Install
#### Using *screen* in case of disconnect
```
$ sudo apt-get install screen
$ screen
@ -20,21 +17,3 @@ Recover after disconnect:
$ screen -d
$ screen -r
```
### Update
#### Using *screen* highly recommended
`$ sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh --debug `
### Administrate with tooctl
`$ (cd /var/www/mastodon/live && sudo -u mastodon RAILS_ENV=production PATH=/opt/rbenv/versions/mastodon/bin bin/tootctl --help)`
## YunoHost specific features
#### Multi-users support
LDAP authentication is activated. All YunoHost users can authenticate.
Log-out from YunoHost's portal doesn't log out from Mastodon. See https://github.com/YunoHost/issues/issues/501

21
doc/PRE_INSTALL_fr.md Normal file
View file

@ -0,0 +1,21 @@
## Points importants à lire avant l'installation
1. **Mastodon** nécessite un **nom de domaine** dédié, par exemple : mastodon.domain.tld
1. L'utilisateur sélectionné pendant l'installation sera créé automatiquement dans Mastodon 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 Mastodon 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.
## Utilisation de *screen* en cas de déconnexion
L'installation de Mastodon peut être longue, selon les performances du serveur. Pour éviter que le processus soit interrompu par une déconnexion, on peut utiliser `screen`.
```
$ sudo apt-get install screen
$ screen
$ sudo yunohost app install mastodon
```
Récupérer l'installation après une deconnection :
```
$ screen -d
$ screen -r
```

69
manifest.json Normal file
View file

@ -0,0 +1,69 @@
{
"name": "Mastodon",
"id": "mastodon",
"packaging_format": 1,
"description": {
"en": "Libre and federated social network",
"fr": "Réseau social libre et fédéré"
},
"version": "4.1.2~ynh1",
"url": "https://github.com/mastodon/mastodon",
"upstream": {
"license": "AGPL-3.0-or-later",
"website": "https://joinmastodon.org/",
"demo": "https://joinmastodon.org/",
"admindoc": "https://docs.joinmastodon.org/",
"code": "https://github.com/mastodon/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.3.0"
},
"multi_instance": true,
"services": [
"nginx"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"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"
},
{
"name": "admin",
"type": "user"
}
]
}
}

View file

@ -15,15 +15,15 @@ website = "https://joinmastodon.org/"
demo = "https://joinmastodon.org/"
admindoc = "https://docs.joinmastodon.org/"
code = "https://github.com/mastodon/mastodon"
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
cpe = " cpe:2.3:a:joinmastodon:mastodon"
fund = "https://joinmastodon.org/sponsors"
[integration]
yunohost = ">= 4.3.0"
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
architectures = "all"
multi_instance = true
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
ldap = true
sso = true
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
@ -50,6 +50,14 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen
type = "user"
[resources]
[resources.sources]
[resources.sources.main]
url = "https://github.com/tootsuite/mastodon/archive/refs/tags/v4.1.2.tar.gz"
sha256 = "12837c7b57acc11ebd24b23a270500c8917459ecdc2a841ba452296b02bcaf29"
autoupdate.strategy = "latest_github_release"
autoupdate.asset = "*.tar.gz"
[resources.system_user]
[resources.install_dir]
@ -57,6 +65,12 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen
[resources.permissions]
main.url = "/"
api.url = "/api"
api.allowed = "visitors"
api.auth_header = false
api.show_tile = false
api.protected = true
[resources.ports]
web.default = 3000
stream.default = 4000
@ -64,7 +78,7 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen
[resources.apt]
packages = "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-tools, redis-server, postgresql, postgresql-contrib, libidn11-dev, libicu-dev, libjemalloc-dev, curl, apt-transport-https"
[[resources.apt.extras]]
[resources.apt.extras]
repo = "deb https://dl.yarnpkg.com/debian/ stable main"
key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
packages = "yarn"

View file

@ -4,10 +4,6 @@
# COMMON VARIABLES
#=================================================
# dependencies used by the app (must be on a single line)
#REMOVEME? 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-tools redis-server postgresql postgresql-contrib libidn11-dev libicu-dev libjemalloc-dev curl apt-transport-https"
#REMOVEME? build_pkg_dependencies=""
memory_needed="2560"
ruby_version=3.0.6
nodejs_version=16

View file

@ -10,27 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
#REMOVEME? ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_print_info --message="Loading installation settings..."
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================

View file

@ -12,107 +12,29 @@ source ynh_add_swap
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
# RETRIEVE ARGUMENTS
#=================================================
#REMOVEME? ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
path="/"
#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
#REMOVEME? language=$YNH_APP_ARG_LANGUAGE
#REMOVEME? admin=$YNH_APP_ARG_ADMIN
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1
#REMOVEME? install_dir=/var/www/$app
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
# Register (book) web path
#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
ynh_app_setting_set --app=$app --key=language --value=$language
#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
#REMOVEME? port_web=$(ynh_find_port --port=3000)
#REMOVEME? ynh_app_setting_set --app=$app --key=port_web --value=$port_web
#REMOVEME? port_stream=$(ynh_find_port --port=4000)
#REMOVEME? ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
#=================================================
# INSTALL DEPENDENCIES
#=================================================
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_script_progression --message="Installing Ruby and NodeJS..." --weight=1
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#REMOVEME? ynh_exec_warn_less 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
#=================================================
#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1
#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name="${app}_production")
#REMOVEME? db_user=$(ynh_sanitize_dbid --db_name=$app)
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
#REMOVEME? ynh_app_setting_set --app=$app --key=db_user --value=$db_user
#REMOVEME? ynh_psql_test_if_first_run
#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;"
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir/live"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
@ -159,11 +81,11 @@ 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"
# We need rake to build vapid keys, we generate them later once the app is installed
vapid_private_key=""
vapid_public_key=""
ynh_add_config --template="../conf/.env.production.sample" --destination="$config"
chmod 400 "$config"
chown $app:$app "$config"
@ -181,6 +103,7 @@ chown $app:$app "$install_dir/live/config/settings.yml"
ynh_script_progression --message="Building app..." --weight=1
pushd "$install_dir/live"
# Building ruby packages
ynh_use_ruby
ynh_gem update --system
ynh_gem install bundler --no-document
@ -188,34 +111,30 @@ pushd "$install_dir/live"
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config without 'development test'
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config set force_ruby_platform true
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
# Building assets
ynh_use_nodejs
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install --pure-lockfile
echo "SAFETY_ASSURED=1">> $config
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails db:setup --quiet
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:precompile --quiet
# Generate vapid keys
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=Admin > /dev/null
# Create the first admin user
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=Owner > /dev/null
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl accounts modify "$admin" --approve
popd
# Re-generate config with vapid keys
vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$install_dir/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.+" "$install_dir/live/key.txt")
ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_key"
#REMOVEME? ynh_secure_remove --file="$install_dir/live/key.txt"
ynh_secure_remove --file="$install_dir/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"
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_package_autoremove
#=================================================
# SETUP SYSTEMD
#=================================================
@ -253,28 +172,6 @@ ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd
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
#=================================================
#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary
#REMOVEME? if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
fi
#REMOVEME? ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true"
#=================================================
# RELOAD NGINX
#=================================================
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -11,18 +11,6 @@ source ynh_install_ruby__2
source ynh_add_swap
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#=================================================
# STANDARD REMOVE
#=================================================
@ -58,22 +46,6 @@ ynh_remove_systemd_config --service="$app-web"
ynh_remove_systemd_config --service="$app-sidekiq"
ynh_remove_systemd_config --service="$app-streaming"
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
#REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
# Remove a database if it exists, along with the associated user
#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
#REMOVEME? ynh_secure_remove --file="$install_dir"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
@ -85,12 +57,11 @@ ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1
ynh_script_progression --message="Removing Ruby and NodeJS..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_ruby
ynh_remove_nodejs
#REMOVEME? ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
@ -108,12 +79,9 @@ ynh_del_swap
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
# ...
#=================================================
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
#REMOVEME? ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT

View file

@ -12,47 +12,8 @@ source ../settings/scripts/ynh_install_ruby__2
source ../settings/scripts/ynh_add_swap
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
#REMOVEME? ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
#REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $install_dir "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
@ -69,13 +30,10 @@ chown -R $app:www-data "$install_dir"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1
ynh_script_progression --message="Reinstalling Ruby and NodeJS..." --weight=1
# Define and install dependencies
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#REMOVEME? ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# RESTORE THE NGINX CONFIGURATION
@ -87,11 +45,8 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
#REMOVEME? ynh_psql_test_if_first_run
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;"
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
@ -123,9 +78,6 @@ pushd "$install_dir/live"
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install --redownload -j$(getconf _NPROCESSORS_ONLN)
popd
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_package_autoremove
#=================================================
# RESTORE VARIOUS FILES
#=================================================

View file

@ -14,28 +14,9 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
ynh_script_progression --message="Loading settings..." --weight=1
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? language=$(ynh_app_setting_get --app=$app --key=language)
#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? redis_namespace=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user)
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
admin_mail=$(ynh_user_get_info --username=$admin --key='mail')
#REMOVEME? port_web=$(ynh_app_setting_get --app=$app --key=port_web)
#REMOVEME? port_stream=$(ynh_app_setting_get --app=$app --key=port_stream)
#REMOVEME? secret_key_base=$(ynh_app_setting_get --app=$app --key=secret_key_base)
#REMOVEME? otp_secret=$(ynh_app_setting_get --app=$app --key=otp_secret)
#REMOVEME? vapid_private_key=$(ynh_app_setting_get --app=$app --key=vapid_private_key)
#REMOVEME? vapid_public_key=$(ynh_app_setting_get --app=$app --key=vapid_public_key)
config="$install_dir/live/.env.production"
#=================================================
@ -45,20 +26,6 @@ ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
# Restore it if the upgrade fails
#REMOVEME? ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -75,45 +42,6 @@ ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=sy
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
#REMOVEME? if ynh_legacy_permissions_exists; then
#REMOVEME? ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# Create a permission if needed
#REMOVEME? if ! ynh_permission_exists --permission="api"; then
#REMOVEME? ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true"
fi
# If port_web doesn't exist, create it, needed for old install
if [[ -z "$port_web" ]]; then
port_web=3000
#REMOVEME? ynh_app_setting_set --app=$app --key=port_web --value=$port_web
fi
# If port_web doesn't exist, create it, needed for old install
if [[ -z "$port_stream" ]]; then
port_stream=4000
#REMOVEME? ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
fi
# If db_user doesn't exist, create it, needed for old install
if [[ -z "$db_user" ]]; then
db_user=$(ynh_sanitize_dbid --db_name=$app)
#REMOVEME? ynh_app_setting_set --app=$app --key=db_user --value=$db_user
fi
# If db_pwd doesn't exist, create it, needed for old install
if [[ -z "$db_pwd" ]]; then
db_pwd=$(ynh_string_random)
#REMOVEME? ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
#REMOVEME? 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="$config"
fi
# Remove paperclip_secret
ynh_app_setting_delete --app=$app --key=paperclip_secret
@ -152,14 +80,6 @@ fi
#Remove previous added repository
ynh_remove_extra_repo
#=================================================
# CREATE DEDICATED USER
#=================================================
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -176,7 +96,7 @@ then
mv --verbose --no-target-directory --backup=numbered "$install_dir/live/public/system" "$install_dir/system.tmp"
fi
rsync -a "$config" "$tmpdir/."
#REMOVEME? ynh_secure_remove --file="$install_dir/live"
ynh_secure_remove --file="$install_dir/live"
ynh_setup_source --dest_dir="$install_dir/live"
@ -185,9 +105,6 @@ then
fi
rsync -a "$tmpdir/.env.production" "$install_dir/live/."
ynh_secure_remove --file="$tmpdir"
# Clean files which are not needed anymore
#REMOVEME? ynh_secure_remove --file="$install_dir/live/config/initializers/timeout.rb"
fi
chmod 750 "$install_dir"
@ -197,12 +114,10 @@ chown -R $app:www-data "$install_dir"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_script_progression --message="Upgrading Ruby and NodeJS..." --weight=1
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#REMOVEME? ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# NGINX CONFIGURATION
@ -251,9 +166,6 @@ pushd "$install_dir/live"
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl cache clear
popd
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_package_autoremove
#=================================================
# UPDATE A CONFIG FILE
#=================================================
@ -303,13 +215,6 @@ ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd
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
#=================================================
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

26
tests.toml Normal file
View file

@ -0,0 +1,26 @@
test_format = 1.0
[default]
# ------------
# Tests to run
# ------------
exclude = ["install.multi", "install.subdir", "install.nourl", "change_url"]
# The test IDs to be used in only/exclude statements are: install.root, install.subdir, install.nourl, install.multi, backup_restore, upgrade, upgrade.someCommitId change_url
# -------------------------------
# Default args to use for install
# -------------------------------
# Nothing to do here...yet
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.94381183.name = "Upgrade from 4.02~ynh2"
test_upgrade_from.00a1a6e7.args.domain="domain.tld"
test_upgrade_from.00a1a6e7.args.is_public=1
test_upgrade_from.00a1a6e7.args.admin="john"
test_upgrade_from.00a1a6e7.args.language="fr_FR"