mirror of
https://github.com/YunoHost-Apps/duniter_ynh.git
synced 2024-09-03 18:26:35 +02:00
update
This commit is contained in:
parent
4781cfed11
commit
439659d1c8
8 changed files with 334 additions and 119 deletions
|
@ -1,26 +1,29 @@
|
|||
;; Test complet
|
||||
auto_remove=1
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/" (PATH)
|
||||
port="8999" (PORT)
|
||||
sync_node="duniter.org"
|
||||
sync_port="10900"
|
||||
admin="john" (USER)
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
admin="john"
|
||||
language="fr"
|
||||
is_public=1
|
||||
password="1Strong-Password"
|
||||
port="666"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=0
|
||||
setup_sub_dir=1
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=0
|
||||
setup_public=0
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
#upgrade=1 from_commit=CommitHash
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
wrong_user=1
|
||||
wrong_path=1
|
||||
incorrect_path=1
|
||||
corrupt_source=0
|
||||
fail_download_source=0
|
||||
port_already_use=1
|
||||
final_path_already_use=0
|
||||
multi_instance=1
|
||||
port_already_use=0
|
||||
change_url=1
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=CommitHash
|
||||
name=Name and date of the commit.
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
|
||||
|
|
7
conf/app.src
Normal file
7
conf/app.src
Normal file
|
@ -0,0 +1,7 @@
|
|||
SOURCE_URL=https://git.duniter.org/nodes/typescript/duniter/-/jobs/40430/artifacts/raw/work/bin/duniter-server-v1.8.1-linux-x64.deb
|
||||
SOURCE_SUM=d96f805e2465f76a51a4311f7b194c59bd00f658b27709cf679b710d11d1dac3
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=deb
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=duniter-server-v1.8.1-linux-x64.deb
|
||||
SOURCE_EXTRACT=false
|
|
@ -4,7 +4,7 @@ location / {
|
|||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
|
||||
proxy_pass http://localhost:YNH_EXAMPLE_PORT;
|
||||
proxy_pass http://localhost:__PORT__;
|
||||
proxy_redirect off;
|
||||
|
||||
# Socket.io support
|
||||
|
|
BIN
doc/screenshots/duniter_admin_g1.png
Normal file
BIN
doc/screenshots/duniter_admin_g1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 145 KiB |
|
@ -3,18 +3,26 @@
|
|||
"id": "duniter",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Duniter node which permits participate to blockchain writing. Monetary system with universal dividend, libre money, relative theory of the money. This package permit to join an existing money.",
|
||||
"fr": "Nœud Duniter qui permet de participer à l’écriture de blocs. Système monétaire à dividende universel, monnaie libre, thérorie relative de la monnaie. Ce paquet permet de rejoindre une monnaie déjà existante."
|
||||
"en": "Crypto-currency software to operate Ğ1 libre currency",
|
||||
"fr": "Nœud qui permet de participer à l’écriture de blocs."
|
||||
},
|
||||
"version": "1.8.1~ynh1",
|
||||
"url": "https://duniter.org",
|
||||
"license": "free",
|
||||
"license": "AGPLv3",
|
||||
"upstream": {
|
||||
"license": "AGPLv3",
|
||||
"website": "https://duniter.org",
|
||||
"demo": "https://demo.example.com",
|
||||
"admindoc": "https://yunohost.org/packaging_apps",
|
||||
"code": "https://git.duniter.org/nodes/typescript/duniter"
|
||||
},
|
||||
"maintainer": {
|
||||
"name": "Moul",
|
||||
"email": "moul@moul.re",
|
||||
"url": "https://moul.re"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">> 4.1.7"
|
||||
"yunohost": ">> 4.3.0"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
@ -24,21 +32,11 @@
|
|||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Dedicated domain name on which no application must be installed. Install will be done on root path.",
|
||||
"fr": "Nom de domaine dédié sur lequel aucune application ne doit être installée. L’installation sera faite à la racine."
|
||||
},
|
||||
"example": "duniter.domain.tld"
|
||||
"type": "domain"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"ask": {
|
||||
"en": "Administrator. Must a YunoHost user.",
|
||||
"fr": "Administrateur. Ce doit être un utilisateur YunoHost"
|
||||
},
|
||||
"example": "jon doe"
|
||||
"type": "user"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
149
scripts/install
149
scripts/install
|
@ -1,66 +1,125 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
# Retrieve arguments
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path="/"
|
||||
port=10901
|
||||
path_url="/"
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
|
||||
# Source app helpers and functions
|
||||
source /usr/share/yunohost/helpers
|
||||
source functions.sh
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Check domain/path availability
|
||||
yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| ynh_die "Path not available: ${domain}${path}"
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
|
||||
|
||||
# Check port availability
|
||||
yunohost app checkport $port
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
ynh_die "Port not available: ${port}"
|
||||
fi
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# 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..." --time --weight=1
|
||||
|
||||
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 AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Finding an available port..." --time --weight=1
|
||||
|
||||
# Find an available port
|
||||
port=$(ynh_find_port --port=10901)
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
ynh_script_progression --message="Configuring system user..." --time --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
# Get CPU architecture and check it
|
||||
arch=$(uname -m)
|
||||
if [ $arch == "x86_64" ]; then
|
||||
arch="x64"
|
||||
fi
|
||||
if [[ $arch != "x64" && $arch != "armv7l" ]]; then
|
||||
ynh_die "$arch is not supported." 2
|
||||
#=================================================
|
||||
# INSTALL DUNITER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building Duniter.. (this will take some time and resources!)" --weight=60
|
||||
|
||||
tempdir="$(mktemp -d)"
|
||||
|
||||
ynh_setup_source --dest_dir=$tempdir --source_id=app
|
||||
ynh_exec_warn_less dpkg -i $tempdir/duniter-server-v1.8.1-linux-x64.deb
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --time --weight=1
|
||||
|
||||
duniter config --bma --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 443 --noupnp
|
||||
duniter config --ws2p-host 127.0.0.1 --ws2p-port 20901 --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-remote-path "/ws2p" --ws2p-noupnp
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description="" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action=start --log_path=systemd
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||
|
||||
# Make app public if necessary or protect it
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
# Store config on YunoHost instance
|
||||
ynh_app_setting_set $app port $port
|
||||
ynh_app_setting_set $app arch $arch
|
||||
ynh_app_setting_set "$app" admin "$admin"
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
|
||||
|
||||
# Open port on firewall
|
||||
yunohost firewall allow TCP $port > /dev/null 2>&1
|
||||
|
||||
INSTALL_DUNITER_DEBIAN_PACKAGE
|
||||
INSTALL_SYSTEMD
|
||||
CONFIGURE_DUNITER
|
||||
|
||||
# Launch Duniter node
|
||||
systemctl start duniter
|
||||
|
||||
# Add Duniter service to the YunoHost monitoring
|
||||
yunohost service add $app --log $USER/.config/$app/"$app"_default/"$app".log
|
||||
|
||||
CONFIG_PERMISSIONS
|
||||
CONFIG_NGINX
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -1,34 +1,62 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Exit and treat unset variables as an error
|
||||
set -u
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Source app helpers
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
source functions.sh
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
|
||||
REMOVE_DUNITER
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
# Disable systemd service
|
||||
systemctl disable duniter.service
|
||||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
#=================================================
|
||||
|
||||
# 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..." --time --weight=1
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --time --weight=1
|
||||
|
||||
dpkg -r duniter
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --time --weight=1
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
# Remove data and conf
|
||||
rm -rf $USER/.conf/duniter
|
||||
|
||||
# Remove Duniter service to YunoHost monitoring
|
||||
yunohost service remove $app
|
||||
|
||||
# Remove Nginx configuration
|
||||
rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
systemctl reload nginx
|
||||
|
||||
# Close opened port
|
||||
yunohost firewall disallow TCP $port
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
160
scripts/upgrade
160
scripts/upgrade
|
@ -1,37 +1,157 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Source app helpers and functions
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
source functions.sh
|
||||
|
||||
# Retrive arguments
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
port=$(ynh_app_setting_get "$app" port)
|
||||
arch=$(ynh_app_setting_get "$app" arch)
|
||||
admin=$(ynh_app_setting_get "$app" admin)
|
||||
|
||||
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)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK 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)..." --time --weight=1
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# 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
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
||||
|
||||
#
|
||||
# N.B. : the followings setting migrations snippets are provided as *EXAMPLES*
|
||||
# of what you may want to do in some cases (e.g. a setting was not defined on
|
||||
# some legacy installs and you therefore want to initiaze stuff during upgrade)
|
||||
#
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
#if [ -z "$db_name" ]; then
|
||||
# db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
# ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
#fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
#if [ -z "$final_path" ]; then
|
||||
# final_path=/var/www/$app
|
||||
# ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
#fi
|
||||
|
||||
### If nobody installed your app before 4.1,
|
||||
### then you may safely remove these lines
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
if ! ynh_permission_exists --permission="admin"; then
|
||||
# Create the required permissions
|
||||
ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
|
||||
fi
|
||||
|
||||
# Create a permission if needed
|
||||
if ! ynh_permission_exists --permission="api"; then
|
||||
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
REMOVE_DUNITER
|
||||
INSTALL_DUNITER_DEBIAN_PACKAGE
|
||||
INSTALL_SYSTEMD
|
||||
CONFIGURE_DUNITER
|
||||
#=================================================
|
||||
# INSTALL DUNITER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building Duniter.. (this will take some time and resources!)" --weight=60
|
||||
|
||||
# Start duniter service
|
||||
systemctl start duniter
|
||||
dpkg -r duniter
|
||||
|
||||
CONFIG_PERMISSIONS
|
||||
CONFIG_NGINX
|
||||
tempdir="$(mktemp -d)"
|
||||
|
||||
ynh_setup_source --dest_dir=$tempdir --source_id=app
|
||||
ynh_exec_warn_less dpkg -i $tempdir/duniter-server-v1.8.1-linux-x64.deb
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --time --weight=1
|
||||
|
||||
duniter config --bma --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 443 --noupnp
|
||||
duniter config --ws2p-host 127.0.0.1 --ws2p-port 20901 --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-remote-path "/ws2p" --ws2p-noupnp
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1
|
||||
|
||||
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --time --last
|
||||
|
|
Loading…
Reference in a new issue