From ac91efc7558ee6dfec698846f73c73221ede63aa Mon Sep 17 00:00:00 2001 From: Moul Date: Mon, 2 May 2022 19:23:05 +0200 Subject: [PATCH] [fix] Create 'duniter' user with --home-dir as \$datadir as well with shell in order to be able to run duniter with systemd So, the configuration get saved in (/home/yunohost.app/duniter) $datadir with which the service will run with The consequence of this was at least a broken BMA access due to the absense of configuration Run Duniter with 'duniter' user to apply the configuration to get the config file with correct permissions, using "ynh_exec_as duniter", an equivalent of su - duniter -c "$cmd" --- scripts/install | 8 ++++---- scripts/restore | 6 +++--- scripts/upgrade | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/install b/scripts/install index 5c32d31..1782688 100644 --- a/scripts/install +++ b/scripts/install @@ -62,7 +62,8 @@ ynh_app_setting_set --app=$app --key=port --value=$port ynh_script_progression --message="Configuring system user…" # Create a system user -ynh_system_user_create --username=$app +datadir=/home/yunohost.app/$app +ynh_system_user_create --username=$app --home_dir=$datadir --use_shell #================================================= # NGINX CONFIGURATION @@ -89,7 +90,6 @@ ynh_exec_warn_less dpkg -i $tempdir/duniter-server-v1.8.*-linux-*.deb #================================================= ynh_script_progression --message="Creating a data directory…" -datadir=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=datadir --value=$datadir mkdir -p $datadir @@ -103,8 +103,8 @@ chown -R $app:www-data "$datadir" #================================================= ynh_script_progression --message="Adding a configuration file…" -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 +ynh_exec_as duniter duniter config --bma --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 443 --noupnp +ynh_exec_as duniter 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 diff --git a/scripts/restore b/scripts/restore index 60baff1..dc13cb5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -48,7 +48,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_script_progression --message="Recreating the dedicated system user…" # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir=$datadir --use_shell #================================================= # RESTORE THE DATA DIRECTORY @@ -80,8 +80,8 @@ ynh_exec_warn_less dpkg -i $tempdir/duniter-server-v1.8.*-linux-*.deb #================================================= ynh_script_progression --message="Adding a configuration file…" -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 +ynh_exec_as duniter duniter --home $datadir config --bma --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 443 --noupnp +ynh_exec_as duniter duniter --home $datadir config --ws2p-host 127.0.0.1 --ws2p-port 20901 --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-remote-path "/ws2p" --ws2p-noupnp #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index a0f9261..400d441 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -72,7 +72,8 @@ fi ynh_script_progression --message="Making sure dedicated system user exists…" # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app +datadir=/home/yunohost.app/$app +ynh_system_user_create --username=$app --home_dir=$datadir --use_shell #================================================= # NGINX CONFIGURATION @@ -112,8 +113,8 @@ fi #================================================= ynh_script_progression --message="Updating a configuration file…" -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 +ynh_exec_as duniter duniter config --bma --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 443 --noupnp +ynh_exec_as duniter 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