# App packaging problem: configuration templating

**URL:** <https://forum.yunohost.org/t/app-packaging-problem-configuration-templating/30700>\
**Category:** Apps packaging\
**Tags:** package, english\
**Created:** [August 6, 2024, 9:48am UTC](https://forum.yunohost.org/t/app-packaging-problem-configuration-templating/30700 "2024-08-06T09:48:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lotigara](https://forum.yunohost.org/user_avatar/forum.yunohost.org/lotigara/32/10371_2.png) [@lotigara](https://forum.yunohost.org/u/lotigara)\
**Post date:** [August 6, 2024, 9:48am UTC](https://forum.yunohost.org/t/app-packaging-problem-configuration-templating/30700/1 "2024-08-06T09:48:48Z")

</div>

`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](https://codeberg.org/Codeberg/pages-server/), which uses environment variables as configuration. systemd service includes the `EnvironmentFile` entry:

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

```

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

```sh
# 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!

```

```sh
# .env
[some variables]

# Forge Settings
GITEA_API_TOKEN= __FORGEJO_TOKEN__
GITEA_ROOT= __FORGEJO_URL__

[some variables]

```

The full repository is available here: [https://lotigara.ru/src/Ynh-Pkgs/forgejo-pages-server\_ynh](https://lotigara.ru/src/Ynh-Pkgs/forgejo-pages-server_ynh)

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](https://paste.yunohost.org/raw/ocitexoquz)

* * *

---

<div class="post-metadata">

**Author:** ![orhtej2](https://forum.yunohost.org/user_avatar/forum.yunohost.org/orhtej2/32/8943_2.png) [@orhtej2](https://forum.yunohost.org/u/orhtej2)\
**Post date:** [August 6, 2024, 10:23am UTC](https://forum.yunohost.org/t/app-packaging-problem-configuration-templating/30700/2 "2024-08-06T10:23:31Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![lotigara](https://forum.yunohost.org/user_avatar/forum.yunohost.org/lotigara/32/10371_2.png) [@lotigara](https://forum.yunohost.org/u/lotigara)\
**Post date:** [August 6, 2024, 10:42am UTC](https://forum.yunohost.org/t/app-packaging-problem-configuration-templating/30700/3 "2024-08-06T10:42:54Z")

</div>

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:

```plaintext
~/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:

```sh
# 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]
}

```

---

<div class="post-metadata">

**Author:** ![system](https://forum.yunohost.org/uploads/default/original/2X/f/f59fe8e3ee6b100b4f574d30d6e30479c68b89f0.png) [@system](https://forum.yunohost.org/u/system)\
**Post date:** [September 5, 2024, 10:43am UTC](https://forum.yunohost.org/t/app-packaging-problem-configuration-templating/30700/4 "2024-09-05T10:43:30Z")

</div>

Closed on September 5, 2024, 10:43am UTC

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