1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/syncserver-rs_ynh.git synced 2024-09-03 20:26:32 +02:00

Merge pull request #1 from orhtej2/testing

First releasable version.
This commit is contained in:
orhtej2 2023-10-14 23:26:23 +02:00 committed by GitHub
commit 4e2f2e4d78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 157 additions and 478 deletions

View file

@ -1,85 +1,43 @@
# Packaging an app, starting from this example
* Copy this app before working on it, using the ['Use this template'](https://github.com/YunoHost/example_ynh/generate) button on the Github repo.
* Edit the `manifest.toml` with app specific info.
* Edit the `install`, `upgrade`, `remove`, `backup` and `restore` scripts, and any relevant conf files in `conf/`.
* Using the [script helpers documentation.](https://yunohost.org/packaging_apps_helpers)
* Edit the `change_url` and `config` scripts too, or remove them if you have no use of them
* Add a `LICENSE` file for the package. NB: this LICENSE file is not meant to necessarily be the LICENSE of the upstream app - it is only the LICENSE you want this package's code to published with ;). We recommend to use [the AGPL-3](https://www.gnu.org/licenses/agpl-3.0.txt).
* Edit `doc/DISCLAIMER*.md`
* The `README.md` files are to be automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
---
<!-- <!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand. It shall NOT be edited by hand.
--> -->
# Example app for YunoHost # Firefox Sync Storage (new) for YunoHost
[![Integration level](https://dash.yunohost.org/integration/example.svg)](https://dash.yunohost.org/appci/app/example) ![Working status](https://ci-apps.yunohost.org/ci/badges/example.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/example.maintain.svg) [![Integration level](https://dash.yunohost.org/integration/syncstorage-rs.svg)](https://dash.yunohost.org/appci/app/syncstorage-rs) ![Working status](https://ci-apps.yunohost.org/ci/badges/syncstorage-rs.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/syncstorage-rs.maintain.svg)
[![Install Example app with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=example)
[![Install Firefox Sync Storage (new) with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=syncstorage-rs)
*[Lire ce readme en français.](./README_fr.md)* *[Lire ce readme en français.](./README_fr.md)*
> *This package allows you to install Example app quickly and simply on a YunoHost server. > *This package allows you to install Firefox Sync Storage (new) 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.* If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview ## Overview
Some long and extensive description of what the app is and does, lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Second-generation server for Firefox Sync written in Rust.
### Features
- Ut enim ad minim veniam, quis nostrud exercitation ullamco ;
- Laboris nisi ut aliquip ex ea commodo consequat ;
- Duis aute irure dolor in reprehenderit in voluptate ;
- Velit esse cillum dolore eu fugiat nulla pariatur ;
- Excepteur sint occaecat cupidatat non proident, sunt in culpa."
**Shipped version:** 1.0~ynh1 **Shipped version:** 0.13.7-20230926~ynh1
**Demo:** https://demo.example.com
## Screenshots
![Screenshot of Example app](./doc/screenshots/example.jpg)
## Disclaimers / important information
* Any known limitations, constrains or stuff not working, such as (but not limited to):
* requiring a full dedicated domain ?
* architectures not supported ?
* not-working single-sign on or LDAP integration ?
* the app requires an important amount of RAM / disk / .. to install or to work properly
* etc...
* Other infos that people should be aware of, such as:
* any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...)
* how to configure / administrate the application if it ain't obvious
* upgrade process / specificities / things to be aware of ?
* security considerations ?
## Documentation and resources ## Documentation and resources
* Official app website: <https://example.com> * Official app website: <https://www.mozilla.org/en-GB/firefox/features/sync/>
* Official user documentation: <https://yunohost.org/apps> * Official admin documentation: <https://github.com/mozilla-services/syncstorage-rs/blob/master/docs/config.md>
* Official admin documentation: <https://yunohost.org/packaging_apps> * Upstream app code repository: <https://github.com/mozilla-services/syncstorage-rs>
* Upstream app code repository: <https://some.forge.com/example/example> * YunoHost documentation for this app: <https://yunohost.org/app_syncstorage-rs>
* YunoHost documentation for this app: <https://yunohost.org/app_example> * Report a bug: <https://github.com/YunoHost-Apps/syncstorage-rs_ynh/issues>
* Report a bug: <https://github.com/YunoHost-Apps/example_ynh/issues>
## Developer info ## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/example_ynh/tree/testing). Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/syncstorage-rs_ynh/tree/testing).
To try the testing branch, please proceed like that. To try the testing branch, please proceed like that.
``` bash ``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/example_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/syncstorage-rs_ynh/tree/testing --debug
or or
sudo yunohost app upgrade example -u https://github.com/YunoHost-Apps/example_ynh/tree/testing --debug sudo yunohost app upgrade syncstorage-rs -u https://github.com/YunoHost-Apps/syncstorage-rs_ynh/tree/testing --debug
``` ```
**More info regarding app packaging:** <https://yunohost.org/packaging_apps> **More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -3,71 +3,41 @@ N.B.: This README was automatically generated by https://github.com/YunoHost/app
It shall NOT be edited by hand. It shall NOT be edited by hand.
--> -->
# Exemple d'app pour YunoHost # Firefox Sync Storage (new) pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/example.svg)](https://dash.yunohost.org/appci/app/example) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/example.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/example.maintain.svg) [![Niveau dintégration](https://dash.yunohost.org/integration/syncstorage-rs.svg)](https://dash.yunohost.org/appci/app/syncstorage-rs) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/syncstorage-rs.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/syncstorage-rs.maintain.svg)
[![Installer Example app avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=example)
[![Installer Firefox Sync Storage (new) avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=syncstorage-rs)
*[Read this readme in english.](./README.md)* *[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer Example app rapidement et simplement sur un serveur YunoHost. > *Ce package vous permet dinstaller Firefox Sync Storage (new) 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.* Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment linstaller et en profiter.*
## Vue d'ensemble ## Vue densemble
Some long and extensive description of what the app is and does, lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ceci est une fausse description des fonctionalités de l'app
### Features
- Ut enim ad minim veniam, quis nostrud exercitation ullamco ;
- Laboris nisi ut aliquip ex ea commodo consequat ;
- Duis aute irure dolor in reprehenderit in voluptate ;
- Velit esse cillum dolore eu fugiat nulla pariatur ;
- Excepteur sint occaecat cupidatat non proident, sunt in culpa."
**Version incluse :** 1.0~ynh1 **Version incluse :** 0.13.7-20230926~ynh1
**Démo :** https://demo.example.com
## Captures d'écran
![Capture d'écran de Example app](./doc/screenshots/example.jpg)
## Avertissements / informations importantes
* Any known limitations, constrains or stuff not working, such as (but not limited to):
* requiring a full dedicated domain ?
* architectures not supported ?
* not-working single-sign on or LDAP integration ?
* the app requires an important amount of RAM / disk / .. to install or to work properly
* etc...
* Other infos that people should be aware of, such as:
* any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...)
* how to configure / administrate the application if it ain't obvious
* upgrade process / specificities / things to be aware of ?
* security considerations ?
## Documentations et ressources ## Documentations et ressources
* Site officiel de l'app : <https://example.com> * Site officiel de lapp : <https://www.mozilla.org/en-GB/firefox/features/sync/>
* Documentation officielle utilisateur : <https://yunohost.org/apps> * Documentation officielle de ladmin : <https://github.com/mozilla-services/syncstorage-rs/blob/master/docs/config.md>
* Documentation officielle de l'admin : <https://yunohost.org/packaging_apps> * Dépôt de code officiel de lapp : <https://github.com/mozilla-services/syncstorage-rs>
* Dépôt de code officiel de l'app : <https://some.forge.com/example/example> * Documentation YunoHost pour cette app : <https://yunohost.org/app_syncstorage-rs>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_example> * Signaler un bug : <https://github.com/YunoHost-Apps/syncstorage-rs_ynh/issues>
* Signaler un bug : <https://github.com/YunoHost-Apps/example_ynh/issues>
## Informations pour les développeurs ## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/example_ynh/tree/testing). Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/syncstorage-rs_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit. Pour essayer la branche testing, procédez comme suit.
``` bash ``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/example_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/syncstorage-rs_ynh/tree/testing --debug
ou ou
sudo yunohost app upgrade example -u https://github.com/YunoHost-Apps/example_ynh/tree/testing --debug sudo yunohost app upgrade syncstorage-rs -u https://github.com/YunoHost-Apps/syncstorage-rs_ynh/tree/testing --debug
``` ```
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps> **Plus dinfos sur le packaging dapplications :** <https://yunohost.org/packaging_apps>

30
conf/config.toml Normal file
View file

@ -0,0 +1,30 @@
master_secret = "__MASTER_SECRET__"
# removing this line will default to moz_json formatted logs (which is preferred for production envs)
human_logs = 1
port = __PORT__
# Example Syncstorage settings:
# Example MySQL DSN:
syncstorage.database_url = "mysql://__DB_USER__:__DB_PWD__@localhost/__DB_NAME__"
# Example Spanner DSN:
# database_url="spanner://projects/SAMPLE_GCP_PROJECT/instances/SAMPLE_SPANNER_INSTANCE/databases/SAMPLE_SPANNER_DB"
# enable quota limits
syncstorage.enable_quota = 0
# set the quota limit to 2GB.
# max_quota_limit = 200000000
syncstorage.enabled = true
syncstorage.limits.max_total_records = 1666 # See issues #298/#333
# Example Tokenserver settings:
tokenserver.database_url = "mysql://__DB_USER__:__DB_PWD__@localhost/__DB_NAME_TOKENSERVER__"
tokenserver.enabled = true
tokenserver.node_type = "mysql"
tokenserver.fxa_metrics_hash_secret = "__SECRET__"
tokenserver.fxa_email_domain = "api.accounts.firefox.com"
tokenserver.fxa_oauth_server_url = "https://oauth.accounts.firefox.com"
tokenserver.fxa_browserid_audience = "https://token.services.mozilla.com"
tokenserver.fxa_browserid_issuer = "https://api.accounts.firefox.com"
tokenserver.fxa_browserid_server_url = "https://verifier.accounts.firefox.com/v2"

View file

@ -1,28 +1,23 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
# Path to source # Path to source
alias __INSTALL_DIR__/; alias __INSTALL_DIR__/ ;
### Example PHP configuration (remove it if not used) include uwsgi_params;
index index.php; # Needed for long running operations in admin interface
proxy_pass http://127.0.0.1:__PORT__/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Common parameter to increase upload size limit in conjunction with dedicated php-fpm file proxy_buffering off;
#client_max_body_size 50M; client_max_body_size 200M;
proxy_set_header X-Real-IP $remote_addr;
try_files $uri $uri/ index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
### End of PHP configuration part
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
} }

View file

@ -1,6 +0,0 @@
HOST=0.0.0.0
PORT=__PORT__
MASTER_SECRET=__SECRET__
[syncstorage]
DATABASE_URL=mysql://__DB_USER__:__DB_PWD__@localhost/__DB_NAME__

View file

@ -1,15 +1,20 @@
[Unit] [Unit]
Description=Small description of the service Description=Firefox Sync Storage server
After=network.target After=network.target
After=mariadb.service
[Service] [Service]
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__INSTALL_DIR__/ WorkingDirectory=__INSTALL_DIR__
ExecStart=__INSTALL_DIR__/script ExecStart=__INSTALL_DIR__/bin/syncserver --config ./config.toml
StandardOutput=append:/var/log/__APP__/__APP__.log StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit StandardError=inherit
Environment=PATH="__INSTALL_DIR__/venv/bin:$(PATH)"
Environment=PYTHONPATH=$(PYTHON_SITE_PACKGES)
Environment=RUST_LOG=error
Environment=RUST_BACKTRACE=full
# Sandboxing options to harden security # Sandboxing options to harden security
# Depending on specificities of your service/app, you may need to tweak these # Depending on specificities of your service/app, you may need to tweak these
@ -47,3 +52,4 @@ CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

View file

@ -1,3 +0,0 @@
This is a dummy admin doc for this app
The app install dir is `__INSTALL_DIR__`

View file

@ -1,3 +0,0 @@
Ceci est une fausse doc d'admin pour cette app
Le dossier d'install de l'app est `__INSTALL_DIR__`

View file

@ -1 +1 @@
This is a dummy description of this app features Second-generation server for Firefox Sync written in Rust.

View file

@ -1,7 +1 @@
This is a dummy disclaimer to display after the install Please open `about:config` in your Firefox and point `identity.sync.tokenserver.uri` to `__DOMAIN____PATH__`.
The app url is `__DOMAIN____PATH__`
The app install dir is `__INSTALL_DIR__`
The app id is `__ID__`

View file

@ -1 +0,0 @@
This is a dummy disclaimer to display after upgrades

View file

@ -1 +0,0 @@
This is a dummy disclaimer to display prior to the install

View file

@ -1 +0,0 @@
Ceci est un faux disclaimer à présenter avant l'installation

View file

@ -1 +0,0 @@
This is a dummy disclaimer to display prior to any upgrade

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

View file

@ -1,13 +1,12 @@
packaging_format = 2 packaging_format = 2
id = "syncstorage-rs" id = "syncstorage-rs"
name = "Firefox Sync Storage-rs" name = "Firefox Sync Storage (new)"
[description] description.en = "New Firefox Sync Storage implemented in Rust. Allows syncing tabs, passwords, history etc. between Firefox instances."
en = "New Firefox Sync Storage implemented in Rust. Allows syncing tabs, passwords, history etc. between Firefox instances." description.fr = "New Firefox Sync Storage implemented in Rust."
fr = "New Firefox Sync Storage implemented in Rust."
version = "0.13.6~ynh1" version = "0.13.7-20230926~ynh1"
maintainers = [""] maintainers = [""]
@ -20,8 +19,7 @@ fund = "https://donate.mozilla.org/en-GB/"
[integration] [integration]
yunohost = ">= 11.1.21" yunohost = ">= 11.1.21"
# List of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386'] architectures = "all"
architectures = "[&#39;all&#39;]" # TODO : handle the "all" option (no ["all"])
multi_instance = true multi_instance = true
# FIXME: replace with an **estimate** minimum disk and RAM requirements. e.g. 20M, 400M, 1G... You may have have a look at CI results # FIXME: replace with an **estimate** minimum disk and RAM requirements. e.g. 20M, 400M, 1G... You may have have a look at CI results
@ -54,9 +52,9 @@ ram.runtime = "50M"
# This will pre-fetch the asset which can then be deployed during the install/upgrade scripts with : # This will pre-fetch the asset which can then be deployed during the install/upgrade scripts with :
# ynh_setup_source --dest_dir="$install_dir" # ynh_setup_source --dest_dir="$install_dir"
# You can also define other assets than "main" and add --source_id="foobar" in the previous command # You can also define other assets than "main" and add --source_id="foobar" in the previous command
url = "https://github.com/mozilla-services/syncstorage-rs/archive/refs/tags/0.13.6.tar.gz" url = "https://github.com/mozilla-services/syncstorage-rs/archive/acc5524cf361d6abf3aedb73bb54ef3db1b6fda3.tar.gz"
sha256 = "ddf8169a0a9bd06db10bf032a2b9af7ea4e5816251e82d9e7627f87eba1f27bd" sha256 = "52cbd6aa890deee4079463c0f45bb2985891f78114ecbbfacb5387fdc0b806f5"
autoupdate.strategy = "latest_github_tag" autoupdate.strategy = "latest_github_commit"
# This will provision/deprovision a unix system user # This will provision/deprovision a unix system user
[resources.system_user] [resources.system_user]
@ -69,12 +67,13 @@ ram.runtime = "50M"
# The initial allowed group of user is configured via the init_main_permission question (public=visitors, private=all_users) # The initial allowed group of user is configured via the init_main_permission question (public=visitors, private=all_users)
[resources.permissions] [resources.permissions]
main.url = "/" main.url = "/"
main.show_tile = false
# This will pick a random port for reverse-proxying and store it as the $port setting # This will pick a random port for reverse-proxying and store it as the $port setting
[resources.ports] [resources.ports]
[resources.apt] [resources.apt]
packages = "mariadb-server default-libmysqlclient-dev cmake python3-dev python3-pip python3-setuptools python3-wheel build-essential libssl-dev libffi-dev libcurl4" packages = "mariadb-server default-libmysqlclient-dev cmake python3-dev python3-pip python3-setuptools python3-wheel build-essential libssl-dev libffi-dev libcurl4 pkg-config"
# This will automatically provision/deprovison a database and store the corresponding credentials in settings $db_user, $db_name, $db_pwd # This will automatically provision/deprovison a database and store the corresponding credentials in settings $db_user, $db_name, $db_pwd
[resources.database] [resources.database]

View file

@ -9,21 +9,21 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_install_go
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
salt=$(ynh_string_random --length=40) secret=$(ynh_string_random --length=40)
master_secret=$(ynh_string_random --length=40)
db_name_tokenserver="${db_name}_tokenserver"
ynh_app_setting_set --app=$app --key=db_name_tokenserver --value=$db_name_tokenserver
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=10 ynh_script_progression --message="Installing dependencies..." --weight=10
ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION
export GOPATH="$install_dir/build/go"
export GOCACHE="$install_dir/build/.cache"
ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y' ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y'
export PATH="$install_dir/.cargo/bin:$PATH" export PATH="$install_dir/.cargo/bin:$PATH"
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH cargo install diesel_cli --no-default-features --features 'mysql'
#================================================= #=================================================
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC) # APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
@ -43,33 +43,50 @@ ynh_setup_source --dest_dir="$install_dir/build"
# ownership to all files such as after the ynh_setup_source step # ownership to all files such as after the ynh_setup_source step
chown -R $app:www-data "$install_dir" chown -R $app:www-data "$install_dir"
#=================================================
# PROVISION SECOND DB
#=================================================
ynh_script_progression --message="Configuring second MySQL database..."
ynh_mysql_create_db "$db_name_tokenserver" "$db_user" "$db_pwd"
#================================================= #=================================================
# BUILD # BUILD
#================================================= #=================================================
ynh_script_progression --message="Building the sources (it will take some time)..." --weight=10 ynh_script_progression --message="Building the sources (it will take some time)..." --weight=10
ynh_exec_as $app virtualenv --python=python3 --system-site-packages "${install_dir}/venv" ynh_exec_as $app python -m venv "${install_dir}/venv"
( (
set +o nounset set +o nounset
source "${install_dir}/venv/bin/activate" source "${install_dir}/venv/bin/activate"
set -o nounset set -o nounset
ynh_use_go ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH $install_dir/venv/bin/pip install --upgrade pip
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH $install_dir/venv/bin/pip install --upgrade setuptools
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade pip
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade setuptools
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH GOPATH=$GOPATH GOCACHE=$GOCACHE CGO_ENABLED=1 pip install -r requirements.txt
pushd $install_dir/build pushd $install_dir/build
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH GOPATH=$GOPATH GOCACHE=$GOCACHE CGO_ENABLED=1 cargo install --path ../syncserver --locked --root /app ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH $install_dir/venv/bin/pip install -r requirements.txt
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH GOPATH=$GOPATH GOCACHE=$GOCACHE CGO_ENABLED=1 cargo install --path ../syncserver --locked --root /app --bin purge_ttl ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH $install_dir/venv/bin/pip install -r tools/tokenserver/requirements.txt
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH cargo install --path ./syncserver --locked --root $install_dir --no-default-features --features=syncstorage-db/mysql
ynh_script_progression --message="Seeding the databases..."
# syncstorage db
diesel --database-url "mysql://$db_user:${db_pwd}@localhost/$db_name" migration --migration-dir syncstorage-mysql/migrations run
# tokenserver db
diesel --database-url "mysql://$db_user:${db_pwd}@localhost/$db_name_tokenserver" migration --migration-dir tokenserver-db/migrations run
ynh_mysql_execute_as_root --sql="INSERT INTO services (id, service, pattern) VALUES (1, 'sync-1.5', '{node}/1.5/{uid}')" --database="$db_name_tokenserver";
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH SYNC_TOKENSERVER__DATABASE_URL="mysql://$db_user:${db_pwd}@localhost/$db_name_tokenserver" $install_dir/venv/bin/python tools/tokenserver/add_node.py "https://$domain$path_url" 10
popd popd
) )
#ynh_secure_remove --file="$install_dir/.cargo" ynh_secure_remove --file="$install_dir/.cargo"
#ynh_secure_remove --file="$install_dir/.rustup" ynh_secure_remove --file="$install_dir/.rustup"
#ynh_secure_remove --file="$install_dir/.cache" ynh_secure_remove --file="$install_dir/.cache"
#ynh_secure_remove --file="$install_dir/.local" ynh_secure_remove --file="$install_dir/.local"
#ynh_secure_remove --file="$install_dir/build" ynh_secure_remove --file="$install_dir/build"
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
@ -81,14 +98,17 @@ ynh_add_nginx_config
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
mkdir /var/log/$app
touch /var/log/$app/$app.log
chown -R $app: /var/log/$app
yunohost service add $app --description="Firefox Sync Server (Rust)" --log="/var/log/$app/$app.log" yunohost service add $app --description="Firefox Sync Server (Rust)" --log="/var/log/$app/$app.log"
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_use_logrotate
# Create a dedicated Fail2Ban config # Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="" #ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex=""
#================================================= #=================================================
# APP INITIAL CONFIGURATION # APP INITIAL CONFIGURATION
#================================================= #=================================================
@ -96,29 +116,13 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failreg
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="sync.ini" --destination="$install_dir/sync.ini" ynh_add_config --template="config.toml" --destination="$install_dir/config.toml"
# FIXME: this should be handled by the core in the future # FIXME: this should be handled by the core in the future
# You may need to use chmod 600 instead of 400, # You may need to use chmod 600 instead of 400,
# for example if the app is expected to be able to modify its own config # for example if the app is expected to be able to modify its own config
chmod 400 "$install_dir/sync.ini" chmod 400 "$install_dir/config.toml"
chown $app:$app "$install_dir/sync.ini" chown $app:$app "$install_dir/config.toml"
### For more complex cases where you want to replace stuff using regexes,
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
### When doing so, you also need to manually call ynh_store_file_checksum
###
### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file"
### ynh_store_file_checksum --file="$install_dir/some_config_file"
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
#### TODO in Yunohost App Generator
# Installation with curl
ynh_script_progression --message="Finalizing installation..." --weight=1
ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -127,7 +131,6 @@ ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================

View file

@ -1,8 +1,5 @@
#!/bin/bash #!/bin/bash
#### App file generated with YoloGen, the Yunohost app generator, version 0.6.5.
# This is the tutorial version of the app.
# It contains extra commands to explain what should be done in case you want to adjust some part of the script.
# Once you are done, you may remove them.
#================================================= #=================================================
# GENERIC START # GENERIC START
#================================================= #=================================================
@ -11,18 +8,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Settings are automatically loaded as bash variables
# in every app script context, therefore typically these will exist:
# - $domain
# - $path
# - $language
# - $install_dir
# - $port
# ...
# For remove operations :
# - the core will deprovision every resource defined in the manifest **after** this script is ran
# this includes removing the install directory, and data directory (if --purge was used)
#================================================= #=================================================
# REMOVE SYSTEM CONFIGURATIONS # REMOVE SYSTEM CONFIGURATIONS
#================================================= #=================================================
@ -42,15 +27,17 @@ ynh_remove_systemd_config
ynh_remove_nginx_config ynh_remove_nginx_config
ynh_remove_logrotate ynh_remove_logrotate
ynh_remove_fail2ban_config
# Remove other various files specific to the app... such as :
ynh_secure_remove --file="/etc/cron.d/$app"
ynh_secure_remove --file="/etc/$app"
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#=================================================
# DROP TOKENSERVER DB
#=================================================
ynh_script_progression --message="Deprovisioning TokenServer DB..."
db_name_tokenserver=$(ynh_app_setting_get --app=$app --key=db_name_tokenserver)
ynh_mysql_drop_db "$db_name_tokenserver"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -1,247 +0,0 @@
#!/bin/bash
ynh_go_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
}
goenv_install_dir="/opt/goenv"
go_version_path="$goenv_install_dir/versions"
# goenv_ROOT is the directory of goenv, it needs to be loaded as a environment variable.
export GOENV_ROOT="$goenv_install_dir"
# Load the version of Go for an app, and set variables.
#
# ynh_use_go has to be used in any app scripts before using Go for the first time.
# This helper will provide alias and variables to use in your scripts.
#
# To use gem or Go, use the alias `ynh_gem` and `ynh_go`
# 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_go`
# And propagate $PATH to sudo with $ynh_go_load_path
# Exemple: `ynh_exec_as $app $ynh_go_load_path $ynh_gem install`
#
# $PATH contains the path of the requested version of Go.
# However, $PATH is duplicated into $go_path to outlast any manipulation of $PATH
# You can use the variable `$ynh_go_load_path` to quickly load your Go version
# in $PATH for an usage into a separate script.
# Exemple: $ynh_go_load_path $install_dir/script_that_use_gem.sh`
#
#
# Finally, to start a Go service with the correct version, 2 solutions
# Either the app is dependent of Go or gem, but does not called it directly.
# In such situation, you need to load PATH
# `Environment="__YNH_GO_LOAD_PATH__"`
# `ExecStart=__FINALPATH__/my_app`
# You will replace __YNH_GO_LOAD_PATH__ with $ynh_go_load_path
#
# Or Go start the app directly, then you don't need to load the PATH variable
# `ExecStart=__YNH_GO__ my_app run`
# You will replace __YNH_GO__ with $ynh_go
#
#
# one other variable is also available
# - $go_path: The absolute path to Go binaries for the chosen version.
#
# usage: ynh_use_go
#
# Requires YunoHost version 3.2.2 or higher.
ynh_use_go () {
go_version=$(ynh_app_setting_get --app=$app --key=go_version)
# Get the absolute path of this version of Go
go_path="$go_version_path/$go_version/bin"
# Allow alias to be used into bash script
shopt -s expand_aliases
# Create an alias for the specific version of Go and a variable as fallback
ynh_go="$go_path/go"
alias ynh_go="$ynh_go"
# Load the path of this version of Go in $PATH
if [[ :$PATH: != *":$go_path"* ]]; then
PATH="$go_path:$PATH"
fi
# Create an alias to easily load the PATH
ynh_go_load_path="PATH=$PATH"
# Sets the local application-specific Go version
pushd $install_dir
$goenv_install_dir/bin/goenv local $go_version
popd
}
# Install a specific version of Go
#
# ynh_install_go will install the version of Go provided as argument by using goenv.
#
# This helper creates a /etc/profile.d/goenv.sh that configures PATH environment for goenv
# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin)
#
# Don't forget to execute go-dependent command in a login environment
# (e.g. sudo --login option)
# When not possible (e.g. in systemd service definition), please use direct path
# to goenv shims (e.g. $goenv_ROOT/shims/bundle)
#
# usage: ynh_install_go --go_version=go_version
# | arg: -v, --go_version= - Version of go to install.
#
# Requires YunoHost version 3.2.2 or higher.
ynh_install_go () {
# Declare an array to define the options of this helper.
local legacy_args=v
local -A args_array=( [v]=go_version= )
local go_version
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# Load goenv path in PATH
local CLEAR_PATH="$goenv_install_dir/bin:$PATH"
# Remove /usr/local/bin in PATH in case of Go prior installation
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
# Move an existing Go binary, to avoid to block goenv
test -x /usr/bin/go && mv /usr/bin/go /usr/bin/go_goenv
# Install or update goenv
goenv="$(command -v goenv $goenv_install_dir/bin/goenv | head -1)"
if [ -n "$goenv" ]; then
ynh_print_info --message="goenv already seems installed in \`$goenv'."
pushd "${goenv%/*/*}"
if git remote -v 2>/dev/null | grep "https://github.com/syndbg/goenv.git"; then
echo "Trying to update with git..."
git pull -q --tags origin master
cd ..
ynh_go_try_bash_extension
fi
popd
else
ynh_print_info --message="Installing goenv with git..."
mkdir -p $goenv_install_dir
pushd $goenv_install_dir
git init -q
git remote add -f -t master origin https://github.com/syndbg/goenv.git > /dev/null 2>&1
git checkout -q -b master origin/master
ynh_go_try_bash_extension
goenv=$goenv_install_dir/bin/goenv
popd
fi
goenv_latest="$(command -v "$goenv_install_dir"/plugins/*/bin/goenv-latest goenv-latest | head -1)"
if [ -n "$goenv_latest" ]; then
ynh_print_info --message="\`goenv latest' command already available in \`$goenv_latest'."
pushd "${goenv_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 "${goenv_install_dir}/plugins"
git clone -q https://github.com/momo-lab/xxenv-latest.git "${goenv_install_dir}/plugins/xxenv-latest"
fi
# Enable caching
mkdir -p "${goenv_install_dir}/cache"
# Create shims directory if needed
mkdir -p "${goenv_install_dir}/shims"
# Restore /usr/local/bin in PATH
PATH=$CLEAR_PATH
# And replace the old Go binary
test -x /usr/bin/go_goenv && mv /usr/bin/go_goenv /usr/bin/go
# Install the requested version of Go
local final_go_version=$(goenv latest --print $go_version)
ynh_print_info --message="Installation of Go-$final_go_version"
goenv install --skip-existing $final_go_version
# Store go_version into the config of this app
ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=go_version --value=$final_go_version
# Cleanup Go versions
ynh_cleanup_go
# Set environment for Go users
echo "#goenv
export GOENV_ROOT=$goenv_install_dir
export PATH=\"$goenv_install_dir/bin:$PATH\"
eval \"\$(goenv init -)\"
#goenv" > /etc/profile.d/goenv.sh
# Load the environment
eval "$(goenv init -)"
}
# Remove the version of Go used by the app.
#
# This helper will also cleanup Go versions
#
# usage: ynh_remove_go
ynh_remove_go () {
local go_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=go_version)
# Load goenv path in PATH
local CLEAR_PATH="$goenv_install_dir/bin:$PATH"
# Remove /usr/local/bin in PATH in case of Go prior installation
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
# Remove the line for this app
ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=go_version
# Cleanup Go versions
ynh_cleanup_go
}
# Remove no more needed versions of Go used by the app.
#
# This helper will check what Go version are no more required,
# and uninstall them
# If no app uses Go, goenv will be also removed.
#
# usage: ynh_cleanup_go
ynh_cleanup_go () {
# List required Go versions
local installed_apps=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
local required_go_versions=""
for installed_app in $installed_apps
do
local installed_app_go_version=$(ynh_app_setting_get --app=$installed_app --key="go_version")
if [[ $installed_app_go_version ]]
then
required_go_versions="${installed_app_go_version}\n${required_go_versions}"
fi
done
# Remove no more needed Go versions
local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/')
for installed_go_version in $installed_go_versions
do
if ! `echo ${required_go_versions} | grep "${installed_go_version}" 1>/dev/null 2>&1`
then
ynh_print_info --message="Removing of Go-$installed_go_version"
$goenv_install_dir/bin/goenv uninstall --force $installed_go_version
fi
done
# If none Go version is required
if [[ ! $required_go_versions ]]
then
# Remove goenv environment configuration
ynh_print_info --message="Removing of goenv"
ynh_secure_remove --file="$goenv_install_dir"
ynh_secure_remove --file="/etc/profile.d/goenv.sh"
fi
}