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)
## Requirements
- Debian Stretch
- YunoHost ≥ 3.0
- Debian Buster
- YunoHost ≥ v4.1
- `x64` or `armlv7` architecture
- 200Mo free RAM
- 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
- 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.
- **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 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"
},
"requirements": {
"yunohost": ">> 2.4.0"
"yunohost": ">> 4.1.7"
},
"multi_instance": false,
"services": [

View file

@ -1,12 +1,13 @@
#/bin/bash
INSTALL_DUNITER_DEBIAN_PACKAGE () {
version="v1.7.21"
url_base="https://git.duniter.org/nodes/typescript/duniter/"
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
mid_url="uploads/23e768a0c5afc515ae59b4bf536ceecb/"
version="v1.8.0"
mid_url="uploads/afe00e6e6cb318fbdbb977d8c73f4645/"
fi
deb="duniter-server-$version-linux-$arch.deb"
@ -19,24 +20,31 @@ INSTALL_DUNITER_DEBIAN_PACKAGE () {
rm -f $deb_path
}
CONFIGURE_DUNITER () {
duniter config --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 80 --noupnp
duniter config --addep "BMAS $domain 443"
duniter config --ws2p-host 127.0.0.1 --ws2p-port 20901 --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-noupnp
INSTALL_SYSTEMD () {
cp ../conf/duniter.service /etc/systemd/system/duniter.service
systemctl enable duniter.service
}
CONFIG_SSOWAT () {
# Add admin to the allowed users
yunohost app addaccess $app -u $admin
CONFIGURE_DUNITER () {
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
}
# Protect senstive sub-routes
ynh_app_setting_set "$app" protected_uris "/webui","/webmin"
CONFIG_PERMISSIONS () {
# 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
ynh_app_setting_set "$app" unprotected_uris "/","/modules"
# Protect senstive sub-routes to Duniter web admin interface, give access to choosen admin
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
ynh_app_setting_set "$app" redirected_urls "{'$domain/':'$domain/webui'}"
# Set BMA and WS2P APIs accessible to visitors
if ! ynh_permission_exists --permission="apis"; then
ynh_permission_create --permission="apis" --url="/" --allowed="visitors" --show_tile=false --protected=true
fi
}
CONFIG_NGINX () {
@ -44,15 +52,12 @@ CONFIG_NGINX () {
sed -i "s@YNH_EXAMPLE_PORT@$port@" $nginx_conf
sed -i "s@YNH_EXAMPLE_DOMAIN@$domain@" $nginx_conf
cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
service nginx reload
systemctl reload nginx
}
REMOVE_DUNITER () {
# Stop duniter daemon if running
duniter status
if [ `echo "$?"` == 0 ]; then
duniter stop
fi
# Stop duniter daemon
systemctl stop duniter
# Remove Duniter package
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
INSTALL_DUNITER_DEBIAN_PACKAGE
INSTALL_SYSTEMD
CONFIGURE_DUNITER
# Reset Duniter node's existing data (blockchain, not conf)
duniter reset data > /dev/null
# Launch Duniter node
duniter webstart
systemctl start duniter
# Add Duniter service to the YunoHost monitoring
yunohost service add $app --log /root/.config/$app/"$app"_default/"$app".log
CONFIG_SSOWAT
CONFIG_PERMISSIONS
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
# Disable systemd service
systemctl disable duniter.service
# Remove data and conf
rm -rf /root/.conf/duniter
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
service nginx reload
systemctl reload nginx
# Close opened 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
INSTALL_DUNITER_DEBIAN_PACKAGE
INSTALL_SYSTEMD
CONFIGURE_DUNITER
# Start duniter daemon
duniter webstart
# Start duniter service
systemctl start duniter
CONFIG_SSOWAT
CONFIG_PERMISSIONS
CONFIG_NGINX
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last