I’ve been trying to add a config panel for my app InvoiceNinja5 without success. But everytime I get the error “Config panel question ‘default_from_email’ should be initialized with a value during install or upgrade.” in the frontend.
What I did:
- Created the config-panel:
version = "1.0"
[main]
[main.config]
name = "Configuration"
[main.config.default_from_email]
ask = "from email"
type = "email"
help = "Default email address to use for various automated emails."
bind = "default_from_email:__INSTALL_DIR__/.env"
[main.config.default_from_name]
ask = "from name"
type = "name"
help = "Default name address to use for various automated names."
bind = "default_from_name:__INSTALL_DIR__/.env"
- Added the same variables as installation questions:
[install.default_from_email]
help.en = "Choose what name will be displayed when InvoiceNinja sends mails."
help.fr = ""
type = "email"
default = ""
[install.default_from_name]
help.en = "Choose from which mail-address mails will be send."
help.fr = ""
type = "string"
default = ""
- Set and use the variables in the installation:
ynh_app_setting_set --app="$app" --key=default_from_email --value="$default_from_email"
ynh_app_setting_set --app="$app" --key=default_from_name --value="$default_from_name"
- And if there not set, set them during an upgrade:
default_from_email=$(ynh_app_setting_get --app="$app" --key=default_from_email)
if [ -z "$default_from_email" ]; then
default_from_email="${app}@${domain}"
ynh_app_setting_set --app="$app" --key=default_from_email --value="$default_from_email"
fi
default_from_name=$(ynh_app_setting_get --app="$app" --key=default_from_name)
if [ -z "$default_from_name" ]; then
default_from_name="${app}@${domain}"
ynh_app_setting_set --app="$app" --key=default_from_name --value="$default_from_name"
fi
The installation (and app itself) works:
sudo yunohost app install ./ -a "domain=foo.example.com&path=/&admin=basti&password=password&language=en" -f
Who should have access to this app? (This can later be changed) [all_users | visitors | admins | talos]: visitors
default_from_email: foo@bar.com
default_from_name: foo bar
Info: Installing invoiceninja5...
Info: Provisioning sources...
Info: Provisioning system_user...
Info: Provisioning install_dir...
Info: Provisioning permissions...
Info: Provisioning apt...
Info: Provisioning database...
Info: [++..................] > Storing secrets to app settings...
Info: [##+++...............] > Setting up source files...
Info: [#####+++............] > Adding system configurations related to invoiceninja5__2...
Info: [########+++.........] > Modifying a config file...
Info: [###########+++......] > Building the application...
Info: [##############+++...] > Adding a cron job...
Info: [#################+++] > Installation of invoiceninja5__2 completed
Success! Installation completed
The settings are also in the settings.yml:
sudo grep "default_from" /etc/yunohost/apps/invoiceninja5__2/settings.yml
default_from_email: foo@bar.com
default_from_name: foo bar
But not the config panel. What am I doing wrong?
The code can be found here: GitHub - YunoHost-Apps/invoiceninja5_ynh at support_mail