171 KiB
App helpers
Doc auto-generated by this script on 02/02/2021 (Yunohost version 4.1.7)
apt
ynh_package_is_installed
Check either a package is installed or not
<strong>Usage</strong>: <code class="helper-code">ynh_package_is_installed --package=name</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-p</code>, <code>--package=</code> : the package name to check</li>
</ul>
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_package_is_installed --package=yunohost && echo "ok"</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/apt#L56">Dude, show me the code !</a>
</p>
ynh_package_version
Get the version of an installed package
<strong>Usage</strong>: <code class="helper-code">ynh_package_version --package=name</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-p</code>, <code>--package=</code> : the package name to get version</li>
</ul>
</p>
<p>
<strong>Returns</strong>: the version or an empty string
</p>
<p>
<strong>Example</strong>: <code class="helper-code">version=$(ynh_package_version --package=yunohost)</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/apt#L78">Dude, show me the code !</a>
</p>
ynh_package_update
Update package index files
<strong>Usage</strong>: <code class="helper-code">ynh_package_update</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/apt#L111">Dude, show me the code !</a>
</p>
ynh_package_install
Install package(s)
<strong>Usage</strong>: <code class="helper-code">ynh_package_install name [name [...]]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>name</code> : the package name to install</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/apt#L121">Dude, show me the code !</a>
</p>
ynh_package_remove
Remove package(s)
<strong>Usage</strong>: <code class="helper-code">ynh_package_remove name [name [...]]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>name</code> : the package name to remove</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/apt#L132">Dude, show me the code !</a>
</p>
ynh_package_autoremove
Remove package(s) and their uneeded dependencies
<strong>Usage</strong>: <code class="helper-code">ynh_package_autoremove name [name [...]]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>name</code> : the package name to remove</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/apt#L142">Dude, show me the code !</a>
</p>
ynh_package_autopurge
Purge package(s) and their uneeded dependencies
<strong>Usage</strong>: <code class="helper-code">ynh_package_autopurge name [name [...]]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>name</code> : the package name to autoremove and purge</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.7.2 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/apt#L152">Dude, show me the code !</a>
</p>
ynh_install_app_dependencies
Define and install dependencies with a equivs control file
<strong>Usage</strong>: <code class="helper-code">ynh_install_app_dependencies dep [dep [...]]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>dep</code> : the package name to install in dependence. Writing "dep3|dep4|dep5" can be used to specify alternatives. For example : dep1 dep2 "dep3|dep4|dep5" will require to install dep1 and dep 2 and (dep3 or dep4 or dep5).</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
This helper can/should only be called once per app</br></br>example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5"</br></br>Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/apt#L222">Dude, show me the code !</a>
</p>
ynh_add_app_dependencies
Add dependencies to install with ynh_install_app_dependencies
<strong>Usage</strong>: <code class="helper-code">ynh_add_app_dependencies --package=phpversion [--replace]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-p</code>, <code>--package=</code> : Packages to add as dependencies for the app.</li>
<li><code>-r</code>, <code>--replace</code> : Replace dependencies instead of adding to existing ones.</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.8.1 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/apt#L295">Dude, show me the code !</a>
</p>
ynh_remove_app_dependencies
Remove fake package and its dependencies
<strong>Usage</strong>: <code class="helper-code">ynh_remove_app_dependencies</code>
</p>
<p>
<strong>Details</strong>:
<p>
Dependencies will removed only if no other package need them.</br></br>Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/apt#L327">Dude, show me the code !</a>
</p>
ynh_install_extra_app_dependencies
Install packages from an extra repository properly.
<strong>Usage</strong>: <code class="helper-code">ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-r</code>, <code>--repo=</code> : Complete url of the extra repository.</li>
<li><code>-p</code>, <code>--package=</code> : The packages to install from this extra repository</li>
<li><code>-k</code>, <code>--key=</code> : url to get the public key.</li>
<li><code>-n</code>, <code>--name=</code> : Name for the files for this repo, $app as default value.</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.8.1 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/apt#L341">Dude, show me the code !</a>
</p>
backup
ynh_backup
Add a file or a directory to the list of paths to backup
<strong>Usage</strong>: <code class="helper-code">ynh_backup --src_path=src_path [--dest_path=dest_path] [--is_big] [--not_mandatory]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-s</code>, <code>--src_path=</code> : file or directory to bind or symlink or copy. it shouldn't be in the backup dir.</li>
<li><code>-d</code>, <code>--dest_path=</code> : destination file or directory inside the backup dir</li>
<li><code>-b</code>, <code>--is_big</code> : Indicate data are big (mail, video, image ...)</li>
<li><code>-m</code>, <code>--not_mandatory</code> : Indicate that if the file is missing, the backup can ignore it.</li>
<li><code>arg</code> : Deprecated arg</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
This helper can be used both in a system backup hook, and in an app backup script</br></br>Details: ynh_backup writes SRC and the relative DEST into a CSV file. And it</br>creates the parent destination directory</br></br>If DEST is ended by a slash it complete this path with the basename of SRC.</br></br>Example in the context of a wordpress app</br></br>ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"</br># => This line will be added into CSV file</br># "/etc/nginx/conf.d/$domain.d/$app.conf","apps/wordpress/etc/nginx/conf.d/$domain.d/$app.conf"</br></br>ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf"</br># => "/etc/nginx/conf.d/$domain.d/$app.conf","apps/wordpress/conf/nginx.conf"</br></br>ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/"</br># => "/etc/nginx/conf.d/$domain.d/$app.conf","apps/wordpress/conf/$app.conf"</br></br>ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf"</br># => "/etc/nginx/conf.d/$domain.d/$app.conf","apps/wordpress/conf"</br></br>#Deprecated usages (maintained for retro-compatibility)</br>ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "${backup_dir}/conf/nginx.conf"</br># => "/etc/nginx/conf.d/$domain.d/$app.conf","apps/wordpress/conf/nginx.conf"</br></br>ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "/conf/"</br># => "/etc/nginx/conf.d/$domain.d/$app.conf","apps/wordpress/conf/$app.conf"</br></br>How to use --is_big:</br>--is_big is used to specify that this part of the backup can be quite huge.</br>So, you don't want that your package does backup that part during ynh_backup_before_upgrade.</br>In the same way, an user may doesn't want to backup this big part of the app for</br> each of his backup. And so handle that part differently.</br></br>As this part of your backup may not be done, your restore script has to handle it.</br>In your restore script, use --not_mandatory with ynh_restore_file</br>As well in your remove script, you should not remove those data ! Or an user may end up with</br> a failed upgrade restoring an app without data anymore !</br></br>To have the benefit of --is_big while doing a backup, you can whether set the environement</br> variable BACKUP_CORE_ONLY to 1 (BACKUP_CORE_ONLY=1) before the backup command. It will affect</br> only that backup command.</br>Or set the config do_not_backup_data to 1 into the settings.yml of the app. This will affect</br> all backups for this app until the setting is removed.</br></br>Requires YunoHost version 2.4.0 or higher.</br>Requires YunoHost version 3.5.0 or higher for the argument --not_mandatory</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/backup#L63">Dude, show me the code !</a>
</p>
ynh_restore
Restore all files that were previously backuped in a core backup script or app backup script
<strong>Usage</strong>: <code class="helper-code">ynh_restore</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/backup#L186">Dude, show me the code !</a>
</p>
ynh_restore_file
Restore a file or a directory
<strong>Usage</strong>: <code class="helper-code">ynh_restore_file --origin_path=origin_path [--dest_path=dest_path] [--not_mandatory]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-o</code>, <code>--origin_path=</code> : Path where was located the file or the directory before to be backuped or relative path to $YNH_CWD where it is located in the backup archive</li>
<li><code>-d</code>, <code>--dest_path=</code> : Path where restore the file or the dir, if unspecified, the destination will be ORIGIN_PATH or if the ORIGIN_PATH doesn't exist in the archive, the destination will be searched into backup.csv</li>
<li><code>-m</code>, <code>--not_mandatory</code> : Indicate that if the file is missing, the restore process can ignore it.</li>
</ul>
</p>
<p>
<strong>Examples</strong>:<ul>
<code class="helper-code"> ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"</code>
<br>
You can also use relative paths:
<br>
<code class="helper-code"> ynh_restore_file "conf/nginx.conf"</code>
<br>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Use the registered path in backup_list by ynh_backup to restore the file at</br>the right place.</br></br>If DEST_PATH already exists and is lighter than 500 Mo, a backup will be made in</br>/home/yunohost.conf/backup/. Otherwise, the existing file is removed.</br></br>if apps/wordpress/etc/nginx/conf.d/$domain.d/$app.conf exists, restore it into</br>/etc/nginx/conf.d/$domain.d/$app.conf</br>if no, search for a match in the csv (eg: conf/nginx.conf) and restore it into</br>/etc/nginx/conf.d/$domain.d/$app.conf</br></br>Requires YunoHost version 2.6.4 or higher.</br>Requires YunoHost version 3.5.0 or higher for the argument --not_mandatory</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/backup#L247">Dude, show me the code !</a>
</p>
ynh_store_file_checksum
Calculate and store a file checksum into the app settings
<strong>Usage</strong>: <code class="helper-code">ynh_store_file_checksum --file=file</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-f</code>, <code>--file=</code> : The file on which the checksum will performed, then stored.</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
$app should be defined when calling this helper</br></br>Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/backup#L325">Dude, show me the code !</a>
</p>
ynh_backup_if_checksum_is_different
Verify the checksum and backup the file if it's different
<strong>Usage</strong>: <code class="helper-code">ynh_backup_if_checksum_is_different --file=file</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-f</code>, <code>--file=</code> : The file on which the checksum test will be perfomed.</li>
</ul>
</p>
<p>
<strong>Returns</strong>: the name of a backup file, or nothing
</p>
<p>
<strong>Details</strong>:
<p>
This helper is primarily meant to allow to easily backup personalised/manually</br>modified config files.</br></br>Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/backup#L357">Dude, show me the code !</a>
</p>
ynh_delete_file_checksum
Delete a file checksum from the app settings
<strong>Usage</strong>: <code class="helper-code">ynh_delete_file_checksum --file=file</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-f</code>, <code>--file=</code> : The file for which the checksum will be deleted</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
$app should be defined when calling this helper</br></br>Requires YunoHost version 3.3.1 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/backup#L390">Dude, show me the code !</a>
</p>
ynh_backup_before_upgrade
Make a backup in case of failed upgrade
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_backup_before_upgrade
ynh_clean_setup () { ynh_restore_upgradebackup } ynh_abort_if_errors
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.7.2 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/backup#L412">Dude, show me the code !</a>
</p>
ynh_restore_upgradebackup
Restore a previous backup if the upgrade process failed
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_backup_before_upgrade
ynh_clean_setup () { ynh_restore_upgradebackup } ynh_abort_if_errors
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.7.2 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/backup#L461">Dude, show me the code !</a>
</p>
fail2ban
ynh_add_fail2ban_config
Create a dedicated fail2ban config (jail and filter conf files)
<strong>Usage</strong>: <code class="helper-code helper-usage">1: ynh_add_fail2ban_config --logpath=log_file --failregex=filter [--max_retry=max_retry] [--ports=ports]
2: ynh_add_fail2ban_config --use_template [--others_var="list of others variables to replace"] | for example : 'var_1 var_2 ...'
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-l</code>, <code>--logpath=</code> : Log file to be checked by fail2ban</li>
<li><code>-r</code>, <code>--failregex=</code> : Failregex to be looked for by fail2ban</li>
<li><code>-m</code>, <code>--max_retry=</code> : Maximum number of retries allowed before banning IP address - default: 3</li>
<li><code>-p</code>, <code>--ports=</code> : Ports blocked for a banned IP address - default: http,https</li>
<li><code>-t</code>, <code>--use_template</code> : Use this helper in template mode</li>
<li><code>-v</code>, <code>--others_var=</code> : List of others variables to replace separeted by a space</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
-----------------------------------------------------------------------------</br></br>This will use a template in ../conf/f2b_jail.conf and ../conf/f2b_filter.conf</br> __APP__ by $app</br></br>You can dynamically replace others variables by example :</br> __VAR_1__ by $var_1</br> __VAR_2__ by $var_2</br></br>Generally your template will look like that by example (for synapse):</br></br>f2b_jail.conf:</br> [__APP__]</br> enabled = true</br> port = http,https</br> filter = __APP__</br> logpath = /var/log/__APP__/logfile.log</br> maxretry = 3</br></br>f2b_filter.conf:</br> [INCLUDES]</br> before = common.conf</br> [Definition]</br></br># Part of regex definition (just used to make more easy to make the global regex)</br> __synapse_start_line = .? \- synapse\..+ \-</br></br># Regex definition.</br> failregex = ^%(__synapse_start_line)s INFO \- POST\-(\d+)\- <HOST> \- \d+ \- Received request\: POST /_matrix/client/r0/login\??<SKIPLINES>%(__synapse_start_line)s INFO \- POST\-\1\- Got login request with identifier: \{u'type': u'm.id.user', u'user'\: u'(.+?)'\}, medium\: None, address: None, user\: u'\5'<SKIPLINES>%(__synapse_start_line)s WARNING \- \- (Attempted to login as @\5\:.+ but they do not exist|Failed password login for user @\5\:.+)$</br></br>ignoreregex =</br></br>-----------------------------------------------------------------------------</br></br>Note about the "failregex" option:</br> regex to match the password failure messages in the logfile. The</br> host must be matched by a group named "host". The tag "<HOST>" can</br> be used for standard IP/hostname matching and is only an alias for</br> (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)</br></br>You can find some more explainations about how to make a regex here :</br> https://www.fail2ban.org/wiki/index.php/MANUAL_0_8#Filters</br></br>Note that the logfile need to exist before to call this helper !!</br></br>To validate your regex you can test with this command:</br>fail2ban-regex /var/log/YOUR_LOG_FILE_PATH /etc/fail2ban/filter.d/YOUR_APP.conf</br></br>Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/fail2ban#L65">Dude, show me the code !</a>
</p>
ynh_remove_fail2ban_config
Remove the dedicated fail2ban config (jail and filter conf files)
<strong>Usage</strong>: <code class="helper-code">ynh_remove_fail2ban_config</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/fail2ban#L150">Dude, show me the code !</a>
</p>
getopts
hardware
ynh_get_ram
Get the total or free amount of RAM+swap on the system
<strong>Usage</strong>: <code class="helper-code">ynh_get_ram [--free|--total] [--ignore_swap|--only_swap]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-f</code>, <code>--free</code> : Count free RAM+swap</li>
<li><code>-t</code>, <code>--total</code> : Count total RAM+swap</li>
<li><code>-s</code>, <code>--ignore_swap</code> : Ignore swap, consider only real RAM</li>
<li><code>-o</code>, <code>--only_swap</code> : Ignore real RAM, consider only swap</li>
</ul>
</p>
<p>
<strong>Returns</strong>: the amount of free ram
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.8.1 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/hardware#L13">Dude, show me the code !</a>
</p>
ynh_require_ram
Return 0 or 1 depending if the system has a given amount of RAM+swap free or total
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_require_ram --required=RAM required in Mb [--free|--total] [--ignore_swap|--only_swap]
| exit: Return 1 if the ram is under the requirement, 0 otherwise.
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-r</code>, <code>--required=</code> : The amount to require, in Mb</li>
<li><code>-f</code>, <code>--free</code> : Count free RAM+swap</li>
<li><code>-t</code>, <code>--total</code> : Count total RAM+swap</li>
<li><code>-s</code>, <code>--ignore_swap</code> : Ignore swap, consider only real RAM</li>
<li><code>-o</code>, <code>--only_swap</code> : Ignore real RAM, consider only swap</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.8.1 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/hardware#L82">Dude, show me the code !</a>
</p>
logging
ynh_die
Print a message to stderr and exit
<strong>Usage</strong>: <code class="helper-code">ynh_die --message=MSG [--ret_code=RETCODE]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-m</code>, <code>--message=</code> : Message to display</li>
<li><code>-c</code>, <code>--ret_code=</code> : Exit code to exit with</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.4.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L10">Dude, show me the code !</a>
</p>
ynh_print_info
Display a message in the 'INFO' logging category
<strong>Usage</strong>: <code class="helper-code">ynh_print_info --message="Some message"</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-m</code>, <code>--message=</code> : Message to display</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.2.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L30">Dude, show me the code !</a>
</p>
ynh_print_warn
Print a warning on stderr
<strong>Usage</strong>: <code class="helper-code">ynh_print_warn --message="Text to print"</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-m</code>, <code>--message=</code> : The text to print</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.2.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L75">Dude, show me the code !</a>
</p>
ynh_print_err
Print an error on stderr
<strong>Usage</strong>: <code class="helper-code">ynh_print_err --message="Text to print"</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-m</code>, <code>--message=</code> : The text to print</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.2.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L92">Dude, show me the code !</a>
</p>
ynh_exec_err
Execute a command and print the result as an error
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_exec_err your_command
ynh_exec_err "your_command | other_command"
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>command</code> : command to execute</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
When using pipes, double quotes are required - otherwise, this helper will run the first command, and the whole output will be sent through the next pipe.</br></br>If the command to execute uses double quotes, they have to be escaped or they will be interpreted and removed.</br></br>Requires YunoHost version 3.2.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L114">Dude, show me the code !</a>
</p>
ynh_exec_warn
Execute a command and print the result as a warning
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_exec_warn your_command
ynh_exec_warn "your_command | other_command"
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>command</code> : command to execute</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
When using pipes, double quotes are required - otherwise, this helper will run the first command, and the whole output will be sent through the next pipe.</br></br>If the command to execute uses double quotes, they have to be escaped or they will be interpreted and removed.</br></br>Requires YunoHost version 3.2.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L129">Dude, show me the code !</a>
</p>
ynh_exec_warn_less
Execute a command and force the result to be printed on stdout
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_exec_warn_less your_command
ynh_exec_warn_less "your_command | other_command"
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>command</code> : command to execute</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
When using pipes, double quotes are required - otherwise, this helper will run the first command, and the whole output will be sent through the next pipe.</br></br>If the command to execute uses double quotes, they have to be escaped or they will be interpreted and removed.</br></br>Requires YunoHost version 3.2.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L144">Dude, show me the code !</a>
</p>
ynh_exec_quiet
Execute a command and redirect stdout in /dev/null
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_exec_quiet your_command
ynh_exec_quiet "your_command | other_command"
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>command</code> : command to execute</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
When using pipes, double quotes are required - otherwise, this helper will run the first command, and the whole output will be sent through the next pipe.</br></br>If the command to execute uses double quotes, they have to be escaped or they will be interpreted and removed.</br></br>Requires YunoHost version 3.2.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L159">Dude, show me the code !</a>
</p>
ynh_exec_fully_quiet
Execute a command and redirect stdout and stderr in /dev/null
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_exec_fully_quiet your_command
ynh_exec_fully_quiet "your_command | other_command"
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>command</code> : command to execute</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
When using pipes, double quotes are required - otherwise, this helper will run the first command, and the whole output will be sent through the next pipe.</br></br>If the command to execute uses double quotes, they have to be escaped or they will be interpreted and removed.</br></br>Requires YunoHost version 3.2.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L174">Dude, show me the code !</a>
</p>
ynh_print_OFF
Remove any logs for all the following commands.
<strong>Usage</strong>: <code class="helper-code">ynh_print_OFF</code>
</p>
<p>
<strong>Details</strong>:
<p>
WARNING: You should be careful with this helper, and never forget to use ynh_print_ON as soon as possible to restore the logging.</br></br>Requires YunoHost version 3.2.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L185">Dude, show me the code !</a>
</p>
ynh_print_ON
Restore the logging after ynh_print_OFF
<strong>Usage</strong>: <code class="helper-code">ynh_print_ON</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.2.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L194">Dude, show me the code !</a>
</p>
ynh_script_progression
Print a progress bar showing the progression of an app script
<strong>Usage</strong>: <code class="helper-code">ynh_script_progression --message=message [--weight=weight] [--time]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-m</code>, <code>--message=</code> : The text to print</li>
<li><code>-w</code>, <code>--weight=</code> : The weight for this progression. This value is 1 by default. Use a bigger value for a longer part of the script.</li>
<li><code>-t</code>, <code>--time</code> : Print the execution time since the last call to this helper. Especially usefull to define weights. The execution time is given for the duration since the previous call. So the weight should be applied to this previous call.</li>
<li><code>-l</code>, <code>--last</code> : Use for the last call of the helper, to fill the progression bar.</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L222">Dude, show me the code !</a>
</p>
ynh_return
Return data to the Yunohost core for later processing (to be used by special hooks like app config panel and core diagnosis)
<strong>Usage</strong>: <code class="helper-code">ynh_return somedata</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.6.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L307">Dude, show me the code !</a>
</p>
ynh_debug
Debugger for app packagers
<strong>Usage</strong>: <code class="helper-code">ynh_debug [--message=message] [--trace=1/0]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-m</code>, <code>--message=</code> : The text to print</li>
<li><code>-t</code>, <code>--trace=</code> : Turn on or off the trace of the script. Usefull to trace nonly a small part of a script.</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L318">Dude, show me the code !</a>
</p>
ynh_debug_exec
Execute a command and print the result as debug
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_debug_exec your_command
ynh_debug_exec "your_command | other_command"
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>command</code> : command to execute</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
When using pipes, double quotes are required - otherwise, this helper will run the first command, and the whole output will be sent through the next pipe.</br></br>If the command to execute uses double quotes, they have to be escaped or they will be interpreted and removed.</br></br>Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logging#L375">Dude, show me the code !</a>
</p>
logrotate
ynh_use_logrotate
Use logrotate to manage the logfile
<strong>Usage</strong>: <code class="helper-code">ynh_use_logrotate [--logfile=/log/file] [--nonappend] [--specific_user=user/group]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-l</code>, <code>--logfile=</code> : absolute path of logfile</li>
<li><code>-n</code>, <code>--nonappend</code> : (optional) Replace the config file instead of appending this new config.</li>
<li><code>-u</code>, <code>--specific_user=</code> : run logrotate as the specified user and group. If not specified logrotate is runned as root.</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
If no --logfile is provided, /var/log/${app} will be used as default.</br>logfile can be just a directory, or a full path to a logfile :</br>/parentdir/logdir</br>/parentdir/logdir/logfile.log</br></br>It's possible to use this helper multiple times, each config will be added to</br>the same logrotate config file. Unless you use the option --non-append</br></br>Requires YunoHost version 2.6.4 or higher.</br>Requires YunoHost version 3.2.0 or higher for the argument --specific_user</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logrotate#L20">Dude, show me the code !</a>
</p>
ynh_remove_logrotate
Remove the app's logrotate config.
<strong>Usage</strong>: <code class="helper-code">ynh_remove_logrotate</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/logrotate#L108">Dude, show me the code !</a>
</p>
mysql
ynh_mysql_connect_as
Open a connection as a user
<strong>Usage</strong>: <code class="helper-code">ynh_mysql_connect_as --user=user --password=password [--database=database]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--user=</code> : the user name to connect as</li>
<li><code>-p</code>, <code>--password=</code> : the user password</li>
<li><code>-d</code>, <code>--database=</code> : the database to connect to</li>
</ul>
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_mysql_connect_as --user="user" --password="pass" <<< "UPDATE ...;" example: ynh_mysql_connect_as --user="user" --password="pass" < /path/to/file.sql</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/mysql#L16">Dude, show me the code !</a>
</p>
ynh_mysql_execute_as_root
Execute a command as root user
<strong>Usage</strong>: <code class="helper-code">ynh_mysql_execute_as_root --sql=sql [--database=database]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-s</code>, <code>--sql=</code> : the SQL command to execute</li>
<li><code>-d</code>, <code>--database=</code> : the database to connect to</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/mysql#L37">Dude, show me the code !</a>
</p>
ynh_mysql_execute_file_as_root
Execute a command from a file as root user
<strong>Usage</strong>: <code class="helper-code">ynh_mysql_execute_file_as_root --file=file [--database=database]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-f</code>, <code>--file=</code> : the file containing SQL commands</li>
<li><code>-d</code>, <code>--database=</code> : the database to connect to</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/mysql#L63">Dude, show me the code !</a>
</p>
ynh_mysql_dump_db
Dump a database
<strong>Usage</strong>: <code class="helper-code">ynh_mysql_dump_db --database=database</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-d</code>, <code>--database=</code> : the database name to dump</li>
</ul>
</p>
<p>
<strong>Returns</strong>: the mysqldump output
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_mysql_dump_db --database=roundcube > ./dump.sql</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/mysql#L135">Dude, show me the code !</a>
</p>
ynh_mysql_user_exists
Check if a mysql user exists
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_mysql_user_exists --user=user
| exit: Return 1 if the user doesn't exist, 0 otherwise.
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--user=</code> : the user for which to check existence</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/mysql#L167">Dude, show me the code !</a>
</p>
ynh_mysql_setup_db
Create a database, an user and its password. Then store the password in the app's config
<strong>Usage</strong>: <code class="helper-code">ynh_mysql_setup_db --db_user=user --db_name=name [--db_pwd=pwd]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--db_user=</code> : Owner of the database</li>
<li><code>-n</code>, <code>--db_name=</code> : Name of the database</li>
<li><code>-p</code>, <code>--db_pwd=</code> : Password of the database. If not provided, a password will be generated</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
After executing this helper, the password of the created database will be available in $db_pwd</br>It will also be stored as "mysqlpwd" into the app settings.</br></br>Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/mysql#L207">Dude, show me the code !</a>
</p>
ynh_mysql_remove_db
Remove a database if it exists, and the associated user
<strong>Usage</strong>: <code class="helper-code">ynh_mysql_remove_db --db_user=user --db_name=name</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--db_user=</code> : Owner of the database</li>
<li><code>-n</code>, <code>--db_name=</code> : Name of the database</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/mysql#L232">Dude, show me the code !</a>
</p>
network
ynh_find_port
Find a free port and return it
<strong>Usage</strong>: <code class="helper-code">ynh_find_port --port=begin_port</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-p</code>, <code>--port=</code> : port to start to search</li>
</ul>
</p>
<p>
<strong>Returns</strong>: the port number
</p>
<p>
<strong>Example</strong>: <code class="helper-code">port=$(ynh_find_port --port=8080)</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/network#L12">Dude, show me the code !</a>
</p>
ynh_port_available
Test if a port is available
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_find_port --port=XYZ
| exit: Return 1 if the port is already used by another process.
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-p</code>, <code>--port=</code> : port to check</li>
</ul>
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_port_available --port=1234 || ynh_die "Port 1234 is needs to be available for this app"</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.8.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/network#L37">Dude, show me the code !</a>
</p>
ynh_validate_ip4
Validate an IPv4 address
<strong>Usage</strong>: <code class="helper-code">ynh_validate_ip4 --ip_address=ip_address</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-i</code>, <code>--ip_address=</code> : the ipv4 address to check</li>
</ul>
</p>
<p>
<strong>Returns</strong>: 0 for valid ipv4 addresses, 1 otherwise
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_validate_ip4 111.222.333.444</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/network#L99">Dude, show me the code !</a>
</p>
ynh_validate_ip6
Validate an IPv6 address
<strong>Usage</strong>: <code class="helper-code">ynh_validate_ip6 --ip_address=ip_address</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-i</code>, <code>--ip_address=</code> : the ipv6 address to check</li>
</ul>
</p>
<p>
<strong>Returns</strong>: 0 for valid ipv6 addresses, 1 otherwise
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_validate_ip6 2000:dead:beef::1</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/network#L121">Dude, show me the code !</a>
</p>
nginx
ynh_add_nginx_config
Create a dedicated nginx config
<strong>Usage</strong>: <code class="helper-code">ynh_add_nginx_config "list of others variables to replace"</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>list</code> : (Optional) list of others variables to replace separated by spaces. For example : 'path_2 port_2 ...'</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
This will use a template in ../conf/nginx.conf</br> __PATH__ by $path_url</br> __DOMAIN__ by $domain</br> __PORT__ by $port</br> __NAME__ by $app</br> __FINALPATH__ by $final_path</br> __PHPVERSION__ by $YNH_PHP_VERSION ($YNH_PHP_VERSION is either the default php version or the version defined for the app)</br></br>And dynamic variables (from the last example) :</br> __PATH_2__ by $path_2</br> __PORT_2__ by $port_2</br></br>Requires YunoHost version 2.7.2 or higher.</br>Requires YunoHost version 2.7.13 or higher for dynamic variables</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/nginx#L23">Dude, show me the code !</a>
</p>
ynh_remove_nginx_config
Remove the dedicated nginx config
<strong>Usage</strong>: <code class="helper-code">ynh_remove_nginx_config</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.7.2 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/nginx#L77">Dude, show me the code !</a>
</p>
nodejs
ynh_use_nodejs
Load the version of node for an app, and set variables.
<strong>Usage</strong>: <code class="helper-code">ynh_use_nodejs</code>
</p>
<p>
<strong>Details</strong>:
<p>
ynh_use_nodejs has to be used in any app scripts before using node for the first time.</br>This helper will provide alias and variables to use in your scripts.</br></br>To use npm or node, use the alias `ynh_npm` and `ynh_node`</br>Those alias will use the correct version installed for the app</br>For example: use `ynh_npm install` instead of `npm install`</br></br>With `sudo` or `ynh_exec_as`, use instead the fallback variables `$ynh_npm` and `$ynh_node`</br>And propagate $PATH to sudo with $ynh_node_load_PATH</br>Exemple: `ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install`</br></br>$PATH contains the path of the requested version of node.</br>However, $PATH is duplicated into $node_PATH to outlast any manipulation of $PATH</br>You can use the variable `$ynh_node_load_PATH` to quickly load your node version</br> in $PATH for an usage into a separate script.</br>Exemple: $ynh_node_load_PATH $final_path/script_that_use_npm.sh`</br></br>Finally, to start a nodejs service with the correct version, 2 solutions</br> Either the app is dependent of node or npm, but does not called it directly.</br> In such situation, you need to load PATH</br> `Environment="__NODE_ENV_PATH__"`</br> `ExecStart=__FINALPATH__/my_app`</br> You will replace __NODE_ENV_PATH__ with $ynh_node_load_PATH</br></br>Or node start the app directly, then you don't need to load the PATH variable</br> `ExecStart=__YNH_NODE__ my_app run`</br> You will replace __YNH_NODE__ with $ynh_node</br></br>2 other variables are also available</br> - $nodejs_path: The absolute path to node binaries for the chosen version.</br> - $nodejs_version: Just the version number of node for this app. Stored as 'nodejs_version' in settings.yml.</br></br>Requires YunoHost version 2.7.12 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/nodejs#L68">Dude, show me the code !</a>
</p>
ynh_install_nodejs
Install a specific version of nodejs
<strong>Usage</strong>: <code class="helper-code">ynh_install_nodejs --nodejs_version=nodejs_version</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-n</code>, <code>--nodejs_version=</code> : Version of node to install. When possible, your should prefer to use major version number (e.g. 8 instead of 8.10.0). The crontab will then handle the update of minor versions when needed.</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
ynh_install_nodejs will install the version of node provided as argument by using n.</br></br>n (Node version management) uses the PATH variable to store the path of the version of node it is going to use.</br>That's how it changes the version</br></br>Refer to ynh_use_nodejs for more information about available commands and variables</br></br>Requires YunoHost version 2.7.12 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/nodejs#L106">Dude, show me the code !</a>
</p>
ynh_remove_nodejs
Remove the version of node used by the app.
<strong>Usage</strong>: <code class="helper-code">ynh_remove_nodejs</code>
</p>
<p>
<strong>Details</strong>:
<p>
This helper will check if another app uses the same version of node,</br>if not, this version of node will be removed.</br>If no other app uses node, n will be also removed.</br></br>Requires YunoHost version 2.7.12 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/nodejs#L187">Dude, show me the code !</a>
</p>
permission
ynh_permission_create
Create a new permission for the app
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_permission_create --permission="permission" [--url="url"] [--additional_urls="second-url" [ "third-url" ]] [--auth_header=true|false]
[--allowed=group1 [ group2 ]] [--label="label"] [--show_tile=true|false]
[--protected=true|false]
| Not that if 'show_tile' is enabled, this URL will be the URL of the tile. | Default is "APP_LABEL (permission name)". | Default is false (for the permission different than 'main'). | won't be able to add or remove the visitors group of this permission. | By default it's 'false'
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-p,</code> : - the name for the permission (by default a permission named "main" already exist)</li>
<li><code>-u,</code> : - (optional) URL for which access will be allowed/forbidden.</li>
<li><code>-A,</code> : - (optional) List of additional URL for which access will be allowed/forbidden</li>
<li><code>-h,</code> : - (optional) Define for the URL of this permission, if SSOwat pass the authentication header to the application. Default is true</li>
<li><code>-a,</code> : - (optional) A list of group/user to allow for the permission</li>
<li><code>-l,</code> : - (optional) Define a name for the permission. This label will be shown on the SSO and in the admin.</li>
<li><code>-t,</code> : - (optional) Define if a tile will be shown in the SSO. If yes the name of the tile will be the 'label' parameter.</li>
<li><code>-P,</code> : - (optional) Define if this permission is protected. If it is protected the administrator</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
example 1: ynh_permission_create --permission=admin --url=/admin --additional_urls=domain.tld/admin /superadmin --allowed=alice bob \</br> --label="My app admin" --show_tile=true</br></br>This example will create a new permission permission with this following effect:</br>- A tile named "My app admin" in the SSO will be available for the users alice and bob. This tile will point to the relative url '/admin'.</br>- Only the user alice and bob will have the access to theses following url: /admin, domain.tld/admin, /superadmin</br></br>example 2: ynh_permission_create --permission=api --url=domain.tld/api --auth_header=false --allowed=visitors \</br> --label="MyApp API" --protected=true</br></br>This example will create a new protected permission. So the admin won't be able to add/remove the visitors group of this permission.</br>In case of an API with need to be always public it avoid that the admin break anything.</br>With this permission all client will be allowed to access to the url 'domain.tld/api'.</br>Note that in this case no tile will be show on the SSO.</br>Note that the auth_header parameter is to 'false'. So no authentication header will be passed to the application.</br>Generally the API is requested by an application and enabling the auth_header has no advantage and could bring some issues in some case.</br>So in this case it's better to disable this option for all API.</br></br>If provided, 'url' or 'additional_urls' is assumed to be relative to the app domain/path if they</br>start with '/'. For example:</br> / -> domain.tld/app</br> /admin -> domain.tld/app/admin</br> domain.tld/app/api -> domain.tld/app/api</br></br>'url' or 'additional_urls' can be treated as a PCRE (not lua) regex if it starts with "re:".</br>For example:</br> re:/api/[A-Z]*$ -> domain.tld/app/api/[A-Z]*$</br> re:domain.tld/app/api/[A-Z]*$ -> domain.tld/app/api/[A-Z]*$</br></br>Note that globally the parameter 'url' and 'additional_urls' are same. The only difference is:</br>- 'url' is only one url, 'additional_urls' can be a list of urls. There are no limitation of 'additional_urls'</br>- 'url' is used for the url of tile in the SSO (if enabled with the 'show_tile' parameter)</br></br>About the authentication header (auth_header parameter).</br>The SSO pass (by default) to the application theses following HTTP header (linked to the authenticated user) to the application:</br> - "Auth-User": username</br> - "Remote-User": username</br> - "Email": user email</br></br>Generally this feature is usefull to authenticate automatically the user in the application but in some case the application don't work with theses header and theses header need to be disabled to have the application to work correctly.</br>See https://github.com/YunoHost/issues/issues/1420 for more informations</br></br>Requires YunoHost version 3.7.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/permission#L69">Dude, show me the code !</a>
</p>
ynh_permission_delete
Remove a permission for the app (note that when the app is removed all permission is automatically removed)
<strong>Usage</strong>: <code class="helper-code">ynh_permission_delete --permission="permission"</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-p</code>, <code>--permission=</code> : the name for the permission (by default a permission named "main" is removed automatically when the app is removed)</li>
</ul>
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_permission_delete --permission=editors</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.7.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/permission#L164">Dude, show me the code !</a>
</p>
ynh_permission_exists
Check if a permission exists
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_permission_exists --permission=permission
| exit: Return 1 if the permission doesn't exist, 0 otherwise
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-p</code>, <code>--permission=</code> : the permission to check</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.7.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/permission#L181">Dude, show me the code !</a>
</p>
ynh_permission_url
Redefine the url associated to a permission
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_permission_url --permission "permission" [--url="url"] [--add_url="new-url" [ "other-new-url" ]] [--remove_url="old-url" [ "other-old-url" ]]
[--auth_header=true|false] [--clear_urls]
| Note that if you want to remove url you can pass an empty sting as arguments ("").
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-p,</code> : - the name for the permission (by default a permission named "main" is removed automatically when the app is removed)</li>
<li><code>-u,</code> : - (optional) URL for which access will be allowed/forbidden.</li>
<li><code>-a,</code> : - (optional) List of additional url to add for which access will be allowed/forbidden.</li>
<li><code>-r,</code> : - (optional) List of additional url to remove for which access will be allowed/forbidden</li>
<li><code>-h,</code> : - (optional) Define for the URL of this permission, if SSOwat pass the authentication header to the application</li>
<li><code>-c,</code> : - (optional) Clean all urls (url and additional_urls)</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.7.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/permission#L204">Dude, show me the code !</a>
</p>
ynh_permission_update
Update a permission for the app
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_permission_update --permission "permission" [--add="group" ["group" ...]] [--remove="group" ["group" ...]]
[--label="label"] [--show_tile=true|false] [--protected=true|false]
| won't be able to add or remove the visitors group of this permission.
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-p,</code> : - the name for the permission (by default a permission named "main" already exist)</li>
<li><code>-a,</code> : - the list of group or users to enable add to the permission</li>
<li><code>-r,</code> : - the list of group or users to remove from the permission</li>
<li><code>-l,</code> : - (optional) Define a name for the permission. This label will be shown on the SSO and in the admin.</li>
<li><code>-t,</code> : - (optional) Define if a tile will be shown in the SSO</li>
<li><code>-P,</code> : - (optional) Define if this permission is protected. If it is protected the administrator</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.7.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/permission#L280">Dude, show me the code !</a>
</p>
ynh_permission_has_user
Check if a permission has an user
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_permission_has_user --permission=permission --user=user
| exit: Return 1 if the permission doesn't have that user or doesn't exist, 0 otherwise
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-p</code>, <code>--permission=</code> : the permission to check</li>
<li><code>-u</code>, <code>--user=</code> : the user seek in the permission</li>
</ul>
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_permission_has_user --permission=main --user=visitors</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.7.1 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/permission#L355">Dude, show me the code !</a>
</p>
ynh_legacy_permissions_exists
Check if a legacy permissions exist
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_legacy_permissions_exists
| exit: Return 1 if the permission doesn't exist, 0 otherwise
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 4.1.2 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/permission#L378">Dude, show me the code !</a>
</p>
ynh_legacy_permissions_delete_all
Remove all legacy permissions
<strong>Usage</strong>: <code class="helper-code">ynh_legacy_permissions_delete_all</code>
</p>
<p>
<strong>Example</strong>: <code class="helper-code">if ynh_legacy_permissions_exists then ynh_legacy_permissions_delete_all # You can recreate the required permissions here with ynh_permission_create fi Requires YunoHost version 4.1.2 or higher.</code>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/permission#L399">Dude, show me the code !</a>
</p>
php
ynh_add_fpm_config
Create a dedicated PHP-FPM config
<strong>Usage</strong>: <code class="helper-code helper-usage">1: ynh_add_fpm_config [--phpversion=7.X] [--use_template] [--package=packages] [--dedicated_service]
2: ynh_add_fpm_config [--phpversion=7.X] --usage=usage --footprint=footprint [--package=packages] [--dedicated_service] low - Less than 20 MB of RAM by pool. medium - Between 20 MB and 40 MB of RAM by pool. high - More than 40 MB of RAM by pool. Or specify exactly the footprint, the load of the service as MB by pool instead of having a standard value. To have this value, use the following command and stress the service. watch -n0.5 ps -o user,cmd,%cpu,rss -u APP
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-v</code>, <code>--phpversion=</code> : Version of PHP to use.</li>
<li><code>-t</code>, <code>--use_template</code> : Use this helper in template mode.</li>
<li><code>-p</code>, <code>--package=</code> : Additionnal PHP packages to install</li>
<li><code>-d</code>, <code>--dedicated_service</code> : Use a dedicated PHP-FPM service instead of the common one.</li>
<li><code>-v</code>, <code>--phpversion=</code> : Version of PHP to use.</li>
<li><code>-f</code>, <code>--footprint=</code> : Memory footprint of the service (low/medium/high).</li>
<li><code>-u</code>, <code>--usage=</code> : Expected usage of the service (low/medium/high).</li>
<li><code>-p</code>, <code>--package=</code> : Additionnal PHP packages to install for a specific version of PHP</li>
<li><code>-d</code>, <code>--dedicated_service</code> : Use a dedicated PHP-FPM service instead of the common one.</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
-----------------------------------------------------------------------------</br></br>The footprint of the service will be used to defined the maximum footprint we can allow, which is half the maximum RAM.</br>So it will be used to defined 'pm.max_children'</br>A lower value for the footprint will allow more children for 'pm.max_children'. And so for</br> 'pm.start_servers', 'pm.min_spare_servers' and 'pm.max_spare_servers' which are defined from the</br> value of 'pm.max_children'</br>NOTE: 'pm.max_children' can't exceed 4 times the number of processor's cores.</br></br>The usage value will defined the way php will handle the children for the pool.</br>A value set as 'low' will set the process manager to 'ondemand'. Children will start only if the</br> service is used, otherwise no child will stay alive. This config gives the lower footprint when the</br> service is idle. But will use more proc since it has to start a child as soon it's used.</br>Set as 'medium', the process manager will be at dynamic. If the service is idle, a number of children</br> equal to pm.min_spare_servers will stay alive. So the service can be quick to answer to any request.</br> The number of children can grow if needed. The footprint can stay low if the service is idle, but</br> not null. The impact on the proc is a little bit less than 'ondemand' as there's always a few</br> children already available.</br>Set as 'high', the process manager will be set at 'static'. There will be always as many children as</br> 'pm.max_children', the footprint is important (but will be set as maximum a quarter of the maximum</br> RAM) but the impact on the proc is lower. The service will be quick to answer as there's always many</br> children ready to answer.</br></br>Requires YunoHost version 2.7.2 or higher.</br>Requires YunoHost version 3.5.1 or higher for the argument --phpversion</br>Requires YunoHost version 3.8.1 or higher for the arguments --use_template, --usage, --footprint, --package and --dedicated_service</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/php#L61">Dude, show me the code !</a>
</p>
ynh_remove_fpm_config
Remove the dedicated PHP-FPM config
<strong>Usage</strong>: <code class="helper-code">ynh_remove_fpm_config</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.7.2 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/php#L288">Dude, show me the code !</a>
</p>
postgresql
ynh_psql_connect_as
Open a connection as a user
<strong>Usage</strong>: <code class="helper-code">ynh_psql_connect_as --user=user --password=password [--database=database]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--user=</code> : the user name to connect as</li>
<li><code>-p</code>, <code>--password=</code> : the user password</li>
<li><code>-d</code>, <code>--database=</code> : the database to connect to</li>
</ul>
</p>
<p>
<strong>Examples</strong>:<ul>
<code class="helper-code"> ynh_psql_connect_as 'user' 'pass' <<< "UPDATE ...;"</code>
<br>
<code class="helper-code"> ynh_psql_connect_as 'user' 'pass' < /path/to/file.sql</code>
<br>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/postgresql#L18">Dude, show me the code !</a>
</p>
ynh_psql_execute_as_root
Execute a command as root user
<strong>Usage</strong>: <code class="helper-code">ynh_psql_execute_as_root --sql=sql [--database=database]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-s</code>, <code>--sql=</code> : the SQL command to execute</li>
<li><code>-d</code>, <code>--database=</code> : the database to connect to</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/postgresql#L39">Dude, show me the code !</a>
</p>
ynh_psql_execute_file_as_root
Execute a command from a file as root user
<strong>Usage</strong>: <code class="helper-code">ynh_psql_execute_file_as_root --file=file [--database=database]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-f</code>, <code>--file=</code> : the file containing SQL commands</li>
<li><code>-d</code>, <code>--database=</code> : the database to connect to</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/postgresql#L65">Dude, show me the code !</a>
</p>
ynh_psql_dump_db
Dump a database
<strong>Usage</strong>: <code class="helper-code">ynh_psql_dump_db --database=database</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-d</code>, <code>--database=</code> : the database name to dump</li>
</ul>
</p>
<p>
<strong>Returns</strong>: the psqldump output
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_psql_dump_db 'roundcube' > ./dump.sql</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/postgresql#L137">Dude, show me the code !</a>
</p>
ynh_psql_user_exists
Check if a psql user exists
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_psql_user_exists --user=user
| exit: Return 1 if the user doesn't exist, 0 otherwise
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--user=</code> : the user for which to check existence</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/postgresql#L170">Dude, show me the code !</a>
</p>
ynh_psql_database_exists
Check if a psql database exists
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_psql_database_exists --database=database
| exit: Return 1 if the database doesn't exist, 0 otherwise
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-d</code>, <code>--database=</code> : the database for which to check existence</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/postgresql#L193">Dude, show me the code !</a>
</p>
ynh_psql_setup_db
Create a database, an user and its password. Then store the password in the app's config
<strong>Usage</strong>: <code class="helper-code">ynh_psql_setup_db --db_user=user --db_name=name [--db_pwd=pwd]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--db_user=</code> : Owner of the database</li>
<li><code>-n</code>, <code>--db_name=</code> : Name of the database</li>
<li><code>-p</code>, <code>--db_pwd=</code> : Password of the database. If not provided, a password will be generated</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
After executing this helper, the password of the created database will be available in $db_pwd</br>It will also be stored as "psqlpwd" into the app settings.</br></br>Requires YunoHost version 2.7.13 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/postgresql#L232">Dude, show me the code !</a>
</p>
ynh_psql_remove_db
Remove a database if it exists, and the associated user
<strong>Usage</strong>: <code class="helper-code">ynh_psql_remove_db --db_user=user --db_name=name</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--db_user=</code> : Owner of the database</li>
<li><code>-n</code>, <code>--db_name=</code> : Name of the database</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.7.13 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/postgresql#L263">Dude, show me the code !</a>
</p>
ynh_psql_test_if_first_run
Create a master password and set up global settings It also make sure that postgresql is installed and running Please always call this script in install and restore scripts
<strong>Usage</strong>: <code class="helper-code">ynh_psql_test_if_first_run</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.7.13 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/postgresql#L295">Dude, show me the code !</a>
</p>
setting
ynh_app_setting_get
Get an application setting
<strong>Usage</strong>: <code class="helper-code">ynh_app_setting_get --app=app --key=key</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-a</code>, <code>--app=</code> : the application id</li>
<li><code>-k</code>, <code>--key=</code> : the setting to get</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/setting#L10">Dude, show me the code !</a>
</p>
ynh_app_setting_set
Set an application setting
<strong>Usage</strong>: <code class="helper-code">ynh_app_setting_set --app=app --key=key --value=value</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-a</code>, <code>--app=</code> : the application id</li>
<li><code>-k</code>, <code>--key=</code> : the setting name to set</li>
<li><code>-v</code>, <code>--value=</code> : the setting value to set</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/setting#L34">Dude, show me the code !</a>
</p>
ynh_app_setting_delete
Delete an application setting
<strong>Usage</strong>: <code class="helper-code">ynh_app_setting_delete --app=app --key=key</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-a</code>, <code>--app=</code> : the application id</li>
<li><code>-k</code>, <code>--key=</code> : the setting to delete</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/setting#L58">Dude, show me the code !</a>
</p>
ynh_webpath_available
Check availability of a web path
<strong>Usage</strong>: <code class="helper-code">ynh_webpath_available --domain=domain --path_url=path</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-d</code>, <code>--domain=</code> : the domain/host of the url</li>
<li><code>-p</code>, <code>--path_url=</code> : the web path to check the availability of</li>
</ul>
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_webpath_available --domain=some.domain.tld --path_url=/coffee</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/setting#L118">Dude, show me the code !</a>
</p>
ynh_webpath_register
Register/book a web path for an app
<strong>Usage</strong>: <code class="helper-code">ynh_webpath_register --app=app --domain=domain --path_url=path</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-a</code>, <code>--app=</code> : the app for which the domain should be registered</li>
<li><code>-d</code>, <code>--domain=</code> : the domain/host of the web path</li>
<li><code>-p</code>, <code>--path_url=</code> : the web path to be registered</li>
</ul>
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_webpath_register --app=wordpress --domain=some.domain.tld --path_url=/coffee</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/setting#L140">Dude, show me the code !</a>
</p>
string
ynh_string_random
Generate a random string
<strong>Usage</strong>: <code class="helper-code">ynh_string_random [--length=string_length]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-l</code>, <code>--length=</code> : the string length to generate (default: 24)</li>
</ul>
</p>
<p>
<strong>Returns</strong>: the generated string
</p>
<p>
<strong>Example</strong>: <code class="helper-code">pwd=$(ynh_string_random --length=8)</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/string#L12">Dude, show me the code !</a>
</p>
ynh_replace_string
Substitute/replace a string (or expression) by another in a file
<strong>Usage</strong>: <code class="helper-code">ynh_replace_string --match_string=match_string --replace_string=replace_string --target_file=target_file</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-m</code>, <code>--match_string=</code> : String to be searched and replaced in the file</li>
<li><code>-r</code>, <code>--replace_string=</code> : String that will replace matches</li>
<li><code>-f</code>, <code>--target_file=</code> : File in which the string will be replaced.</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
As this helper is based on sed command, regular expressions and</br>references to sub-expressions can be used</br>(see sed manual page for more information)</br></br>Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/string#L38">Dude, show me the code !</a>
</p>
ynh_replace_special_string
Substitute/replace a special string by another in a file
<strong>Usage</strong>: <code class="helper-code">ynh_replace_special_string --match_string=match_string --replace_string=replace_string --target_file=target_file</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-m</code>, <code>--match_string=</code> : String to be searched and replaced in the file</li>
<li><code>-r</code>, <code>--replace_string=</code> : String that will replace matches</li>
<li><code>-t</code>, <code>--target_file=</code> : File in which the string will be replaced.</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
This helper will use ynh_replace_string, but as you can use special</br>characters, you can't use some regular expressions and sub-expressions.</br></br>Requires YunoHost version 2.7.7 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/string#L67">Dude, show me the code !</a>
</p>
ynh_sanitize_dbid
Sanitize a string intended to be the name of a database (More specifically : replace - and . by _)
<strong>Usage</strong>: <code class="helper-code">ynh_sanitize_dbid --db_name=name</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-n</code>, <code>--db_name=</code> : name to correct/sanitize</li>
</ul>
</p>
<p>
<strong>Returns</strong>: the corrected name
</p>
<p>
<strong>Example</strong>: <code class="helper-code">dbname=$(ynh_sanitize_dbid $app)</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/string#L98">Dude, show me the code !</a>
</p>
systemd
ynh_add_systemd_config
Create a dedicated systemd config
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_add_systemd_config [--service=service] [--template=template]
ynh_add_systemd_config [--service=service] [--template=template] [--others_var="list of others variables to replace"]
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-s</code>, <code>--service=</code> : Service name (optionnal, $app by default)</li>
<li><code>-t</code>, <code>--template=</code> : Name of template file (optionnal, this is 'systemd' by default, meaning ./conf/systemd.service will be used as template)</li>
<li><code>-v</code>, <code>--others_var=</code> : List of others variables to replace separated by a space. For example: 'var_1 var_2 ...'</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
This will use the template ../conf/<templatename>.service</br>to generate a systemd config, by replacing the following keywords</br>with global variables that should be defined before calling</br>this helper :</br></br>__APP__ by $app</br> __FINALPATH__ by $final_path</br></br>And dynamic variables (from the last example) :</br> __VAR_1__ by $var_1</br> __VAR_2__ by $var_2</br></br>Requires YunoHost version 2.7.11 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/systemd#L24">Dude, show me the code !</a>
</p>
ynh_remove_systemd_config
Remove the dedicated systemd config
<strong>Usage</strong>: <code class="helper-code">ynh_remove_systemd_config [--service=service]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-s</code>, <code>--service=</code> : Service name (optionnal, $app by default)</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.7.2 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/systemd#L71">Dude, show me the code !</a>
</p>
ynh_systemd_action
Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
<strong>Usage</strong>: <code class="helper-code">ynh_systemd_action [--service_name=service_name] [--action=action] [ [--line_match="line to match"] [--log_path=log_path] [--timeout=300] [--length=20] ]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-n</code>, <code>--service_name=</code> : Name of the service to start. Default : $app</li>
<li><code>-a</code>, <code>--action=</code> : Action to perform with systemctl. Default: start</li>
<li><code>-l</code>, <code>--line_match=</code> : Line to match - The line to find in the log to attest the service have finished to boot. If not defined it don't wait until the service is completely started. WARNING: When using --line_match, you should always add `ynh_clean_check_starting` into your `ynh_clean_setup` at the beginning of the script. Otherwise, tail will not stop in case of failure of the script. The script will then hang forever.</li>
<li><code>-p</code>, <code>--log_path=</code> : Log file - Path to the log file. Default : /var/log/$app/$app.log</li>
<li><code>-t</code>, <code>--timeout=</code> : Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.</li>
<li><code>-e</code>, <code>--length=</code> : Length of the error log : Default : 20</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/systemd#L101">Dude, show me the code !</a>
</p>
ynh_clean_check_starting
Clean temporary process and file used by ynh_check_starting (usually used in ynh_clean_setup scripts)
<strong>Usage</strong>: <code class="helper-code">ynh_clean_check_starting</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/systemd#L203">Dude, show me the code !</a>
</p>
user
ynh_user_exists
Check if a YunoHost user exists
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_user_exists --username=username
| exit: Return 1 if the user doesn't exist, 0 otherwise
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--username=</code> : the username to check</li>
</ul>
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_user_exists 'toto' || exit 1</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/user#L12">Dude, show me the code !</a>
</p>
ynh_user_get_info
Retrieve a YunoHost user information
<strong>Usage</strong>: <code class="helper-code">ynh_user_get_info --username=username --key=key</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--username=</code> : the username to retrieve info from</li>
<li><code>-k</code>, <code>--key=</code> : the key to retrieve</li>
</ul>
</p>
<p>
<strong>Returns</strong>: string - the key's value
</p>
<p>
<strong>Example</strong>: <code class="helper-code">mail=$(ynh_user_get_info 'toto' 'mail')</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/user#L33">Dude, show me the code !</a>
</p>
ynh_user_list
Get the list of YunoHost users
<strong>Usage</strong>: <code class="helper-code">ynh_user_list</code>
</p>
<p>
<strong>Returns</strong>: string - one username per line
</p>
<p>
<strong>Example</strong>: <code class="helper-code">for u in $(ynh_user_list); do ...</code>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.4.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/user#L53">Dude, show me the code !</a>
</p>
ynh_system_user_exists
Check if a user exists on the system
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_system_user_exists --username=username
| exit: Return 1 if the user doesn't exist, 0 otherwise
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--username=</code> : the username to check</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.2.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/user#L65">Dude, show me the code !</a>
</p>
ynh_system_group_exists
Check if a group exists on the system
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_system_group_exists --group=group
| exit: Return 1 if the group doesn't exist, 0 otherwise
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-g</code>, <code>--group=</code> : the group to check</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.5.0.2 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/user#L83">Dude, show me the code !</a>
</p>
ynh_system_user_create
Create a system user
<strong>Usage</strong>: <code class="helper-code">ynh_system_user_create --username=user_name [--home_dir=home_dir] [--use_shell]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--username=</code> : Name of the system user that will be create</li>
<li><code>-h</code>, <code>--home_dir=</code> : Path of the home dir for the user. Usually the final path of the app. If this argument is omitted, the user will be created without home</li>
<li><code>-s</code>, <code>--use_shell</code> : Create a user using the default login shell if present. If this argument is omitted, the user will be created with /usr/sbin/nologin shell</li>
</ul>
</p>
<p>
<strong>Examples</strong>:<ul>
Create a nextcloud user with no home directory and /usr/sbin/nologin login shell (hence no login capability)
<br>
<code class="helper-code"> ynh_system_user_create --username=nextcloud</code>
<br>
Create a discourse user using /var/www/discourse as home directory and the default login shell
<br>
<code class="helper-code"> ynh_system_user_create --username=discourse --home_dir=/var/www/discourse --use_shell</code>
<br>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/user#L108">Dude, show me the code !</a>
</p>
ynh_system_user_delete
Delete a system user
<strong>Usage</strong>: <code class="helper-code">ynh_system_user_delete --username=user_name</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--username=</code> : Name of the system user that will be create</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/user#L144">Dude, show me the code !</a>
</p>
ynh_exec_as
Execute a command as another user
<strong>Usage</strong>: <code class="helper-code">ynh_exec_as --user=USER --command=COMMAND [ARG ...]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-u</code>, <code>--user=</code> : the user that will execute the command</li>
<li><code>-n</code>, <code>--command=</code> : the command to be executed</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 4.1.7 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/user#L174">Dude, show me the code !</a>
</p>
utils
ynh_abort_if_errors
Exits if an error occurs during the execution of the script.
<strong>Usage</strong>: <code class="helper-code">ynh_abort_if_errors</code>
</p>
<p>
<strong>Details</strong>:
<p>
This configure the rest of the script execution such that, if an error occurs</br>or if an empty variable is used, the execution of the script stops</br>immediately and a call to `ynh_clean_setup` is triggered if it has been</br>defined by your script.</br></br>Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/utils#L54">Dude, show me the code !</a>
</p>
ynh_setup_source
Download, check integrity, uncompress and patch the source from app.src
<strong>Usage</strong>: <code class="helper-code">ynh_setup_source --dest_dir=dest_dir [--source_id=source_id]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-d</code>, <code>--dest_dir=</code> : Directory where to setup sources</li>
<li><code>-s</code>, <code>--source_id=</code> : Name of the app, if the package contains more than one app</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
The file conf/app.src need to contains:</br></br>SOURCE_URL=Address to download the app archive</br>SOURCE_SUM=Control sum</br># (Optional) Program to check the integrity (sha256sum, md5sum...)</br># default: sha256</br>SOURCE_SUM_PRG=sha256</br># (Optional) Archive format</br># default: tar.gz</br>SOURCE_FORMAT=tar.gz</br># (Optional) Put false if sources are directly in the archive root</br># default: true</br># Instead of true, SOURCE_IN_SUBDIR could be the number of sub directories</br># to remove.</br>SOURCE_IN_SUBDIR=false</br># (Optionnal) Name of the local archive (offline setup support)</br># default: ${src_id}.${src_format}</br>SOURCE_FILENAME=example.tar.gz</br># (Optional) If it set as false don't extract the source.</br># (Useful to get a debian package or a python wheel.)</br># default: true</br>SOURCE_EXTRACT=(true|false)</br></br>Details:</br>This helper downloads sources from SOURCE_URL if there is no local source</br>archive in /opt/yunohost-apps-src/APP_ID/SOURCE_FILENAME</br></br>Next, it checks the integrity with "SOURCE_SUM_PRG -c --status" command.</br></br>If it's ok, the source archive will be uncompressed in $dest_dir. If the</br>SOURCE_IN_SUBDIR is true, the first level directory of the archive will be</br>removed.</br>If SOURCE_IN_SUBDIR is a numeric value, 2 for example, the 2 first level</br>directories will be removed</br></br>Finally, patches named sources/patches/${src_id}-*.patch and extra files in</br>sources/extra_files/$src_id will be applied to dest_dir</br></br>Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/utils#L105">Dude, show me the code !</a>
</p>
ynh_local_curl
Curl abstraction to help with POST requests to local pages (such as installation forms)
<strong>Usage</strong>: <code class="helper-code">ynh_local_curl "page_uri" "key1=value1" "key2=value2" ...</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>page_uri</code> : Path (relative to $path_url) of the page where POST data will be sent</li>
<li><code>key1=value1</code> : (Optionnal) POST key and corresponding value</li>
<li><code>key2=value2</code> : (Optionnal) Another POST key and corresponding value</li>
<li><code>...</code> : (Optionnal) More POST keys and values</li>
</ul>
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_local_curl "/install.php?installButton" "foo=$var1" "bar=$var2"</code>
</p>
<p>
<strong>Details</strong>:
<p>
For multiple calls, cookies are persisted between each call for the same app</br></br>$domain and $path_url should be defined externally (and correspond to the domain.tld and the /path (of the app?))</br></br>Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/utils#L230">Dude, show me the code !</a>
</p>
ynh_add_config
Create a dedicated config file from a template
<strong>Usage</strong>: <code class="helper-code">ynh_add_config --template="template" --destination="destination"</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-t</code>, <code>--template=</code> : Template config file to use</li>
<li><code>-d</code>, <code>--destination=</code> : Destination of the config file</li>
</ul>
</p>
<p>
<strong>Examples</strong>:<ul>
<code class="helper-code"> ynh_add_config --template=".env" --destination="$final_path/.env"</code>
<br>
<code class="helper-code"> ynh_add_config --template="../conf/.env" --destination="$final_path/.env"</code>
<br>
<code class="helper-code"> ynh_add_config --template="/etc/nginx/sites-available/default" --destination="etc/nginx/sites-available/mydomain.conf"</code>
<br>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
The template can be by default the name of a file in the conf directory</br>of a YunoHost Package, a relative path or an absolute path</br>The helper will use the template $template to generate a config file</br>$destination by replacing the following keywords with global variables</br>that should be defined before calling this helper :</br> __PATH__ by $path_url</br> __NAME__ by $app</br> __NAMETOCHANGE__ by $app</br> __USER__ by $app</br> __FINALPATH__ by $final_path</br> __PHPVERSION__ by $YNH_PHP_VERSION</br> __YNH_NODE_LOAD_PATH__ by $ynh_node_load_PATH</br></br>And any dynamic variables that should be defined before calling this helper like:</br> __DOMAIN__ by $domain</br> __APP__ by $app</br> __VAR_1__ by $var_1</br> __VAR_2__ by $var_2</br></br>The helper will verify the checksum and backup the destination file</br>if it's different before applying the new template.</br>And it will calculate and store the destination file checksum</br>into the app settings when configuration is done.</br></br>Requires YunoHost version 4.1.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/utils#L302">Dude, show me the code !</a>
</p>
ynh_get_debian_release
Fetch the Debian release codename
<strong>Usage</strong>: <code class="helper-code">ynh_get_debian_release</code>
</p>
<p>
<strong>Returns</strong>: The Debian release codename (i.e. jessie, stretch, ...)
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.7.12 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/utils#L436">Dude, show me the code !</a>
</p>
ynh_secure_remove
Remove a file or a directory securely
<strong>Usage</strong>: <code class="helper-code">ynh_secure_remove --file=path_to_remove</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-f</code>, <code>--file=</code> : File or directory to remove</li>
</ul>
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 2.6.4 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/utils#L466">Dude, show me the code !</a>
</p>
ynh_read_manifest
Read the value of a key in a ynh manifest file
<strong>Usage</strong>: <code class="helper-code">ynh_read_manifest --manifest="manifest.json" --key="key"</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-m</code>, <code>--manifest=</code> : Path of the manifest to read</li>
<li><code>-k</code>, <code>--key=</code> : Name of the key to find</li>
</ul>
</p>
<p>
<strong>Returns</strong>: the value associate to that key
</p>
<p>
<strong>Details</strong>:
<p>
Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/utils#L547">Dude, show me the code !</a>
</p>
ynh_app_upstream_version
Read the upstream version from the manifest, or from the env variable $YNH_APP_MANIFEST_VERSION if not given
<strong>Usage</strong>: <code class="helper-code">ynh_app_upstream_version [--manifest="manifest.json"]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-m</code>, <code>--manifest=</code> : Path of the manifest to read</li>
</ul>
</p>
<p>
<strong>Returns</strong>: the version number of the upstream app
</p>
<p>
<strong>Details</strong>:
<p>
The version number in the manifest is defined by <upstreamversion>~ynh<packageversion></br>For example : 4.3-2~ynh3</br>This include the number before ~ynh</br>In the last example it return 4.3-2</br></br>Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/utils#L576">Dude, show me the code !</a>
</p>
ynh_app_package_version
Read package version from the manifest
<strong>Usage</strong>: <code class="helper-code">ynh_app_package_version [--manifest="manifest.json"]</code>
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>-m</code>, <code>--manifest=</code> : Path of the manifest to read</li>
</ul>
</p>
<p>
<strong>Returns</strong>: the version number of the package
</p>
<p>
<strong>Details</strong>:
<p>
The version number in the manifest is defined by <upstreamversion>~ynh<packageversion></br>For example : 4.3-2~ynh3</br>This include the number after ~ynh</br>In the last example it return 3</br></br>Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/utils#L607">Dude, show me the code !</a>
</p>
ynh_check_app_version_changed
Checks the app version to upgrade with the existing app version and returns:
<strong>Usage</strong>: <code class="helper-code">ynh_check_app_version_changed</code>
</p>
<p>
<strong>Details</strong>:
<p>
- UPGRADE_PACKAGE if only the YunoHost package has changed</br>- UPGRADE_APP otherwise</br></br>This helper should be used to avoid an upgrade of an app, or the upstream part</br>of it, when it's not needed</br></br>To force an upgrade, even if the package is up to date,</br>you have to use the parameter --force (or -F).</br>example: sudo yunohost app upgrade MyApp --force</br></br>Requires YunoHost version 3.5.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/utils#L634">Dude, show me the code !</a>
</p>
ynh_compare_current_package_version
Compare the current package version against another version given as an argument. This is really useful when we need to do some actions only for some old package versions.
<strong>Usage</strong>: <code class="helper-code helper-usage">ynh_compare_current_package_version --comparison lt|le|eq|ne|ge|gt
| eq (equal), ne (not equal), ge (greater or equal), gt (greater than)
</p>
<p>
<strong>Arguments</strong>:
<ul>
<li><code>--comparison</code> : Comparison type. Could be : lt (lower than), le (lower or equal),</li>
<li><code>--version</code> : The version to compare. Need to be a version in the yunohost package version type (like 2.3.1~ynh4)</li>
</ul>
</p>
<p>
<strong>Example</strong>: <code class="helper-code">ynh_compare_current_package_version --comparison lt --version 2.3.2~ynh1 This example will check if the installed version is lower than (lt) the version 2.3.2~ynh1</code>
</p>
<p>
<strong>Details</strong>:
<p>
Generally you might probably use it as follow in the upgrade script</br></br>if ynh_compare_current_package_version --comparison lt --version 2.3.2~ynh1</br>then</br> # Do something that is needed for the package version older than 2.3.2~ynh1</br>fi</br></br>Return 0 if the evaluation is true. 1 if false.</br></br>Requires YunoHost version 3.8.0 or higher.</br></br>
</p>
</p>
<p>
<a href="https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/utils#L666">Dude, show me the code !</a>
</p>