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

Merge branch 'testing' into patch-4

This commit is contained in:
Éric Gaspar 2021-11-25 19:05:39 +01:00 committed by GitHub
commit 040231e1eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 78 additions and 36 deletions

View file

@ -3,8 +3,8 @@
- [YunoHost project](https://yunohost.org) - [YunoHost project](https://yunohost.org)
## Requirements ## Requirements
- Debian Stretch - Debian Buster
- YunoHost ≥ 3.0 - YunoHost ≥ v4.1
- `x64` or `armlv7` architecture - `x64` or `armlv7` architecture
- 200Mo free RAM - 200Mo free RAM
- A dedicated domain name to install the app on root path. For instance, `duniter.domain.tld`. - A dedicated domain name to install the app on root path. For instance, `duniter.domain.tld`.
@ -22,6 +22,9 @@ Be carefull when installing applications from the community list.
## Configurations ## Configurations
- In order to compute blocks you will have to set your member credentials with `duniter wizard key` or from the webadmin. - In order to compute blocks you will have to set your member credentials with `duniter wizard key` or from the webadmin.
- The BMA API is accessible from `https://duniter.domain.tld/` if enabled. - The BMA API is accessible from `https://duniter.domain.tld/` if enabled.
- **Warning**: In case the Webui tells you your network configuration is wrong and proposes to correct it, do not apply it, otherwise it breaks the specific configuration made for this package.
You can manually reset the configuration with following command:
`duniter config --bma --ipv4 127.0.0.1 --port CHOSEN_PORT --remoteh YOUR_DOMAIN --remotep 443 --noupnp`
## Cesium ## Cesium
Cesium is a wallet webapp. You can install it with: Cesium is a wallet webapp. You can install it with:

16
conf/duniter.service Normal file
View file

@ -0,0 +1,16 @@
[Unit]
Description=Duniter node
After=network.target
[Service]
Environment="DUNITER_WEB=web"
Group=root
User=root
Type=forking
ExecStart=/usr/bin/duniter ${DUNITER_WEB}start
ExecReload=/usr/bin/duniter ${DUNITER_WEB}restart
ExecStop=/usr/bin/duniter stop
Restart=on-failure
[Install]
WantedBy=multi-user.target

View file

@ -14,7 +14,7 @@
"url": "https://moul.re" "url": "https://moul.re"
}, },
"requirements": { "requirements": {
"yunohost": ">> 2.4.0" "yunohost": ">> 4.1.7"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [

View file

@ -1,12 +1,13 @@
#/bin/bash #/bin/bash
INSTALL_DUNITER_DEBIAN_PACKAGE () { INSTALL_DUNITER_DEBIAN_PACKAGE () {
version="v1.7.21"
url_base="https://git.duniter.org/nodes/typescript/duniter/" url_base="https://git.duniter.org/nodes/typescript/duniter/"
if [ $arch == "x64" ]; then if [ $arch == "x64" ]; then
mid_url="-/jobs/34995/artifacts/raw/work/bin/" version="v1.8.1"
mid_url="-/jobs/40430/artifacts/raw/work/bin/"
else else
mid_url="uploads/23e768a0c5afc515ae59b4bf536ceecb/" version="v1.8.0"
mid_url="uploads/afe00e6e6cb318fbdbb977d8c73f4645/"
fi fi
deb="duniter-server-$version-linux-$arch.deb" deb="duniter-server-$version-linux-$arch.deb"
@ -19,24 +20,31 @@ INSTALL_DUNITER_DEBIAN_PACKAGE () {
rm -f $deb_path rm -f $deb_path
} }
CONFIGURE_DUNITER () { INSTALL_SYSTEMD () {
duniter config --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 80 --noupnp cp ../conf/duniter.service /etc/systemd/system/duniter.service
duniter config --addep "BMAS $domain 443" systemctl enable duniter.service
duniter config --ws2p-host 127.0.0.1 --ws2p-port 20901 --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-noupnp
} }
CONFIG_SSOWAT () { CONFIGURE_DUNITER () {
# Add admin to the allowed users duniter config --bma --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 443 --noupnp
yunohost app addaccess $app -u $admin 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
}
# Protect senstive sub-routes CONFIG_PERMISSIONS () {
ynh_app_setting_set "$app" protected_uris "/webui","/webmin" # Remove deprecated permission system settings to remove their effects
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
fi
# Duniter is public app, with only some parts restricted in nginx.conf # Protect senstive sub-routes to Duniter web admin interface, give access to choosen admin
ynh_app_setting_set "$app" unprotected_uris "/","/modules" if ! ynh_permission_exists --permission="admin"; then
ynh_permission_create --permission "admin" --url "/webui" --additional_urls "/webmin" --allowed "$admin" --label "Administration" --show_tile=true
fi
# Set URL redirection from root to webadmin # Set BMA and WS2P APIs accessible to visitors
ynh_app_setting_set "$app" redirected_urls "{'$domain/':'$domain/webui'}" if ! ynh_permission_exists --permission="apis"; then
ynh_permission_create --permission="apis" --url="/" --allowed="visitors" --show_tile=false --protected=true
fi
} }
CONFIG_NGINX () { CONFIG_NGINX () {
@ -44,15 +52,12 @@ CONFIG_NGINX () {
sed -i "s@YNH_EXAMPLE_PORT@$port@" $nginx_conf sed -i "s@YNH_EXAMPLE_PORT@$port@" $nginx_conf
sed -i "s@YNH_EXAMPLE_DOMAIN@$domain@" $nginx_conf sed -i "s@YNH_EXAMPLE_DOMAIN@$domain@" $nginx_conf
cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
service nginx reload systemctl reload nginx
} }
REMOVE_DUNITER () { REMOVE_DUNITER () {
# Stop duniter daemon if running # Stop duniter daemon
duniter status systemctl stop duniter
if [ `echo "$?"` == 0 ]; then
duniter stop
fi
# Remove Duniter package # Remove Duniter package
dpkg -r duniter dpkg -r duniter

View file

@ -45,16 +45,19 @@ ynh_app_setting_set "$app" admin "$admin"
yunohost firewall allow TCP $port > /dev/null 2>&1 yunohost firewall allow TCP $port > /dev/null 2>&1
INSTALL_DUNITER_DEBIAN_PACKAGE INSTALL_DUNITER_DEBIAN_PACKAGE
INSTALL_SYSTEMD
CONFIGURE_DUNITER CONFIGURE_DUNITER
# Reset Duniter node's existing data (blockchain, not conf)
duniter reset data > /dev/null
# Launch Duniter node # Launch Duniter node
duniter webstart systemctl start duniter
# Add Duniter service to the YunoHost monitoring # Add Duniter service to the YunoHost monitoring
yunohost service add $app --log /root/.config/$app/"$app"_default/"$app".log yunohost service add $app --log /root/.config/$app/"$app"_default/"$app".log
CONFIG_SSOWAT CONFIG_PERMISSIONS
CONFIG_NGINX CONFIG_NGINX
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -13,15 +13,24 @@ port=$(ynh_app_setting_get $app port)
REMOVE_DUNITER REMOVE_DUNITER
# Disable systemd service
systemctl disable duniter.service
# Remove data and conf # Remove data and conf
rm -rf /root/.conf/duniter rm -rf $USER/.conf/duniter
# Remove Duniter service to YunoHost monitoring # Remove Duniter service to YunoHost monitoring
yunohost service remove $app yunohost service remove $app
# Remove Nginx configuration # Remove Nginx configuration
rm -f /etc/nginx/conf.d/$domain.d/$app.conf rm -f /etc/nginx/conf.d/$domain.d/$app.conf
service nginx reload systemctl reload nginx
# Close opened port # Close opened port
yunohost firewall disallow TCP $port yunohost firewall disallow TCP $port
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -22,10 +22,16 @@ ynh_system_user_create --username=$app
REMOVE_DUNITER REMOVE_DUNITER
INSTALL_DUNITER_DEBIAN_PACKAGE INSTALL_DUNITER_DEBIAN_PACKAGE
INSTALL_SYSTEMD
CONFIGURE_DUNITER CONFIGURE_DUNITER
# Start duniter daemon # Start duniter service
duniter webstart systemctl start duniter
CONFIG_SSOWAT CONFIG_PERMISSIONS
CONFIG_NGINX CONFIG_NGINX
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last