mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
helpers 2.1: rework argument parsing comment to improve readability, consistency
This commit is contained in:
parent
0915a6a70b
commit
aa6634fd22
22 changed files with 202 additions and 195 deletions
|
@ -7,11 +7,11 @@
|
||||||
#
|
#
|
||||||
# Requires YunoHost version *.*.* or higher.
|
# Requires YunoHost version *.*.* or higher.
|
||||||
ynh_install_apps() {
|
ynh_install_apps() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([a]=apps=)
|
local -A args_array=([a]=apps=)
|
||||||
local apps
|
local apps
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Split the list of apps in an array
|
# Split the list of apps in an array
|
||||||
local apps_list=($(echo $apps | tr " " "\n"))
|
local apps_list=($(echo $apps | tr " " "\n"))
|
||||||
|
@ -125,11 +125,11 @@ ynh_remove_apps() {
|
||||||
# from the app's service configuration file (defaults to $app.service, overridable by the packager with `service` setting).
|
# from the app's service configuration file (defaults to $app.service, overridable by the packager with `service` setting).
|
||||||
# If the app relies on a specific PHP version, then `php` will be aliased that version. The PHP command will also be appended with the `phpflags` settings.
|
# If the app relies on a specific PHP version, then `php` will be aliased that version. The PHP command will also be appended with the `phpflags` settings.
|
||||||
ynh_spawn_app_shell() {
|
ynh_spawn_app_shell() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([a]=app=)
|
local -A args_array=([a]=app=)
|
||||||
local app
|
local app
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Force Bash to be used to run this helper
|
# Force Bash to be used to run this helper
|
||||||
if [[ ! $0 =~ \/?bash$ ]]
|
if [[ ! $0 =~ \/?bash$ ]]
|
||||||
|
|
|
@ -68,11 +68,11 @@ ynh_package_is_installed() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_package_version() {
|
ynh_package_version() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([p]=package=)
|
local -A args_array=([p]=package=)
|
||||||
local package
|
local package
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if ynh_package_is_installed "$package"; then
|
if ynh_package_is_installed "$package"; then
|
||||||
dpkg-query --show --showformat='${Version}' "$package" 2>/dev/null
|
dpkg-query --show --showformat='${Version}' "$package" 2>/dev/null
|
||||||
|
@ -344,11 +344,11 @@ EOF
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.8.1 or higher.
|
# Requires YunoHost version 3.8.1 or higher.
|
||||||
ynh_add_app_dependencies() {
|
ynh_add_app_dependencies() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([p]=package= [r]=replace)
|
local -A args_array=([p]=package= [r]=replace)
|
||||||
local package
|
local package
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
ynh_print_warn --message="Packagers: ynh_add_app_dependencies is deprecated and is now only an alias to ynh_install_app_dependencies"
|
ynh_print_warn --message="Packagers: ynh_add_app_dependencies is deprecated and is now only an alias to ynh_install_app_dependencies"
|
||||||
ynh_install_app_dependencies "${package}"
|
ynh_install_app_dependencies "${package}"
|
||||||
|
@ -400,16 +400,16 @@ ynh_remove_app_dependencies() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.8.1 or higher.
|
# Requires YunoHost version 3.8.1 or higher.
|
||||||
ynh_install_extra_app_dependencies() {
|
ynh_install_extra_app_dependencies() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([r]=repo= [p]=package= [k]=key= [n]=name=)
|
local -A args_array=([r]=repo= [p]=package= [k]=key= [n]=name=)
|
||||||
local repo
|
local repo
|
||||||
local package
|
local package
|
||||||
local key
|
local key
|
||||||
local name
|
local name
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
name="${name:-$app}"
|
name="${name:-$app}"
|
||||||
key=${key:-}
|
key=${key:-}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Set a key only if asked
|
# Set a key only if asked
|
||||||
if [ -n "$key" ]; then
|
if [ -n "$key" ]; then
|
||||||
|
@ -444,19 +444,19 @@ ynh_install_extra_app_dependencies() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.8.1 or higher.
|
# Requires YunoHost version 3.8.1 or higher.
|
||||||
ynh_install_extra_repo() {
|
ynh_install_extra_repo() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append)
|
local -A args_array=([r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append)
|
||||||
local repo
|
local repo
|
||||||
local key
|
local key
|
||||||
local priority
|
local priority
|
||||||
local name
|
local name
|
||||||
local append
|
local append
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
name="${name:-$app}"
|
name="${name:-$app}"
|
||||||
append=${append:-0}
|
append=${append:-0}
|
||||||
key=${key:-}
|
key=${key:-}
|
||||||
priority=${priority:-}
|
priority=${priority:-}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [ $append -eq 1 ]; then
|
if [ $append -eq 1 ]; then
|
||||||
append="--append"
|
append="--append"
|
||||||
|
@ -512,12 +512,12 @@ ynh_install_extra_repo() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.8.1 or higher.
|
# Requires YunoHost version 3.8.1 or higher.
|
||||||
ynh_remove_extra_repo() {
|
ynh_remove_extra_repo() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([n]=name=)
|
local -A args_array=([n]=name=)
|
||||||
local name
|
local name
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
name="${name:-$app}"
|
name="${name:-$app}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
ynh_secure_remove --file="/etc/apt/sources.list.d/$name.list"
|
ynh_secure_remove --file="/etc/apt/sources.list.d/$name.list"
|
||||||
# Sury pinning is managed by the regenconf in the core...
|
# Sury pinning is managed by the regenconf in the core...
|
||||||
|
@ -552,17 +552,17 @@ ynh_remove_extra_repo() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.8.1 or higher.
|
# Requires YunoHost version 3.8.1 or higher.
|
||||||
ynh_add_repo() {
|
ynh_add_repo() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append)
|
local -A args_array=([u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append)
|
||||||
local uri
|
local uri
|
||||||
local suite
|
local suite
|
||||||
local component
|
local component
|
||||||
local name
|
local name
|
||||||
local append
|
local append
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
name="${name:-$app}"
|
name="${name:-$app}"
|
||||||
append=${append:-0}
|
append=${append:-0}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [ $append -eq 1 ]; then
|
if [ $append -eq 1 ]; then
|
||||||
append="tee --append"
|
append="tee --append"
|
||||||
|
@ -591,19 +591,19 @@ ynh_add_repo() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.8.1 or higher.
|
# Requires YunoHost version 3.8.1 or higher.
|
||||||
ynh_pin_repo() {
|
ynh_pin_repo() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append)
|
local -A args_array=([p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append)
|
||||||
local package
|
local package
|
||||||
local pin
|
local pin
|
||||||
local priority
|
local priority
|
||||||
local name
|
local name
|
||||||
local append
|
local append
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
package="${package:-*}"
|
package="${package:-*}"
|
||||||
priority=${priority:-50}
|
priority=${priority:-50}
|
||||||
name="${name:-$app}"
|
name="${name:-$app}"
|
||||||
append=${append:-0}
|
append=${append:-0}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [ $append -eq 1 ]; then
|
if [ $append -eq 1 ]; then
|
||||||
append="tee --append"
|
append="tee --append"
|
||||||
|
|
|
@ -64,17 +64,17 @@ CAN_BIND=${CAN_BIND:-1}
|
||||||
ynh_backup() {
|
ynh_backup() {
|
||||||
# TODO find a way to avoid injection by file strange naming !
|
# TODO find a way to avoid injection by file strange naming !
|
||||||
|
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([s]=src_path= [d]=dest_path= [b]=is_big [m]=not_mandatory)
|
local -A args_array=([s]=src_path= [d]=dest_path= [b]=is_big [m]=not_mandatory)
|
||||||
local src_path
|
local src_path
|
||||||
local dest_path
|
local dest_path
|
||||||
local is_big
|
local is_big
|
||||||
local not_mandatory
|
local not_mandatory
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
dest_path="${dest_path:-}"
|
dest_path="${dest_path:-}"
|
||||||
is_big="${is_big:-0}"
|
is_big="${is_big:-0}"
|
||||||
not_mandatory="${not_mandatory:-0}"
|
not_mandatory="${not_mandatory:-0}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
BACKUP_CORE_ONLY=${BACKUP_CORE_ONLY:-0}
|
BACKUP_CORE_ONLY=${BACKUP_CORE_ONLY:-0}
|
||||||
test -n "${app:-}" && do_not_backup_data=$(ynh_app_setting_get --key=do_not_backup_data)
|
test -n "${app:-}" && do_not_backup_data=$(ynh_app_setting_get --key=do_not_backup_data)
|
||||||
|
@ -235,17 +235,17 @@ with open(sys.argv[1], 'r') as backup_file:
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
# Requires YunoHost version 3.5.0 or higher for the argument --not_mandatory
|
# Requires YunoHost version 3.5.0 or higher for the argument --not_mandatory
|
||||||
ynh_restore_file() {
|
ynh_restore_file() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([o]=origin_path= [d]=dest_path= [m]=not_mandatory)
|
local -A args_array=([o]=origin_path= [d]=dest_path= [m]=not_mandatory)
|
||||||
local origin_path
|
local origin_path
|
||||||
local dest_path
|
local dest_path
|
||||||
local not_mandatory
|
local not_mandatory
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
origin_path="/${origin_path#/}"
|
origin_path="/${origin_path#/}"
|
||||||
# Default value for dest_path = /$origin_path
|
# Default value for dest_path = /$origin_path
|
||||||
dest_path="${dest_path:-$origin_path}"
|
dest_path="${dest_path:-$origin_path}"
|
||||||
not_mandatory="${not_mandatory:-0}"
|
not_mandatory="${not_mandatory:-0}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
local archive_path="$YNH_CWD${origin_path}"
|
local archive_path="$YNH_CWD${origin_path}"
|
||||||
# If archive_path doesn't exist, search for a corresponding path in CSV
|
# If archive_path doesn't exist, search for a corresponding path in CSV
|
||||||
|
@ -302,14 +302,13 @@ ynh_restore_file() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_store_file_checksum() {
|
ynh_store_file_checksum() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([f]=file= [u]=update_only)
|
local -A args_array=([f]=file= [u]=update_only)
|
||||||
local file
|
local file
|
||||||
local update_only
|
local update_only
|
||||||
update_only="${update_only:-0}"
|
update_only="${update_only:-0}"
|
||||||
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||||
|
|
||||||
|
@ -352,11 +351,11 @@ ynh_store_file_checksum() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_backup_if_checksum_is_different() {
|
ynh_backup_if_checksum_is_different() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([f]=file=)
|
local -A args_array=([f]=file=)
|
||||||
local file
|
local file
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||||
local checksum_value=$(ynh_app_setting_get --key=$checksum_setting_name)
|
local checksum_value=$(ynh_app_setting_get --key=$checksum_setting_name)
|
||||||
|
@ -391,11 +390,11 @@ ynh_backup_if_checksum_is_different() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.3.1 or higher.
|
# Requires YunoHost version 3.3.1 or higher.
|
||||||
ynh_delete_file_checksum() {
|
ynh_delete_file_checksum() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([f]=file=)
|
local -A args_array=([f]=file=)
|
||||||
local file
|
local file
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||||
ynh_app_setting_delete --key=$checksum_setting_name
|
ynh_app_setting_delete --key=$checksum_setting_name
|
||||||
|
|
|
@ -58,18 +58,18 @@
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 4.1.0 or higher.
|
# Requires YunoHost version 4.1.0 or higher.
|
||||||
ynh_add_fail2ban_config() {
|
ynh_add_fail2ban_config() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([l]=logpath= [r]=failregex= [m]=max_retry= [p]=ports= [t]=use_template)
|
local -A args_array=([l]=logpath= [r]=failregex= [m]=max_retry= [p]=ports= [t]=use_template)
|
||||||
local logpath
|
local logpath
|
||||||
local failregex
|
local failregex
|
||||||
local max_retry
|
local max_retry
|
||||||
local ports
|
local ports
|
||||||
local use_template
|
local use_template
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
max_retry=${max_retry:-3}
|
max_retry=${max_retry:-3}
|
||||||
ports=${ports:-http,https}
|
ports=${ports:-http,https}
|
||||||
use_template="${use_template:-0}"
|
use_template="${use_template:-0}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [ "$use_template" -ne 1 ]; then
|
if [ "$use_template" -ne 1 ]; then
|
||||||
# Usage 1, no template. Build a config file from scratch.
|
# Usage 1, no template. Build a config file from scratch.
|
||||||
|
|
|
@ -94,11 +94,11 @@ ynh_use_go () {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.2 or higher.
|
# Requires YunoHost version 3.2.2 or higher.
|
||||||
ynh_install_go () {
|
ynh_install_go () {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [v]=go_version= )
|
local -A args_array=( [v]=go_version= )
|
||||||
local go_version
|
local go_version
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Load goenv path in PATH
|
# Load goenv path in PATH
|
||||||
local CLEAR_PATH="$goenv_install_dir/bin:$PATH"
|
local CLEAR_PATH="$goenv_install_dir/bin:$PATH"
|
||||||
|
|
|
@ -13,18 +13,18 @@
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.8.1 or higher.
|
# Requires YunoHost version 3.8.1 or higher.
|
||||||
ynh_get_ram() {
|
ynh_get_ram() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([f]=free [t]=total [s]=ignore_swap [o]=only_swap)
|
local -A args_array=([f]=free [t]=total [s]=ignore_swap [o]=only_swap)
|
||||||
local free
|
local free
|
||||||
local total
|
local total
|
||||||
local ignore_swap
|
local ignore_swap
|
||||||
local only_swap
|
local only_swap
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
ignore_swap=${ignore_swap:-0}
|
ignore_swap=${ignore_swap:-0}
|
||||||
only_swap=${only_swap:-0}
|
only_swap=${only_swap:-0}
|
||||||
free=${free:-0}
|
free=${free:-0}
|
||||||
total=${total:-0}
|
total=${total:-0}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [ $free -eq $total ]; then
|
if [ $free -eq $total ]; then
|
||||||
ynh_print_warn --message="You have to choose --free or --total when using ynh_get_ram"
|
ynh_print_warn --message="You have to choose --free or --total when using ynh_get_ram"
|
||||||
|
@ -76,14 +76,13 @@ ynh_get_ram() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.8.1 or higher.
|
# Requires YunoHost version 3.8.1 or higher.
|
||||||
ynh_require_ram() {
|
ynh_require_ram() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([r]=required= [f]=free [t]=total [s]=ignore_swap [o]=only_swap)
|
local -A args_array=([r]=required= [f]=free [t]=total [s]=ignore_swap [o]=only_swap)
|
||||||
local required
|
local required
|
||||||
local free
|
local free
|
||||||
local total
|
local total
|
||||||
local ignore_swap
|
local ignore_swap
|
||||||
local only_swap
|
local only_swap
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
# Dunno if that's the right way to do, but that's some black magic to be able to
|
# Dunno if that's the right way to do, but that's some black magic to be able to
|
||||||
# forward the bool args to ynh_get_ram easily?
|
# forward the bool args to ynh_get_ram easily?
|
||||||
|
@ -92,6 +91,7 @@ ynh_require_ram() {
|
||||||
total=${total:+--total}
|
total=${total:+--total}
|
||||||
ignore_swap=${ignore_swap:+--ignore_swap}
|
ignore_swap=${ignore_swap:+--ignore_swap}
|
||||||
only_swap=${only_swap:+--only_swap}
|
only_swap=${only_swap:+--only_swap}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
local ram=$(ynh_get_ram $free $total $ignore_swap $only_swap)
|
local ram=$(ynh_get_ram $free $total $ignore_swap $only_swap)
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.4.0 or higher.
|
# Requires YunoHost version 2.4.0 or higher.
|
||||||
ynh_die() {
|
ynh_die() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([m]=message= [c]=ret_code=)
|
local -A args_array=([m]=message= [c]=ret_code=)
|
||||||
local message
|
local message
|
||||||
local ret_code
|
local ret_code
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
ret_code=${ret_code:-1}
|
ret_code=${ret_code:-1}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
echo "$message" 1>&2
|
echo "$message" 1>&2
|
||||||
exit "$ret_code"
|
exit "$ret_code"
|
||||||
|
@ -27,11 +27,11 @@ ynh_die() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.0 or higher.
|
# Requires YunoHost version 3.2.0 or higher.
|
||||||
ynh_print_info() {
|
ynh_print_info() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([m]=message=)
|
local -A args_array=([m]=message=)
|
||||||
local message
|
local message
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
echo "$message" >&$YNH_STDINFO
|
echo "$message" >&$YNH_STDINFO
|
||||||
}
|
}
|
||||||
|
@ -52,11 +52,11 @@ ynh_print_log() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.0 or higher.
|
# Requires YunoHost version 3.2.0 or higher.
|
||||||
ynh_print_warn() {
|
ynh_print_warn() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([m]=message=)
|
local -A args_array=([m]=message=)
|
||||||
local message
|
local message
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
ynh_print_log "${message}" >&2
|
ynh_print_log "${message}" >&2
|
||||||
}
|
}
|
||||||
|
@ -68,11 +68,11 @@ ynh_print_warn() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.0 or higher.
|
# Requires YunoHost version 3.2.0 or higher.
|
||||||
ynh_print_err() {
|
ynh_print_err() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([m]=message=)
|
local -A args_array=([m]=message=)
|
||||||
local message
|
local message
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
ynh_print_log "[Error] ${message}" >&2
|
ynh_print_log "[Error] ${message}" >&2
|
||||||
}
|
}
|
||||||
|
@ -252,17 +252,19 @@ base_time=$(date +%s)
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
# Requires YunoHost version 3.5.0 or higher.
|
||||||
ynh_script_progression() {
|
ynh_script_progression() {
|
||||||
set +o xtrace # set +x
|
set +o xtrace # set +x
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([m]=message= [w]=weight= [t]=time [l]=last)
|
local -A args_array=([m]=message= [w]=weight= [t]=time [l]=last)
|
||||||
local message
|
local message
|
||||||
local weight
|
local weight
|
||||||
local time
|
local time
|
||||||
local last
|
local last
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
weight=${weight:-1}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Re-disable xtrace, ynh_handle_getopts_args set it back
|
# Re-disable xtrace, ynh_handle_getopts_args set it back
|
||||||
set +o xtrace # set +x
|
set +o xtrace # set +x
|
||||||
weight=${weight:-1}
|
|
||||||
|
|
||||||
# Always activate time when running inside CI tests
|
# Always activate time when running inside CI tests
|
||||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||||
|
|
|
@ -26,13 +26,14 @@ ynh_use_logrotate() {
|
||||||
done
|
done
|
||||||
set -- "${all_args[@]}"
|
set -- "${all_args[@]}"
|
||||||
|
|
||||||
# Argument parsing
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([l]=logfile= [u]=specific_user=)
|
local -A args_array=([l]=logfile= [u]=specific_user=)
|
||||||
local logfile
|
local logfile
|
||||||
local specific_user
|
local specific_user
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
logfile="${logfile:-}"
|
logfile="${logfile:-}"
|
||||||
specific_user="${specific_user:-}"
|
specific_user="${specific_user:-}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
set -o noglob
|
set -o noglob
|
||||||
if [[ -z "$logfile" ]]; then
|
if [[ -z "$logfile" ]]; then
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_exec() {
|
ynh_mongo_exec() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [u]=user= [p]=password= [a]=authenticationdatabase= [d]=database= [h]=host= [P]=port= [c]=command= [e]=eval )
|
local -A args_array=( [u]=user= [p]=password= [a]=authenticationdatabase= [d]=database= [h]=host= [P]=port= [c]=command= [e]=eval )
|
||||||
local user
|
local user
|
||||||
local password
|
local password
|
||||||
|
@ -27,7 +27,6 @@ ynh_mongo_exec() {
|
||||||
local port
|
local port
|
||||||
local command
|
local command
|
||||||
local eval
|
local eval
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
user="${user:-}"
|
user="${user:-}"
|
||||||
password="${password:-}"
|
password="${password:-}"
|
||||||
|
@ -36,6 +35,7 @@ ynh_mongo_exec() {
|
||||||
host="${host:-}"
|
host="${host:-}"
|
||||||
port="${port:-}"
|
port="${port:-}"
|
||||||
eval=${eval:-0}
|
eval=${eval:-0}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# If user is provided
|
# If user is provided
|
||||||
if [ -n "$user" ]
|
if [ -n "$user" ]
|
||||||
|
@ -113,11 +113,11 @@ EOF
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_drop_db() {
|
ynh_mongo_drop_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [d]=database= )
|
local -A args_array=( [d]=database= )
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
ynh_mongo_exec --database="$database" --command='db.runCommand({dropDatabase: 1})'
|
ynh_mongo_exec --database="$database" --command='db.runCommand({dropDatabase: 1})'
|
||||||
}
|
}
|
||||||
|
@ -132,11 +132,11 @@ ynh_mongo_drop_db() {
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_dump_db() {
|
ynh_mongo_dump_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [d]=database= )
|
local -A args_array=( [d]=database= )
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
mongodump --quiet --db="$database" --archive
|
mongodump --quiet --db="$database" --archive
|
||||||
}
|
}
|
||||||
|
@ -152,13 +152,13 @@ ynh_mongo_dump_db() {
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_create_user() {
|
ynh_mongo_create_user() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
|
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
local db_pwd
|
local db_pwd
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Create the user and set the user as admin of the db
|
# Create the user and set the user as admin of the db
|
||||||
ynh_mongo_exec --database="$db_name" --command='db.createUser( { user: "'${db_user}'", pwd: "'${db_pwd}'", roles: [ { role: "readWrite", db: "'${db_name}'" } ] } );'
|
ynh_mongo_exec --database="$db_name" --command='db.createUser( { user: "'${db_user}'", pwd: "'${db_pwd}'", roles: [ { role: "readWrite", db: "'${db_name}'" } ] } );'
|
||||||
|
@ -175,11 +175,11 @@ ynh_mongo_create_user() {
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_database_exists() {
|
ynh_mongo_database_exists() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([d]=database=)
|
local -A args_array=([d]=database=)
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")' --eval) -lt 0 ]
|
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")' --eval) -lt 0 ]
|
||||||
then
|
then
|
||||||
|
@ -198,11 +198,11 @@ ynh_mongo_database_exists() {
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_restore_db() {
|
ynh_mongo_restore_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [d]=database= )
|
local -A args_array=( [d]=database= )
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
mongorestore --quiet --db="$database" --archive
|
mongorestore --quiet --db="$database" --archive
|
||||||
}
|
}
|
||||||
|
@ -217,12 +217,12 @@ ynh_mongo_restore_db() {
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_drop_user() {
|
ynh_mongo_drop_user() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [u]=db_user= [n]=db_name= )
|
local -A args_array=( [u]=db_user= [n]=db_name= )
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
ynh_mongo_exec --database="$db_name" --command='db.dropUser("'$db_user'", {w: "majority", wtimeout: 5000})'
|
ynh_mongo_exec --database="$db_name" --command='db.dropUser("'$db_user'", {w: "majority", wtimeout: 5000})'
|
||||||
}
|
}
|
||||||
|
@ -239,13 +239,13 @@ ynh_mongo_drop_user() {
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_setup_db() {
|
ynh_mongo_setup_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
|
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
db_pwd=""
|
db_pwd=""
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
local new_db_pwd=$(ynh_string_random) # Generate a random password
|
local new_db_pwd=$(ynh_string_random) # Generate a random password
|
||||||
# If $db_pwd is not provided, use new_db_pwd instead for db_pwd
|
# If $db_pwd is not provided, use new_db_pwd instead for db_pwd
|
||||||
|
@ -266,12 +266,12 @@ ynh_mongo_setup_db() {
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_remove_db() {
|
ynh_mongo_remove_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [u]=db_user= [n]=db_name= )
|
local -A args_array=( [u]=db_user= [n]=db_name= )
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if ynh_mongo_database_exists --database=$db_name; then # Check if the database exists
|
if ynh_mongo_database_exists --database=$db_name; then # Check if the database exists
|
||||||
ynh_mongo_drop_db --database=$db_name # Remove the database
|
ynh_mongo_drop_db --database=$db_name # Remove the database
|
||||||
|
@ -290,12 +290,12 @@ ynh_mongo_remove_db() {
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_install_mongo() {
|
ynh_install_mongo() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([m]=mongo_version=)
|
local -A args_array=([m]=mongo_version=)
|
||||||
local mongo_version
|
local mongo_version
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
mongo_version="${mongo_version:-$YNH_MONGO_VERSION}"
|
mongo_version="${mongo_version:-$YNH_MONGO_VERSION}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
ynh_print_info --message="Installing MongoDB Community Edition ..."
|
ynh_print_info --message="Installing MongoDB Community Edition ..."
|
||||||
local mongo_debian_release=$(ynh_get_debian_release)
|
local mongo_debian_release=$(ynh_get_debian_release)
|
||||||
|
|
|
@ -63,12 +63,12 @@ ynh_multimedia_build_main_dir() {
|
||||||
# Requires YunoHost version 4.2 or higher.
|
# Requires YunoHost version 4.2 or higher.
|
||||||
ynh_multimedia_addfolder() {
|
ynh_multimedia_addfolder() {
|
||||||
|
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([s]=source_dir= [d]=dest_dir=)
|
local -A args_array=([s]=source_dir= [d]=dest_dir=)
|
||||||
local source_dir
|
local source_dir
|
||||||
local dest_dir
|
local dest_dir
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Ajout d'un lien symbolique vers le dossier à partager
|
# Ajout d'un lien symbolique vers le dossier à partager
|
||||||
ln -sfn "$source_dir" "$MEDIA_DIRECTORY/$dest_dir"
|
ln -sfn "$source_dir" "$MEDIA_DIRECTORY/$dest_dir"
|
||||||
|
@ -90,11 +90,12 @@ ynh_multimedia_addfolder() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 4.2 or higher.
|
# Requires YunoHost version 4.2 or higher.
|
||||||
ynh_multimedia_addaccess() {
|
ynh_multimedia_addaccess() {
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
declare -Ar args_array=([u]=user_name=)
|
# ============ Argument parsing =============
|
||||||
|
local -A args_array=([u]=user_name=)
|
||||||
local user_name
|
local user_name
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
groupadd -f multimedia
|
groupadd -f multimedia
|
||||||
usermod -a -G multimedia $user_name
|
usermod -a -G multimedia $user_name
|
||||||
|
|
|
@ -13,14 +13,14 @@
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_mysql_connect_as() {
|
ynh_mysql_connect_as() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=user= [p]=password= [d]=database=)
|
local -A args_array=([u]=user= [p]=password= [d]=database=)
|
||||||
local user
|
local user
|
||||||
local password
|
local password
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
database="${database:-}"
|
database="${database:-}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
mysql --user="$user" --password="$password" --batch "$database"
|
mysql --user="$user" --password="$password" --batch "$database"
|
||||||
}
|
}
|
||||||
|
@ -33,13 +33,13 @@ ynh_mysql_connect_as() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_mysql_execute_as_root() {
|
ynh_mysql_execute_as_root() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([s]=sql= [d]=database=)
|
local -A args_array=([s]=sql= [d]=database=)
|
||||||
local sql
|
local sql
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
database="${database:-}"
|
database="${database:-}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [ -n "$database" ]; then
|
if [ -n "$database" ]; then
|
||||||
database="--database=$database"
|
database="--database=$database"
|
||||||
|
@ -56,13 +56,13 @@ ynh_mysql_execute_as_root() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_mysql_execute_file_as_root() {
|
ynh_mysql_execute_file_as_root() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([f]=file= [d]=database=)
|
local -A args_array=([f]=file= [d]=database=)
|
||||||
local file
|
local file
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
database="${database:-}"
|
database="${database:-}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [ -n "$database" ]; then
|
if [ -n "$database" ]; then
|
||||||
database="--database=$database"
|
database="--database=$database"
|
||||||
|
@ -123,11 +123,11 @@ ynh_mysql_drop_db() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_mysql_dump_db() {
|
ynh_mysql_dump_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([d]=database=)
|
local -A args_array=([d]=database=)
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
mysqldump --single-transaction --skip-dump-date --routines "$database"
|
mysqldump --single-transaction --skip-dump-date --routines "$database"
|
||||||
}
|
}
|
||||||
|
@ -156,11 +156,11 @@ ynh_mysql_create_user() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_mysql_user_exists() {
|
ynh_mysql_user_exists() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=user=)
|
local -A args_array=([u]=user=)
|
||||||
local user
|
local user
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [[ -z $(ynh_mysql_execute_as_root --sql="SELECT User from mysql.user WHERE User = '$user';") ]]; then
|
if [[ -z $(ynh_mysql_execute_as_root --sql="SELECT User from mysql.user WHERE User = '$user';") ]]; then
|
||||||
return 1
|
return 1
|
||||||
|
@ -195,13 +195,13 @@ ynh_mysql_drop_user() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_mysql_setup_db() {
|
ynh_mysql_setup_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=db_user= [n]=db_name= [p]=db_pwd=)
|
local -A args_array=([u]=db_user= [n]=db_name= [p]=db_pwd=)
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
db_pwd=""
|
db_pwd=""
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Generate a random password
|
# Generate a random password
|
||||||
local new_db_pwd=$(ynh_string_random)
|
local new_db_pwd=$(ynh_string_random)
|
||||||
|
@ -225,12 +225,12 @@ ynh_mysql_setup_db() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_mysql_remove_db() {
|
ynh_mysql_remove_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -Ar args_array=([u]=db_user= [n]=db_name=)
|
local -Ar args_array=([u]=db_user= [n]=db_name=)
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if mysqlshow | grep -q "^| $db_name "; then
|
if mysqlshow | grep -q "^| $db_name "; then
|
||||||
ynh_mysql_drop_db $db_name
|
ynh_mysql_drop_db $db_name
|
||||||
|
|
|
@ -12,11 +12,11 @@
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_find_port() {
|
ynh_find_port() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([p]=port=)
|
local -A args_array=([p]=port=)
|
||||||
local port
|
local port
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
test -n "$port" || ynh_die --message="The argument of ynh_find_port must be a valid port."
|
test -n "$port" || ynh_die --message="The argument of ynh_find_port must be a valid port."
|
||||||
while ! ynh_port_available --port=$port; do
|
while ! ynh_port_available --port=$port; do
|
||||||
|
@ -37,11 +37,11 @@ ynh_find_port() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.8.0 or higher.
|
# Requires YunoHost version 3.8.0 or higher.
|
||||||
ynh_port_available() {
|
ynh_port_available() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([p]=port=)
|
local -A args_array=([p]=port=)
|
||||||
local port
|
local port
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Check if the port is free
|
# Check if the port is free
|
||||||
if ss --numeric --listening --tcp --udp | awk '{print$5}' | grep --quiet --extended-regexp ":$port$"; then
|
if ss --numeric --listening --tcp --udp | awk '{print$5}' | grep --quiet --extended-regexp ":$port$"; then
|
||||||
|
@ -67,12 +67,12 @@ ynh_port_available() {
|
||||||
ynh_validate_ip() {
|
ynh_validate_ip() {
|
||||||
# http://stackoverflow.com/questions/319279/how-to-validate-ip-address-in-python#319298
|
# http://stackoverflow.com/questions/319279/how-to-validate-ip-address-in-python#319298
|
||||||
|
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([f]=family= [i]=ip_address=)
|
local -A args_array=([f]=family= [i]=ip_address=)
|
||||||
local family
|
local family
|
||||||
local ip_address
|
local ip_address
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
[ "$family" == "4" ] || [ "$family" == "6" ] || return 1
|
[ "$family" == "4" ] || [ "$family" == "6" ] || return 1
|
||||||
|
|
||||||
|
@ -98,11 +98,11 @@ EOF
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_validate_ip4() {
|
ynh_validate_ip4() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([i]=ip_address=)
|
local -A args_array=([i]=ip_address=)
|
||||||
local ip_address
|
local ip_address
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
ynh_validate_ip --family=4 --ip_address=$ip_address
|
ynh_validate_ip --family=4 --ip_address=$ip_address
|
||||||
}
|
}
|
||||||
|
@ -117,11 +117,11 @@ ynh_validate_ip4() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_validate_ip6() {
|
ynh_validate_ip6() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([i]=ip_address=)
|
local -A args_array=([i]=ip_address=)
|
||||||
local ip_address
|
local ip_address
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
ynh_validate_ip --family=6 --ip_address=$ip_address
|
ynh_validate_ip --family=6 --ip_address=$ip_address
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,11 +94,11 @@ ynh_use_nodejs() {
|
||||||
ynh_install_nodejs() {
|
ynh_install_nodejs() {
|
||||||
# Use n, https://github.com/tj/n to manage the nodejs versions
|
# Use n, https://github.com/tj/n to manage the nodejs versions
|
||||||
|
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([n]=nodejs_version=)
|
local -A args_array=([n]=nodejs_version=)
|
||||||
local nodejs_version
|
local nodejs_version
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Create $n_install_dir
|
# Create $n_install_dir
|
||||||
mkdir --parents "$n_install_dir"
|
mkdir --parents "$n_install_dir"
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.7.0 or higher.
|
# Requires YunoHost version 3.7.0 or higher.
|
||||||
ynh_permission_create() {
|
ynh_permission_create() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([p]=permission= [u]=url= [A]=additional_urls= [h]=auth_header= [a]=allowed= [l]=label= [t]=show_tile= [P]=protected=)
|
local -A args_array=([p]=permission= [u]=url= [A]=additional_urls= [h]=auth_header= [a]=allowed= [l]=label= [t]=show_tile= [P]=protected=)
|
||||||
local permission
|
local permission
|
||||||
local url
|
local url
|
||||||
|
@ -84,6 +84,7 @@ ynh_permission_create() {
|
||||||
label=${label:-}
|
label=${label:-}
|
||||||
show_tile=${show_tile:-}
|
show_tile=${show_tile:-}
|
||||||
protected=${protected:-}
|
protected=${protected:-}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [[ -n $url ]]; then
|
if [[ -n $url ]]; then
|
||||||
url=",url='$url'"
|
url=",url='$url'"
|
||||||
|
@ -153,10 +154,11 @@ ynh_permission_create() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.7.0 or higher.
|
# Requires YunoHost version 3.7.0 or higher.
|
||||||
ynh_permission_delete() {
|
ynh_permission_delete() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([p]=permission=)
|
local -A args_array=([p]=permission=)
|
||||||
local permission
|
local permission
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
yunohost tools shell -c "from yunohost.permission import permission_delete; permission_delete('$app.$permission')"
|
yunohost tools shell -c "from yunohost.permission import permission_delete; permission_delete('$app.$permission')"
|
||||||
}
|
}
|
||||||
|
@ -171,10 +173,11 @@ ynh_permission_delete() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.7.0 or higher.
|
# Requires YunoHost version 3.7.0 or higher.
|
||||||
ynh_permission_exists() {
|
ynh_permission_exists() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([p]=permission=)
|
local -A args_array=([p]=permission=)
|
||||||
local permission
|
local permission
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
yunohost user permission list "$app" --output-as json --quiet \
|
yunohost user permission list "$app" --output-as json --quiet \
|
||||||
| jq -e --arg perm "$app.$permission" '.permissions[$perm]' >/dev/null
|
| jq -e --arg perm "$app.$permission" '.permissions[$perm]' >/dev/null
|
||||||
|
@ -195,7 +198,7 @@ ynh_permission_exists() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.7.0 or higher.
|
# Requires YunoHost version 3.7.0 or higher.
|
||||||
ynh_permission_url() {
|
ynh_permission_url() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([p]=permission= [u]=url= [a]=add_url= [r]=remove_url= [h]=auth_header= [c]=clear_urls)
|
local -A args_array=([p]=permission= [u]=url= [a]=add_url= [r]=remove_url= [h]=auth_header= [c]=clear_urls)
|
||||||
local permission
|
local permission
|
||||||
local url
|
local url
|
||||||
|
@ -209,6 +212,7 @@ ynh_permission_url() {
|
||||||
remove_url=${remove_url:-}
|
remove_url=${remove_url:-}
|
||||||
auth_header=${auth_header:-}
|
auth_header=${auth_header:-}
|
||||||
clear_urls=${clear_urls:-}
|
clear_urls=${clear_urls:-}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [[ -n $url ]]; then
|
if [[ -n $url ]]; then
|
||||||
url=",url='$url'"
|
url=",url='$url'"
|
||||||
|
@ -264,7 +268,7 @@ ynh_permission_url() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.7.0 or higher.
|
# Requires YunoHost version 3.7.0 or higher.
|
||||||
ynh_permission_update() {
|
ynh_permission_update() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([p]=permission= [a]=add= [r]=remove= [l]=label= [t]=show_tile= [P]=protected=)
|
local -A args_array=([p]=permission= [a]=add= [r]=remove= [l]=label= [t]=show_tile= [P]=protected=)
|
||||||
local permission
|
local permission
|
||||||
local add
|
local add
|
||||||
|
@ -278,6 +282,7 @@ ynh_permission_update() {
|
||||||
label=${label:-}
|
label=${label:-}
|
||||||
show_tile=${show_tile:-}
|
show_tile=${show_tile:-}
|
||||||
protected=${protected:-}
|
protected=${protected:-}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [[ -n $add ]]; then
|
if [[ -n $add ]]; then
|
||||||
# Convert a list from getopts to python list
|
# Convert a list from getopts to python list
|
||||||
|
@ -332,12 +337,12 @@ ynh_permission_update() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.7.1 or higher.
|
# Requires YunoHost version 3.7.1 or higher.
|
||||||
ynh_permission_has_user() {
|
ynh_permission_has_user() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([p]=permission= [u]=user=)
|
local -A args_array=([p]=permission= [u]=user=)
|
||||||
local permission
|
local permission
|
||||||
local user
|
local user
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if ! ynh_permission_exists --permission=$permission; then
|
if ! ynh_permission_exists --permission=$permission; then
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -68,16 +68,16 @@ YNH_PHP_VERSION=${YNH_PHP_VERSION:-$YNH_DEFAULT_PHP_VERSION}
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 4.1.0 or higher.
|
# Requires YunoHost version 4.1.0 or higher.
|
||||||
ynh_add_fpm_config() {
|
ynh_add_fpm_config() {
|
||||||
|
# ============ Argument parsing =============
|
||||||
local _globalphpversion=${phpversion-:}
|
local _globalphpversion=${phpversion-:}
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local -A args_array=([v]=phpversion= [u]=usage= [f]=footprint= [g]=group=)
|
local -A args_array=([v]=phpversion= [u]=usage= [f]=footprint= [g]=group=)
|
||||||
local group
|
local group
|
||||||
local phpversion
|
local phpversion
|
||||||
local usage
|
local usage
|
||||||
local footprint
|
local footprint
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
group=${group:-}
|
group=${group:-}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# The default behaviour is to use the template.
|
# The default behaviour is to use the template.
|
||||||
local autogenconf=false
|
local autogenconf=false
|
||||||
|
@ -242,12 +242,11 @@ ynh_remove_fpm_config() {
|
||||||
#
|
#
|
||||||
# | arg: -p, --print - Print the result (intended for debug purpose only when packaging the app)
|
# | arg: -p, --print - Print the result (intended for debug purpose only when packaging the app)
|
||||||
ynh_get_scalable_phpfpm() {
|
ynh_get_scalable_phpfpm() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=usage= [f]=footprint= [p]=print)
|
local -A args_array=([u]=usage= [f]=footprint= [p]=print)
|
||||||
local usage
|
local usage
|
||||||
local footprint
|
local footprint
|
||||||
local print
|
local print
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
# Set all characters as lowercase
|
# Set all characters as lowercase
|
||||||
footprint=${footprint,,}
|
footprint=${footprint,,}
|
||||||
|
@ -372,13 +371,12 @@ YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION}
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 4.2 or higher.
|
# Requires YunoHost version 4.2 or higher.
|
||||||
ynh_composer_exec() {
|
ynh_composer_exec() {
|
||||||
|
# ============ Argument parsing =============
|
||||||
local _globalphpversion=${phpversion-:}
|
local _globalphpversion=${phpversion-:}
|
||||||
# Declare an array to define the options of this helper.
|
local -A args_array=([v]=phpversion= [w]=workdir= [c]=commands=)
|
||||||
declare -Ar args_array=([v]=phpversion= [w]=workdir= [c]=commands=)
|
|
||||||
local phpversion
|
local phpversion
|
||||||
local workdir
|
local workdir
|
||||||
local commands
|
local commands
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
workdir="${workdir:-${install_dir:-$final_path}}"
|
workdir="${workdir:-${install_dir:-$final_path}}"
|
||||||
|
|
||||||
|
@ -403,15 +401,16 @@ ynh_composer_exec() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 4.2 or higher.
|
# Requires YunoHost version 4.2 or higher.
|
||||||
ynh_install_composer() {
|
ynh_install_composer() {
|
||||||
|
# ============ Argument parsing =============
|
||||||
local _globalphpversion=${phpversion-:}
|
local _globalphpversion=${phpversion-:}
|
||||||
# Declare an array to define the options of this helper.
|
local -A args_array=([v]=phpversion= [w]=workdir= [a]=install_args= [c]=composerversion=)
|
||||||
declare -Ar args_array=([v]=phpversion= [w]=workdir= [a]=install_args= [c]=composerversion=)
|
|
||||||
local phpversion
|
local phpversion
|
||||||
local workdir
|
local workdir
|
||||||
local install_args
|
local install_args
|
||||||
local composerversion
|
local composerversion
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if dpkg --compare-versions ${YNH_APP_PACKAGING_FORMAT:-0} lt 2; then
|
if dpkg --compare-versions ${YNH_APP_PACKAGING_FORMAT:-0} lt 2; then
|
||||||
workdir="${workdir:-$final_path}"
|
workdir="${workdir:-$final_path}"
|
||||||
else
|
else
|
||||||
|
|
|
@ -16,14 +16,14 @@ PSQL_VERSION=13
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
# Requires YunoHost version 3.5.0 or higher.
|
||||||
ynh_psql_connect_as() {
|
ynh_psql_connect_as() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=user= [p]=password= [d]=database=)
|
local -A args_array=([u]=user= [p]=password= [d]=database=)
|
||||||
local user
|
local user
|
||||||
local password
|
local password
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
database="${database:-}"
|
database="${database:-}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
sudo --login --user=postgres PGUSER="$user" PGPASSWORD="$password" psql "$database"
|
sudo --login --user=postgres PGUSER="$user" PGPASSWORD="$password" psql "$database"
|
||||||
}
|
}
|
||||||
|
@ -36,13 +36,13 @@ ynh_psql_connect_as() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
# Requires YunoHost version 3.5.0 or higher.
|
||||||
ynh_psql_execute_as_root() {
|
ynh_psql_execute_as_root() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([s]=sql= [d]=database=)
|
local -A args_array=([s]=sql= [d]=database=)
|
||||||
local sql
|
local sql
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
database="${database:-}"
|
database="${database:-}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [ -n "$database" ]; then
|
if [ -n "$database" ]; then
|
||||||
database="--database=$database"
|
database="--database=$database"
|
||||||
|
@ -60,13 +60,13 @@ ynh_psql_execute_as_root() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
# Requires YunoHost version 3.5.0 or higher.
|
||||||
ynh_psql_execute_file_as_root() {
|
ynh_psql_execute_file_as_root() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([f]=file= [d]=database=)
|
local -A args_array=([f]=file= [d]=database=)
|
||||||
local file
|
local file
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
database="${database:-}"
|
database="${database:-}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [ -n "$database" ]; then
|
if [ -n "$database" ]; then
|
||||||
database="--database=$database"
|
database="--database=$database"
|
||||||
|
@ -130,11 +130,11 @@ ynh_psql_drop_db() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
# Requires YunoHost version 3.5.0 or higher.
|
||||||
ynh_psql_dump_db() {
|
ynh_psql_dump_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([d]=database=)
|
local -A args_array=([d]=database=)
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
sudo --login --user=postgres pg_dump "$database"
|
sudo --login --user=postgres pg_dump "$database"
|
||||||
}
|
}
|
||||||
|
@ -164,11 +164,11 @@ ynh_psql_create_user() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
# Requires YunoHost version 3.5.0 or higher.
|
||||||
ynh_psql_user_exists() {
|
ynh_psql_user_exists() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=user=)
|
local -A args_array=([u]=user=)
|
||||||
local user
|
local user
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if ! sudo --login --user=postgres PGUSER="postgres" PGPASSWORD="$(cat $PSQL_ROOT_PWD_FILE)" psql -tAc "SELECT rolname FROM pg_roles WHERE rolname='$user';" | grep --quiet "$user"; then
|
if ! sudo --login --user=postgres PGUSER="postgres" PGPASSWORD="$(cat $PSQL_ROOT_PWD_FILE)" psql -tAc "SELECT rolname FROM pg_roles WHERE rolname='$user';" | grep --quiet "$user"; then
|
||||||
return 1
|
return 1
|
||||||
|
@ -185,11 +185,11 @@ ynh_psql_user_exists() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
# Requires YunoHost version 3.5.0 or higher.
|
||||||
ynh_psql_database_exists() {
|
ynh_psql_database_exists() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([d]=database=)
|
local -A args_array=([d]=database=)
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# if psql is not there, we cannot check the db
|
# if psql is not there, we cannot check the db
|
||||||
# though it could exists.
|
# though it could exists.
|
||||||
|
@ -230,13 +230,13 @@ ynh_psql_drop_user() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.7.13 or higher.
|
# Requires YunoHost version 2.7.13 or higher.
|
||||||
ynh_psql_setup_db() {
|
ynh_psql_setup_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=db_user= [n]=db_name= [p]=db_pwd=)
|
local -A args_array=([u]=db_user= [n]=db_name= [p]=db_pwd=)
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
db_pwd=""
|
db_pwd=""
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if ! ynh_psql_user_exists --user=$db_user; then
|
if ! ynh_psql_user_exists --user=$db_user; then
|
||||||
local new_db_pwd=$(ynh_string_random) # Generate a random password
|
local new_db_pwd=$(ynh_string_random) # Generate a random password
|
||||||
|
@ -262,12 +262,12 @@ ynh_psql_setup_db() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.7.13 or higher.
|
# Requires YunoHost version 2.7.13 or higher.
|
||||||
ynh_psql_remove_db() {
|
ynh_psql_remove_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=db_user= [n]=db_name=)
|
local -A args_array=([u]=db_user= [n]=db_name=)
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if ynh_psql_database_exists --database=$db_name; then # Check if the database exists
|
if ynh_psql_database_exists --database=$db_name; then # Check if the database exists
|
||||||
ynh_psql_drop_db $db_name # Remove the database
|
ynh_psql_drop_db $db_name # Remove the database
|
||||||
|
|
|
@ -96,11 +96,11 @@ ynh_use_ruby () {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.2 or higher.
|
# Requires YunoHost version 3.2.2 or higher.
|
||||||
ynh_install_ruby () {
|
ynh_install_ruby () {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [v]=ruby_version= )
|
local -A args_array=( [v]=ruby_version= )
|
||||||
local ruby_version
|
local ruby_version
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Load rbenv path in PATH
|
# Load rbenv path in PATH
|
||||||
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
||||||
|
|
|
@ -8,14 +8,14 @@
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_app_setting_get() {
|
ynh_app_setting_get() {
|
||||||
|
# ============ Argument parsing =============
|
||||||
local _globalapp=${app-:}
|
local _globalapp=${app-:}
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local -A args_array=([a]=app= [k]=key=)
|
local -A args_array=([a]=app= [k]=key=)
|
||||||
local app
|
local app
|
||||||
local key
|
local key
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
app="${app:-$_globalapp}"
|
app="${app:-$_globalapp}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
ynh_app_setting "get" "$app" "$key"
|
ynh_app_setting "get" "$app" "$key"
|
||||||
}
|
}
|
||||||
|
@ -29,15 +29,15 @@ ynh_app_setting_get() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_app_setting_set() {
|
ynh_app_setting_set() {
|
||||||
|
# ============ Argument parsing =============
|
||||||
local _globalapp=${app-:}
|
local _globalapp=${app-:}
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local -A args_array=([a]=app= [k]=key= [v]=value=)
|
local -A args_array=([a]=app= [k]=key= [v]=value=)
|
||||||
local app
|
local app
|
||||||
local key
|
local key
|
||||||
local value
|
local value
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
app="${app:-$_globalapp}"
|
app="${app:-$_globalapp}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
ynh_app_setting "set" "$app" "$key" "$value"
|
ynh_app_setting "set" "$app" "$key" "$value"
|
||||||
}
|
}
|
||||||
|
@ -50,14 +50,14 @@ ynh_app_setting_set() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_app_setting_delete() {
|
ynh_app_setting_delete() {
|
||||||
|
# ============ Argument parsing =============
|
||||||
local _globalapp=${app-:}
|
local _globalapp=${app-:}
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local -A args_array=([a]=app= [k]=key=)
|
local -A args_array=([a]=app= [k]=key=)
|
||||||
local app
|
local app
|
||||||
local key
|
local key
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
app="${app:-$_globalapp}"
|
app="${app:-$_globalapp}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
ynh_app_setting "delete" "$app" "$key"
|
ynh_app_setting "delete" "$app" "$key"
|
||||||
}
|
}
|
||||||
|
@ -108,12 +108,12 @@ EOF
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_webpath_available() {
|
ynh_webpath_available() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([d]=domain= [p]=path_url=)
|
local -A args_array=([d]=domain= [p]=path_url=)
|
||||||
local domain
|
local domain
|
||||||
local path_url
|
local path_url
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
yunohost domain url-available $domain $path_url
|
yunohost domain url-available $domain $path_url
|
||||||
}
|
}
|
||||||
|
@ -131,13 +131,13 @@ ynh_webpath_available() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_webpath_register() {
|
ynh_webpath_register() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([a]=app= [d]=domain= [p]=path_url=)
|
local -A args_array=([a]=app= [d]=domain= [p]=path_url=)
|
||||||
local app
|
local app
|
||||||
local domain
|
local domain
|
||||||
local path_url
|
local path_url
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
yunohost app register-url $app $domain $path_url
|
yunohost app register-url $app $domain $path_url
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,14 @@
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_string_random() {
|
ynh_string_random() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([l]=length= [f]=filter=)
|
local -A args_array=([l]=length= [f]=filter=)
|
||||||
local length
|
local length
|
||||||
local filter
|
local filter
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
length=${length:-24}
|
length=${length:-24}
|
||||||
filter=${filter:-'A-Za-z0-9'}
|
filter=${filter:-'A-Za-z0-9'}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
dd if=/dev/urandom bs=1 count=1000 2>/dev/null \
|
dd if=/dev/urandom bs=1 count=1000 2>/dev/null \
|
||||||
| tr --complement --delete "$filter" \
|
| tr --complement --delete "$filter" \
|
||||||
|
@ -37,13 +37,13 @@ ynh_string_random() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_replace_string() {
|
ynh_replace_string() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([m]=match_string= [r]=replace_string= [f]=target_file=)
|
local -A args_array=([m]=match_string= [r]=replace_string= [f]=target_file=)
|
||||||
local match_string
|
local match_string
|
||||||
local replace_string
|
local replace_string
|
||||||
local target_file
|
local target_file
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
set +o xtrace # set +x
|
set +o xtrace # set +x
|
||||||
|
|
||||||
local delimit=$'\001'
|
local delimit=$'\001'
|
||||||
|
@ -67,13 +67,13 @@ ynh_replace_string() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.7.7 or higher.
|
# Requires YunoHost version 2.7.7 or higher.
|
||||||
ynh_replace_special_string() {
|
ynh_replace_special_string() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([m]=match_string= [r]=replace_string= [f]=target_file=)
|
local -A args_array=([m]=match_string= [r]=replace_string= [f]=target_file=)
|
||||||
local match_string
|
local match_string
|
||||||
local replace_string
|
local replace_string
|
||||||
local target_file
|
local target_file
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Escape any backslash to preserve them as simple backslash.
|
# Escape any backslash to preserve them as simple backslash.
|
||||||
match_string=${match_string//\\/"\\\\"}
|
match_string=${match_string//\\/"\\\\"}
|
||||||
|
@ -100,11 +100,11 @@ ynh_replace_special_string() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_sanitize_dbid() {
|
ynh_sanitize_dbid() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([n]=db_name=)
|
local -A args_array=([n]=db_name=)
|
||||||
local db_name
|
local db_name
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# We should avoid having - and . in the name of databases. They are replaced by _
|
# We should avoid having - and . in the name of databases. They are replaced by _
|
||||||
echo ${db_name//[-.]/_}
|
echo ${db_name//[-.]/_}
|
||||||
|
@ -129,11 +129,11 @@ ynh_sanitize_dbid() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_normalize_url_path() {
|
ynh_normalize_url_path() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([p]=path_url=)
|
local -A args_array=([p]=path_url=)
|
||||||
local path_url
|
local path_url
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
test -n "$path_url" || ynh_die --message="ynh_normalize_url_path expect a URL path as first argument and received nothing."
|
test -n "$path_url" || ynh_die --message="ynh_normalize_url_path expect a URL path as first argument and received nothing."
|
||||||
if [ "${path_url:0:1}" != "/" ]; then # If the first character is not a /
|
if [ "${path_url:0:1}" != "/" ]; then # If the first character is not a /
|
||||||
|
|
|
@ -13,14 +13,14 @@
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 4.1.0 or higher.
|
# Requires YunoHost version 4.1.0 or higher.
|
||||||
ynh_add_systemd_config() {
|
ynh_add_systemd_config() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([s]=service= [t]=template=)
|
local -A args_array=([s]=service= [t]=template=)
|
||||||
local service
|
local service
|
||||||
local template
|
local template
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
service="${service:-$app}"
|
service="${service:-$app}"
|
||||||
template="${template:-systemd.service}"
|
template="${template:-systemd.service}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
ynh_add_config --template="$template" --destination="/etc/systemd/system/$service.service"
|
ynh_add_config --template="$template" --destination="/etc/systemd/system/$service.service"
|
||||||
|
|
||||||
|
@ -35,12 +35,12 @@ ynh_add_systemd_config() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.7.2 or higher.
|
# Requires YunoHost version 2.7.2 or higher.
|
||||||
ynh_remove_systemd_config() {
|
ynh_remove_systemd_config() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([s]=service=)
|
local -A args_array=([s]=service=)
|
||||||
local service
|
local service
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
local service="${service:-$app}"
|
local service="${service:-$app}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
local finalsystemdconf="/etc/systemd/system/$service.service"
|
local finalsystemdconf="/etc/systemd/system/$service.service"
|
||||||
if [ -e "$finalsystemdconf" ]; then
|
if [ -e "$finalsystemdconf" ]; then
|
||||||
|
@ -63,7 +63,7 @@ ynh_remove_systemd_config() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
# Requires YunoHost version 3.5.0 or higher.
|
||||||
ynh_systemd_action() {
|
ynh_systemd_action() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length=)
|
local -A args_array=([n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length=)
|
||||||
local service_name
|
local service_name
|
||||||
local action
|
local action
|
||||||
|
@ -71,7 +71,6 @@ ynh_systemd_action() {
|
||||||
local length
|
local length
|
||||||
local log_path
|
local log_path
|
||||||
local timeout
|
local timeout
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
service_name="${service_name:-$app}"
|
service_name="${service_name:-$app}"
|
||||||
action=${action:-start}
|
action=${action:-start}
|
||||||
|
@ -79,6 +78,7 @@ ynh_systemd_action() {
|
||||||
length=${length:-20}
|
length=${length:-20}
|
||||||
log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
||||||
timeout=${timeout:-300}
|
timeout=${timeout:-300}
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Manage case of service already stopped
|
# Manage case of service already stopped
|
||||||
if [ "$action" == "stop" ] && ! systemctl is-active --quiet $service_name; then
|
if [ "$action" == "stop" ] && ! systemctl is-active --quiet $service_name; then
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_user_exists() {
|
ynh_user_exists() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=username=)
|
local -A args_array=([u]=username=)
|
||||||
local username
|
local username
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
yunohost user list --output-as json --quiet | jq -e ".users.\"${username}\"" >/dev/null
|
yunohost user list --output-as json --quiet | jq -e ".users.\"${username}\"" >/dev/null
|
||||||
}
|
}
|
||||||
|
@ -30,12 +30,12 @@ ynh_user_exists() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_user_get_info() {
|
ynh_user_get_info() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=username= [k]=key=)
|
local -A args_array=([u]=username= [k]=key=)
|
||||||
local username
|
local username
|
||||||
local key
|
local key
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
yunohost user info "$username" --output-as json --quiet | jq -r ".$key"
|
yunohost user info "$username" --output-as json --quiet | jq -r ".$key"
|
||||||
}
|
}
|
||||||
|
@ -62,11 +62,11 @@ ynh_user_list() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.2.4 or higher.
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
ynh_system_user_exists() {
|
ynh_system_user_exists() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=username=)
|
local -A args_array=([u]=username=)
|
||||||
local username
|
local username
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
getent passwd "$username" &>/dev/null
|
getent passwd "$username" &>/dev/null
|
||||||
}
|
}
|
||||||
|
@ -81,11 +81,11 @@ ynh_system_user_exists() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.5.0.2 or higher.
|
# Requires YunoHost version 3.5.0.2 or higher.
|
||||||
ynh_system_group_exists() {
|
ynh_system_group_exists() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([g]=group=)
|
local -A args_array=([g]=group=)
|
||||||
local group
|
local group
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
getent group "$group" &>/dev/null
|
getent group "$group" &>/dev/null
|
||||||
}
|
}
|
||||||
|
@ -111,18 +111,17 @@ ynh_system_group_exists() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_system_user_create() {
|
ynh_system_user_create() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=username= [h]=home_dir= [s]=use_shell [g]=groups=)
|
local -A args_array=([u]=username= [h]=home_dir= [s]=use_shell [g]=groups=)
|
||||||
local username
|
local username
|
||||||
local home_dir
|
local home_dir
|
||||||
local use_shell
|
local use_shell
|
||||||
local groups
|
local groups
|
||||||
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
use_shell="${use_shell:-0}"
|
use_shell="${use_shell:-0}"
|
||||||
home_dir="${home_dir:-}"
|
home_dir="${home_dir:-}"
|
||||||
groups="${groups:-}"
|
groups="${groups:-}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if ! ynh_system_user_exists --username="$username"; then # Check if the user exists on the system
|
if ! ynh_system_user_exists --username="$username"; then # Check if the user exists on the system
|
||||||
# If the user doesn't exist
|
# If the user doesn't exist
|
||||||
|
@ -154,11 +153,11 @@ ynh_system_user_create() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_system_user_delete() {
|
ynh_system_user_delete() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([u]=username=)
|
local -A args_array=([u]=username=)
|
||||||
local username
|
local username
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Check if the user exists on the system
|
# Check if the user exists on the system
|
||||||
if ynh_system_user_exists --username="$username"; then
|
if ynh_system_user_exists --username="$username"; then
|
||||||
|
|
|
@ -137,18 +137,18 @@ fi
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_setup_source() {
|
ynh_setup_source() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([d]=dest_dir= [s]=source_id= [k]=keep= [r]=full_replace=)
|
local -A args_array=([d]=dest_dir= [s]=source_id= [k]=keep= [r]=full_replace=)
|
||||||
local dest_dir
|
local dest_dir
|
||||||
local source_id
|
local source_id
|
||||||
local keep
|
local keep
|
||||||
local full_replace
|
local full_replace
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
keep="${keep:-}"
|
keep="${keep:-}"
|
||||||
full_replace="${full_replace:-0}"
|
full_replace="${full_replace:-0}"
|
||||||
|
|
||||||
source_id="${source_id:-main}"
|
source_id="${source_id:-main}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
local sources_json=$(cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq ".resources.sources[\"$source_id\"]")
|
local sources_json=$(cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq ".resources.sources[\"$source_id\"]")
|
||||||
if jq -re ".url" <<< "$sources_json"
|
if jq -re ".url" <<< "$sources_json"
|
||||||
then
|
then
|
||||||
|
@ -448,13 +448,13 @@ ynh_local_curl() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 4.1.0 or higher.
|
# Requires YunoHost version 4.1.0 or higher.
|
||||||
ynh_add_config() {
|
ynh_add_config() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([t]=template= [d]=destination=)
|
local -A args_array=([t]=template= [d]=destination=)
|
||||||
local template
|
local template
|
||||||
local destination
|
local destination
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
local template_path
|
local template_path
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [ -f "$YNH_APP_BASEDIR/conf/$template" ]; then
|
if [ -f "$YNH_APP_BASEDIR/conf/$template" ]; then
|
||||||
template_path="$YNH_APP_BASEDIR/conf/$template"
|
template_path="$YNH_APP_BASEDIR/conf/$template"
|
||||||
|
@ -506,11 +506,11 @@ ynh_add_config() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 4.1.0 or higher.
|
# Requires YunoHost version 4.1.0 or higher.
|
||||||
ynh_replace_vars() {
|
ynh_replace_vars() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([f]=file=)
|
local -A args_array=([f]=file=)
|
||||||
local file
|
local file
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
# Replace specific YunoHost variables
|
# Replace specific YunoHost variables
|
||||||
if test -n "${path_url:-}"; then
|
if test -n "${path_url:-}"; then
|
||||||
|
@ -591,14 +591,14 @@ ynh_replace_vars() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 4.3 or higher.
|
# Requires YunoHost version 4.3 or higher.
|
||||||
ynh_read_var_in_file() {
|
ynh_read_var_in_file() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([f]=file= [k]=key= [a]=after=)
|
local -A args_array=([f]=file= [k]=key= [a]=after=)
|
||||||
local file
|
local file
|
||||||
local key
|
local key
|
||||||
local after
|
local after
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
after="${after:-}"
|
after="${after:-}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
[[ -f $file ]] || ynh_die --message="File $file does not exists"
|
[[ -f $file ]] || ynh_die --message="File $file does not exists"
|
||||||
|
|
||||||
|
@ -668,15 +668,15 @@ ynh_read_var_in_file() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 4.3 or higher.
|
# Requires YunoHost version 4.3 or higher.
|
||||||
ynh_write_var_in_file() {
|
ynh_write_var_in_file() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([f]=file= [k]=key= [v]=value= [a]=after=)
|
local -A args_array=([f]=file= [k]=key= [v]=value= [a]=after=)
|
||||||
local file
|
local file
|
||||||
local key
|
local key
|
||||||
local value
|
local value
|
||||||
local after
|
local after
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
after="${after:-}"
|
after="${after:-}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
[[ -f $file ]] || ynh_die --message="File $file does not exists"
|
[[ -f $file ]] || ynh_die --message="File $file does not exists"
|
||||||
|
|
||||||
|
@ -815,11 +815,11 @@ _acceptable_path_to_delete() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_secure_remove() {
|
ynh_secure_remove() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([f]=file=)
|
local -A args_array=([f]=file=)
|
||||||
local file
|
local file
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
set +o xtrace # set +x
|
set +o xtrace # set +x
|
||||||
|
|
||||||
if [ $# -ge 2 ]; then
|
if [ $# -ge 2 ]; then
|
||||||
|
@ -848,12 +848,12 @@ ynh_secure_remove() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
# Requires YunoHost version 3.5.0 or higher.
|
||||||
ynh_read_manifest() {
|
ynh_read_manifest() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([m]=manifest= [k]=manifest_key=)
|
local -A args_array=([m]=manifest= [k]=manifest_key=)
|
||||||
local manifest
|
local manifest
|
||||||
local manifest_key
|
local manifest_key
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [ ! -e "${manifest:-}" ]; then
|
if [ ! -e "${manifest:-}" ]; then
|
||||||
# If the manifest isn't found, try the common place for backup and restore script.
|
# If the manifest isn't found, try the common place for backup and restore script.
|
||||||
|
@ -890,12 +890,12 @@ ynh_read_manifest() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
# Requires YunoHost version 3.5.0 or higher.
|
||||||
ynh_app_upstream_version() {
|
ynh_app_upstream_version() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([m]=manifest=)
|
local -A args_array=([m]=manifest=)
|
||||||
local manifest
|
local manifest
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
manifest="${manifest:-}"
|
manifest="${manifest:-}"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
if [[ "$manifest" != "" ]] && [[ -e "$manifest" ]]; then
|
if [[ "$manifest" != "" ]] && [[ -e "$manifest" ]]; then
|
||||||
version_key_=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
|
version_key_=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
|
||||||
|
@ -920,11 +920,11 @@ ynh_app_upstream_version() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
# Requires YunoHost version 3.5.0 or higher.
|
||||||
ynh_app_package_version() {
|
ynh_app_package_version() {
|
||||||
# Declare an array to define the options of this helper.
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([m]=manifest=)
|
local -A args_array=([m]=manifest=)
|
||||||
local manifest
|
local manifest
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
version_key_=$YNH_APP_MANIFEST_VERSION
|
version_key_=$YNH_APP_MANIFEST_VERSION
|
||||||
echo "${version_key_/*~ynh/}"
|
echo "${version_key_/*~ynh/}"
|
||||||
|
@ -970,11 +970,12 @@ ynh_check_app_version_changed() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.8.0 or higher.
|
# Requires YunoHost version 3.8.0 or higher.
|
||||||
ynh_compare_current_package_version() {
|
ynh_compare_current_package_version() {
|
||||||
declare -Ar args_array=([c]=comparison= [v]=version=)
|
# ============ Argument parsing =============
|
||||||
|
local -A args_array=([c]=comparison= [v]=version=)
|
||||||
local version
|
local version
|
||||||
local comparison
|
local comparison
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
# ===========================================
|
||||||
|
|
||||||
local current_version=$YNH_APP_CURRENT_VERSION
|
local current_version=$YNH_APP_CURRENT_VERSION
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue