1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/duniter_ynh.git synced 2024-09-03 18:26:35 +02:00

Packaging v2

This commit is contained in:
Salamandar 2024-02-21 14:59:14 +01:00
parent d0ec6502f2
commit ec6f832827
17 changed files with 162 additions and 554 deletions

View file

@ -1,20 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
admin="john"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=0
setup_public=0
upgrade=1
upgrade=1 from_commit=70eaf1b90afe598445690e30debe3f39e1082c72
backup_restore=1
multi_instance=0
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://git.duniter.org/nodes/typescript/duniter/-/jobs/110607/artifacts/raw/work/bin/duniter-server-v1.8.7-linux-x64.deb
SOURCE_SUM=a3b3f44b09a76f40d93f761872f9d798ee68bea8cc2eb73fe63c9cc6ad8b6519
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=deb
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=duniter-server-v1.8.7-linux-x64.deb
SOURCE_EXTRACT=false

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://git.duniter.org/nodes/typescript/duniter/uploads/8773273a64956cb02de555ec72e4d2bd/duniter-server-v1.8.5-linux-armv7l.deb
SOURCE_SUM=498e3a7766e167887de2d71dd43ffa6c1add11f976bf00e2a44ccc3cec5d5da0
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=deb
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=duniter-server-v1.8.5-linux-armv7l.deb
SOURCE_EXTRACT=false

View file

@ -4,7 +4,7 @@ After=network.target
[Service]
Environment="DUNITER_WEB=web"
Environment="DUNITER_HOME=__DATADIR__"
Environment="DUNITER_HOME=__DATA_DIR__"
Environment="DUNITER_DATA=duniter_default"
Environment="DUNITER_OPTS="
Group=duniter

View file

@ -1,8 +1,11 @@
## First synchronization
The first synchronization can be very time consuming, it can be considered to do it from the command line via ssh rather than via the graphical WEB interface. In order to let the synchronization be done without keeping the terminal window open connected in ssh, it is recommended to use `tmux` or `screen`. `screen -S duniter` in order to open a new "screen". In this screen called "duniter":
The first synchronization can be very time consuming, it can be considered to do it from the command line via ssh rather than via the web interface.
In order to let the synchronization be done without keeping the terminal window open connected in ssh, it is recommended to use `tmux` or `screen`:
```
* `screen -S duniter` in order to open a new "screen". In this screen called "duniter":
```bash
sudo systemctl stop duniter
sudo su - duniter -c "duniter --home \$HOME sync g1.duniter.org" && sudo systemctl start duniter
```
@ -10,7 +13,8 @@ sudo su - duniter -c "duniter --home \$HOME sync g1.duniter.org" && sudo systemc
During the synchronization, you can press CTRL+SHIFT+a+d to exit without closing the "duniter" screen, you can then leave the ssh connection.
To come back to your "duniter" screen to see if the sync is finished, you have to run the command `screen -d duniter`
## Configurations
## Configuration
- In order to compute blocks you will have to set your member credentials with `sudo su - duniter -c "duniter --home \$HOME wizard key"` or from the webadmin.
- BMA, the client API is accessible from `https://duniter.domain.tld/bma/` if enabled . The last `/` is necessary to the proper functioning. This URL can be use in Cesium and Silkaj.
- The web administration interface is accessible via `https://duniter.domain.tld/` and is only accessible to the administrator specified at the installation.
@ -19,5 +23,5 @@ In case you applied this correction, you can manually reset the configuration wi
`sudo su - duniter -c "duniter --home \$HOME config --bma --ipv4 127.0.0.1 --port CHOSEN_PORT --remoteh YOUR_DOMAIN --remotep 443 --noupnp"`
## Cesium
Cesium is a wallet webapp. You can install it with:
- [YunoHost app](https://github.com/YunoHost-Apps/cesium_ynh)
Cesium is a wallet webapp. You can install it with [its YunoHost app](https://github.com/YunoHost-Apps/cesium_ynh).

View file

@ -1,16 +1,20 @@
## Première synchronisation
La première synchronisation pouvant demander beaucoup de temps, il peut être envisagé de la faire en ligne de commande par ssh plutôt que par l'interface graphique WEB. Afin de pouvoir laisser la synchronisation se faire sans garder la fenêtre du terminal ouverte connecté en ssh, il est recommandé d'utiliser `tmux` ou `screen`.
`screen -S duniter` afin d'ouvrir un nouvel "écran".
Dans cet écran appelé "duniter" :
```
La première synchronisation pouvant demander beaucoup de temps, il peut être envisagé de la faire en ligne de commande par ssh plutôt que par l'interface web.
Afin de pouvoir laisser la synchronisation se faire sans garder la fenêtre du terminal ouverte connecté en ssh, il est recommandé d'utiliser `tmux` ou `screen`:
* `screen -S duniter` afin d'ouvrir un nouvel "écran" ; Dans cet écran appelez "duniter" :
```bash
sudo systemctl stop duniter
sudo su - duniter -c "duniter --home \$HOME sync g1.duniter.org" && sudo systemctl start duniter
```
Pendant la synchronisation, vous pouvez faire CTRL+SHIFT+a+d afin de quitter sans fermer l'écran "duniter", vous pouvez alors quitter la connexion ssh.
Pour revenir à votre écran "duniter" pour voir si la synchro est terminée, vous devez lancer la commande
`screen -d duniter`
## Configurations
Pendant la synchronisation, vous pouvez faire `CTRL+SHIFT+a,d` afin de quitter sans fermer l'écran "duniter", vous pouvez alors quitter la connexion ssh.
Pour revenir à votre écran "duniter" pour voir si la synchro est terminée, vous devez lancer la commande `screen -d duniter`.
## Configuration
- Afin de calculer des blocs, il faut configurer ses identifiants membre avec `sudo su - duniter -c "duniter --home \$HOME wizard key"` ou via linterface dadministration web.
- BMA, lAPI client est accessible via `https://duniter.domain.tld/bma/` si activé. Le dernier `/` est nécessaire à son fonctionnement. Cette URL peut être utilisée dans Cesium et Silkaj.
- Linterface dadministration web est accessible à ladresse `https://duniter.domain.tld/` et est uniquement accessible à ladministrateur spécifié lors de linstallation.
@ -19,5 +23,5 @@ Dans le cas où vous auriez appliqué cette correction, vous pouvez manuellement
`sudo su - duniter -c "duniter --home \$HOME config --bma --ipv4 127.0.0.1 --port CHOSEN_PORT --remoteh YOUR_DOMAIN --remotep 443 --noupnp"`
## Cesium
Cesium est une application portefeuilles web. Vous pouvez linstaller :
- [avec lapplication YunoHost](https://github.com/YunoHost-Apps/cesium_ynh)
Cesium est une application portefeuilles web. Vous pouvez linstaller [avec lapplication YunoHost](https://github.com/YunoHost-Apps/cesium_ynh).

View file

@ -0,0 +1 @@
Crypto-currency software to operate the Ğ1 libre currency.

View file

@ -1,41 +0,0 @@
{
"name": "Duniter",
"id": "duniter",
"packaging_format": 1,
"description": {
"en": "Crypto-currency software to operate Ğ1 libre currency",
"fr": "Logiciel de cryptomonnaie pour faire fonctionner la monnaie libre Ğ1"
},
"version": "1.8.7~ynh0",
"url": "https://duniter.org",
"license": "AGPL-3.0-or-later",
"upstream": {
"license": "AGPL-3.0-or-later",
"website": "https://duniter.org",
"code": "https://git.duniter.org/nodes/typescript/duniter"
},
"maintainer": {
"name": "Moul",
"email": "moul@moul.re",
"url": "https://moul.re"
},
"requirements": {
"yunohost": ">= 11.0.0"
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain"
},
{
"name": "admin",
"type": "user"
}
]
}
}

60
manifest.toml Normal file
View file

@ -0,0 +1,60 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "duniter"
name = "Duniter"
description.en = "Crypto-currency software to operate Ğ1 libre currency"
description.fr = "Logiciel de cryptomonnaie pour faire fonctionner la monnaie libre Ğ1"
version = "1.8.7~ynh0"
maintainers = ["Moul"]
[upstream]
license = "AGPL-3.0-or-later"
website = "https://duniter.org"
code = "https://git.duniter.org/nodes/typescript/duniter"
[integration]
yunohost = ">= 11.0.0"
architectures = ["amd64", "armhf"]
multi_instance = false
ldap = "not_relevant"
sso = "not_relevant"
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, ...
[install]
[install.domain]
type = "domain"
[install.admin]
type = "user"
[resources]
[resources.sources.main]
amd64.url = "https://git.duniter.org/nodes/typescript/duniter/-/jobs/110607/artifacts/raw/work/bin/duniter-server-v1.8.7-linux-x64.deb"
amd64.sha256 = "a3b3f44b09a76f40d93f761872f9d798ee68bea8cc2eb73fe63c9cc6ad8b6519"
armhf.url = "https://git.duniter.org/nodes/typescript/duniter/uploads/8773273a64956cb02de555ec72e4d2bd/duniter-server-v1.8.5-linux-armv7l.deb"
armhf.sha256 = "498e3a7766e167887de2d71dd43ffa6c1add11f976bf00e2a44ccc3cec5d5da0"
format = "whatever"
rename = "duniter-server.deb"
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
[resources.permissions]
main.url = "/"
admin.allowed = "admins"
admin.additional_urls = ["/webmin"]
[resources.ports]
local_bma.default = 10901
local_ws2p.default = 20901
web_admin.default = 9220

View file

@ -4,18 +4,22 @@
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="deb1 deb2 php$YNH_DEFAULT_PHP_VERSION-deb1 php$YNH_DEFAULT_PHP_VERSION-deb2"
#=================================================
# PERSONAL HELPERS
#=================================================
CONFIGURE_DUNITER() {
ynh_exec_as duniter duniter --home $datadir config --bma --ipv4 127.0.0.1 --port $bma_local_port --remoteh $domain --remotep 443 --noupnp
ynh_exec_as duniter duniter --home $datadir config --ws2p-host 127.0.0.1 --ws2p-port $ws2p_local_port --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-remote-path "/ws2p" --ws2p-noupnp
ynh_exec_as "duniter" duniter --home "$data_dir" config \
--bma --ipv4 127.0.0.1 --port $bma_local_port --remoteh $domain --remotep 443 --noupnp
ynh_exec_as "duniter" duniter --home "$data_dir" config \
--ws2p-host 127.0.0.1 --ws2p-port $ws2p_local_port \
--ws2p-remote-host "$domain" --ws2p-remote-port 443 \
--ws2p-remote-path "/ws2p" --ws2p-noupnp
# Add BMAS with path, remove auto-generated BMAS endpoint
ynh_exec_as duniter duniter --home $datadir config --addep "BMAS $domain 443 /bma" --remep "BMAS $domain 443"
ynh_exec_as "duniter" duniter --home "$data_dir" config \
--addep "BMAS $domain 443 /bma" --remep "BMAS $domain 443"
}
#=================================================

View file

@ -10,26 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings…"
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -39,20 +19,14 @@ ynh_print_info --message="Declaring files to be backed up…"
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$datadir" --is_big
ynh_backup --src_path="$data_dir" --is_big
#=================================================
# BACKUP THE NGINX CONFIGURATION
# SYSTEM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================

View file

@ -9,65 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path="/"
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings…"
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#db_user=$db_name
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)…"
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# 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 WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
@ -82,35 +23,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration…"
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# …
#=================================================
ynh_change_url_nginx_config
#=================================================
# GENERIC FINALISATION
@ -120,14 +33,7 @@ fi
ynh_script_progression --message="Starting a systemd service…"
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server…"
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd
#=================================================
# END OF SCRIPT

View file

@ -9,76 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
admin=$YNH_APP_ARG_ADMIN
app=$YNH_APP_INSTANCE_NAME
architecture=$YNH_ARCH
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters…"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
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
#=================================================
# FIND AVAILABLE PORTS
#=================================================
ynh_script_progression --message="Finding available ports…"
# Find available ports
local_bma_port=$(ynh_find_port --port=10901)
ynh_app_setting_set --app=$app --key=local_bma_port --value=$local_bma_port
local_ws2p_port=$(ynh_find_port --port=20901)
ynh_app_setting_set --app=$app --key=local_ws2p_port --value=$local_ws2p_port
web_admin_port=$(ynh_find_port --port=9220)
ynh_app_setting_set --app=$app --key=web_admin_port --value=$web_admin_port
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user…"
# Create a system user
datadir=/home/yunohost.app/$app
ynh_system_user_create --username=$app --home_dir=$datadir --use_shell
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server…"
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
@ -86,23 +16,17 @@ ynh_add_nginx_config
#=================================================
ynh_script_progression --message="Installation of Debian package of Duniter…"
tempdir="$(mktemp -d)"
ynh_setup_source --dest_dir=$tempdir --source_id=$architecture
ynh_exec_warn_less dpkg -i $tempdir/duniter-server-v1.8.*-linux-*.deb
ynh_setup_source --dest_dir="$install_dir" --source_id=$architecture
ynh_exec_warn_less dpkg -i "$install_dir/duniter-server.deb"
ynh_secure_remove "$install_dir/duniter-server.deb"
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory…"
ynh_script_progression --message="Configuring a data directory…"
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
chmod -R o-rwx "$data_dir"
chown -R $app:www-data "$data_dir"
#=================================================
# CONFIGURE DUNITER
@ -112,19 +36,16 @@ ynh_script_progression --message="Configure Duniter…"
CONFIGURE_DUNITER
#=================================================
# SETUP SYSTEMD
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring a systemd service…"
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost…"
yunohost service add $app
yunohost service add "$app"
#=================================================
# START SYSTEMD SERVICE
@ -132,26 +53,7 @@ yunohost service add $app
ynh_script_progression --message="Starting a systemd service…"
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions…"
# Change main group to protect sensitive sub-routes (client, API) to Duniter web admin interface, give access to choosen admin
ynh_permission_update --permission "main" --add "$admin" --remove "all_users"
ynh_permission_url --permission "main" --add_url "/webmin"
# Create apis permission group to public to allow BMA and WS2P APIs accessible to visitors
ynh_permission_create --permission "apis" --url "/bma" --additional_urls "/ws2p" --auth_header=false --allowed "visitors"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server…"
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd
#=================================================
# END OF SCRIPT

View file

@ -10,72 +10,28 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings…"
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration…"
yunohost service remove $app
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
yunohost service remove "$app"
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service…"
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory…"
ynh_secure_remove --file="$datadir"
fi
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration…"
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies…"
ynh_script_progression --message="Removing Duniter package…"
dpkg -r duniter
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user…"
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -10,60 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
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)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
local_bma_port=$(ynh_app_setting_get --app=$app --key=local_bma_port)
local_ws2p_port=$(ynh_app_setting_get --app=$app --key=local_ws2p_port)
architecture=$YNH_ARCH
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
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=$datadir --use_shell
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory…"
ynh_restore_file --origin_path="$datadir" --not_mandatory
mkdir -p $datadir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#=================================================
# SPECIFIC RESTORATION
#=================================================
@ -71,10 +17,9 @@ chown -R $app:www-data "$datadir"
#=================================================
ynh_script_progression --message="Installation of Debian package of Duniter…"
tempdir="$(mktemp -d)"
ynh_setup_source --dest_dir=$tempdir --source_id=$architecture
ynh_exec_warn_less dpkg -i $tempdir/duniter-server-v1.8.*-linux-*.deb
ynh_setup_source --dest_dir="$install_dir" --source_id=$architecture
ynh_exec_warn_less dpkg -i "$install_dir/duniter-server.deb"
ynh_secure_remove "$install_dir/duniter-server.deb"
#=================================================
# CONFIGURE DUNITER
@ -84,33 +29,33 @@ ynh_script_progression --message="Configure Duniter…"
CONFIGURE_DUNITER
#=================================================
# RESTORE SYSTEMD
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the systemd configuration…"
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$data_dir" --not_mandatory
chown -R "$app:www-data" "$data_dir"
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost…"
yunohost service add $app
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service…"
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd
systemctl enable "$app.service" --quiet
yunohost service add "$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression --message="Reloading NGINX web server…"
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd"
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -9,44 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
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)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
local_bma_port=$(ynh_app_setting_get --app=$app --key=local_bma_port)
local_ws2p_port=$(ynh_app_setting_get --app=$app --key=local_ws2p_port)
webadmin_port=$(ynh_app_setting_get --app=$app --key=webadmin_port)
architecture=$YNH_ARCH
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version…"
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
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
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -61,30 +23,12 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
#=================================================
ynh_script_progression --message="Ensuring downward compatibility…"
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
if [ -z "$(ls -A "$data_dir")" ]; then
mv "/root/.config/duniter"/{,.}* "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R "$app:www-data" "$data_dir"
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists…"
# Create a dedicated user (if not existing)
datadir=/home/yunohost.app/$app
ynh_system_user_create --username=$app --home_dir=$datadir --use_shell
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration…"
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
@ -92,23 +36,9 @@ ynh_add_nginx_config
#=================================================
ynh_script_progression --message="Installation of Debian package of Duniter…"
dpkg -r duniter
tempdir="$(mktemp -d)"
ynh_setup_source --dest_dir=$tempdir --source_id=$architecture
ynh_exec_warn_less dpkg -i $tempdir/duniter-server-v1.8.*-linux-*.deb
#=================================================
# MOVE DUNITER DIRECTORY
#=================================================
if [[ ! -d "${datadir}" ]]; then
ynh_script_progression --message="Moving data directory…"
mv /root/.config/duniter $datadir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
fi
ynh_setup_source --dest_dir="$install_dir" --source_id=$architecture
ynh_exec_warn_less dpkg -i "$install_dir/duniter-server.deb"
ynh_secure_remove "$install_dir/duniter-server.deb"
#=================================================
# UPDATE DUNITER CONFIG FILE
@ -118,33 +48,23 @@ ynh_script_progression --message="Configure Duniter…"
CONFIGURE_DUNITER
#=================================================
# SETUP SYSTEMD
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading systemd configuration…"
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost…"
yunohost service add $app
yunohost service add "$app"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service…"
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server…"
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd
#=================================================
# END OF SCRIPT

7
tests.toml Normal file
View file

@ -0,0 +1,7 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1
[default]
test_upgrade_from.70eaf1b90afe598445690e30debe3f39e1082c72.name = "1.8.5~ynh1"