App packaging problem: configuration templating

please sorry for my English

My YunoHost server

Hardware: New computer
YunoHost version: 11.2.27
I have access to my server : Through SSH & through the webadmin
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no
If yes, please explain:

Description of my issue

I’m trying to package the Codeberg Pages Server, which uses environment variables as configuration. systemd service includes the EnvironmentFile entry:

[Service]
[other entries]
EnvironmentFile=__INSTALL_DIR__/.env
[other entries]

There is also part of install script and the .env file:

# install
#=================================================
# APP INITIAL CONFIGURATION
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding configuration files..." --weight=1

ynh_add_config --template=".env" --destination="$install_dir/.env" # -- problem is here!
# .env
[some variables]

# Forge Settings
GITEA_API_TOKEN=__FORGEJO_TOKEN__
GITEA_ROOT=__FORGEJO_URL__

[some variables]

The full repository is available here: Ynh-Pkgs/forgejo-pages-server_ynh: It is a YunoHost package for Codeberg Pages Server - Исходные коды Набу

Problem is in line marked above as problematic, more specifically in sed. That helper calls sed and it in its turn outputs the following line:

sed: -e expression #1, char 58: unterminated s’ command`

There is the full installation log: https://paste.yunohost.org/raw/ocitexoquz


I think ynh_add_config is unable to paste in e-mails as it uses @ as a delimiter internally :person_shrugging:

Can you try for the sake of testing replace @ with \@ is some phony_email var and try using it as a replacement?

No, it changes nothing. I think that problem is in newlines. I tried running failed command (sed) on my PC and it returned needed variables, but they were separated by newlines, so maybe it is the problem:

~/ynh/forgejo-pages-server_ynh$ grep -oP '__[A-Z0-9]+?[A-Z0-9_]*?[A-Z0-9]*?__' conf/.env | sort --unique | sed 's@__\([^.]*\)__@\L\1@g'
acme_email
acme_use
dns_credentials
dns_provider
domain
domain_raw
forgejo_token
forgejo_url

Here is also erroneous code fragment from helper:

# helpers.v2.1.d/templating
ynh_config_add() {
    [some code]
        _ynh_replace_vars "$destination"
    [some code]
}

_ynh_replace_vars() {
    [some code]
    # List unique (__ __) variables in $file
    local uniques_vars=($(grep -oP '__[A-Z0-9]+?[A-Z0-9_]*?[A-Z0-9]*?__' $file | sort --unique | sed "s@__\([^.]*\)__@\L\1@g")) # -- problem is in sed command
    [some code]
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.