mirror of
https://github.com/YunoHost-Apps/flohmarkt_ynh.git
synced 2024-09-03 18:36:30 +02:00
Merge pull request #22 from YunoHost-Apps/testing
cleaning linter messages
This commit is contained in:
commit
29a06fcab1
5 changed files with 44 additions and 24 deletions
|
@ -111,8 +111,8 @@ flohmarkt_old_service="flohmarkt"
|
||||||
# deprecated before the last re-design of this sub)
|
# deprecated before the last re-design of this sub)
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.2 or higher.
|
# Requires YunoHost version 3.2.2 or higher.
|
||||||
# flohmarkt_ynh_handle_getopts_args() {
|
# ynh_handle_getopts_args() {
|
||||||
ynh_handle_getopts_args() {
|
flohmarkt_ynh_handle_getopts_args() {
|
||||||
# Manage arguments only if there's some provided
|
# Manage arguments only if there's some provided
|
||||||
set +o xtrace # set +x
|
set +o xtrace # set +x
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
|
@ -365,7 +365,7 @@ ynh_handle_getopts_args() {
|
||||||
# https://github.com/YunoHost/yunohost/pull/1857
|
# https://github.com/YunoHost/yunohost/pull/1857
|
||||||
# https://github.com/YunoHost/issues/issues/2396
|
# https://github.com/YunoHost/issues/issues/2396
|
||||||
# https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/51
|
# https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/51
|
||||||
ynh_local_curl() {
|
flohmarkt_ynh_local_curl() {
|
||||||
# Curl abstraction to help with POST requests to local pages (such as installation forms)
|
# Curl abstraction to help with POST requests to local pages (such as installation forms)
|
||||||
#
|
#
|
||||||
# usage: ynh_local_curl [--option [-other_option […]]] "page" "key1=value1" "key2=value2" ...
|
# usage: ynh_local_curl [--option [-other_option […]]] "page" "key1=value1" "key2=value2" ...
|
||||||
|
@ -422,13 +422,27 @@ ynh_local_curl() {
|
||||||
local -a data
|
local -a data
|
||||||
local -a curl_opt_args # optional arguments to `curl`
|
local -a curl_opt_args # optional arguments to `curl`
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
flohmarkt_ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
# make sure method is a supported one
|
# make sure method is a supported one
|
||||||
if ! [[ -v supported_methods[$method] ]]; then
|
if ! [[ -v supported_methods[$method] ]]; then
|
||||||
ynh_die --message="method $method not supported by ynh_local_curl"
|
ynh_die --message="method $method not supported by flohmarkt_ynh_local_curl"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# linter doesn't want that the internal function is used anymore
|
||||||
|
# it's replaced here quick and dirty
|
||||||
|
flohmarkt_normalize_url_path() {
|
||||||
|
# check that $location is a valid '/path'
|
||||||
|
if [[ -n "${location}" ]]; then
|
||||||
|
if [ "${location:0:1}" != "/" ]; then
|
||||||
|
location="/${location}"
|
||||||
|
fi
|
||||||
|
if [ "${location:${#location}-1}" == "/" ]; then
|
||||||
|
location="${location:0:${#location}-1}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Define url of page to curl
|
# Define url of page to curl
|
||||||
# $location contains either an URL or just a page
|
# $location contains either an URL or just a page
|
||||||
local full_page_url
|
local full_page_url
|
||||||
|
@ -437,10 +451,12 @@ ynh_local_curl() {
|
||||||
full_page_url="$location"
|
full_page_url="$location"
|
||||||
elif [ "${path_url}" == "/" ]; then
|
elif [ "${path_url}" == "/" ]; then
|
||||||
# if $path_url points to the webserver root just append $location to localhost URL
|
# if $path_url points to the webserver root just append $location to localhost URL
|
||||||
full_page_url="https://localhost$(ynh_normalize_url_path $location)"
|
flohmarkt_normalize_url_path
|
||||||
|
full_page_url="https://localhost${location}"
|
||||||
else
|
else
|
||||||
# else append $path_url and $location to localhost URL
|
# else append $path_url and $location to localhost URL
|
||||||
full_page_url="https://localhost${path_url}$(ynh_normalize_url_path $location)"
|
flohmarkt_normalize_url_path
|
||||||
|
full_page_url="https://localhost${path_url}${location}"
|
||||||
fi
|
fi
|
||||||
flohmarkt_print_debug "full_page_url='$full_page_url'"
|
flohmarkt_print_debug "full_page_url='$full_page_url'"
|
||||||
|
|
||||||
|
@ -537,7 +553,7 @@ ynh_local_curl() {
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# debug output for ynh_handle_getopts_args and ynh_local_curl
|
# debug output for flohmarkt_ynh_handle_getopts_args and flohmarkt_ynh_local_curl
|
||||||
# otherwise not needed TODO delete after development of the two is done
|
# otherwise not needed TODO delete after development of the two is done
|
||||||
flohmarkt_debug=0
|
flohmarkt_debug=0
|
||||||
flohmarkt_print_debug() {
|
flohmarkt_print_debug() {
|
||||||
|
@ -632,14 +648,18 @@ flohmarkt_ynh_import_couchdb() {
|
||||||
}
|
}
|
||||||
|
|
||||||
flohmarkt_ynh_delete_couchdb_user() {
|
flohmarkt_ynh_delete_couchdb_user() {
|
||||||
local couchdb_user_revision=$( ynh_local_curl -n -m GET -u admin -p "$password_couchdb_admin" \
|
local couchdb_user_revision=$( flohmarkt_ynh_local_curl -n -m GET -u admin -p "$password_couchdb_admin" \
|
||||||
"http://127.0.0.1:5984/_users/org.couchdb.user%3A${app}" | jq -r ._rev )
|
"http://127.0.0.1:5984/_users/org.couchdb.user%3A${app}" | jq -r ._rev )
|
||||||
ynh_local_curl -n -m DELETE -u admin -p ${password_couchdb_admin} -l '"ok":true' \
|
if [[ -v couchdb_user_revision ]] && [[ -n "${couchdb_user_revision}" ]]; then
|
||||||
"http://127.0.0.1:5984/_users/org.couchdb.user%3A${app}?rev=${couchdb_user_revision}"
|
flohmarkt_ynh_local_curl -n -m DELETE -u admin -p ${password_couchdb_admin} -l '"ok":true' \
|
||||||
|
"http://127.0.0.1:5984/_users/org.couchdb.user%3A${app}?rev=${couchdb_user_revision}"
|
||||||
|
else
|
||||||
|
ynh_die --message "couchdb_user_revision is empty (${couchdb_user_revision})"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
flohmarkt_ynh_create_couchdb_user() {
|
flohmarkt_ynh_create_couchdb_user() {
|
||||||
ynh_local_curl -n -m PUT -u admin -p "${password_couchdb_admin}" \
|
flohmarkt_ynh_local_curl -n -m PUT -u admin -p "${password_couchdb_admin}" \
|
||||||
-H "Accept: application/json" -H "Content-Type: application/json" \
|
-H "Accept: application/json" -H "Content-Type: application/json" \
|
||||||
-d '{' \
|
-d '{' \
|
||||||
-d "\"name\": \"${app}\", \"password\": \"${password_couchdb_flohmarkt}\"," \
|
-d "\"name\": \"${app}\", \"password\": \"${password_couchdb_flohmarkt}\"," \
|
||||||
|
@ -649,7 +669,7 @@ flohmarkt_ynh_create_couchdb_user() {
|
||||||
}
|
}
|
||||||
|
|
||||||
flohmarkt_ynh_couchdb_user_permissions() {
|
flohmarkt_ynh_couchdb_user_permissions() {
|
||||||
ynh_local_curl -n -m PUT -u admin -p "$password_couchdb_admin" \
|
flohmarkt_ynh_local_curl -n -m PUT -u admin -p "$password_couchdb_admin" \
|
||||||
-H "Accept: application/json" -H "Content-Type: application/json" \
|
-H "Accept: application/json" -H "Content-Type: application/json" \
|
||||||
-d "{\"members\":{\"names\": [\"${app}\"],\"roles\": [\"editor\"]}}" \
|
-d "{\"members\":{\"names\": [\"${app}\"],\"roles\": [\"editor\"]}}" \
|
||||||
--line_match='"ok":true' \
|
--line_match='"ok":true' \
|
||||||
|
@ -657,22 +677,22 @@ flohmarkt_ynh_couchdb_user_permissions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
flohmarkt_ynh_exists_couchdb_user() {
|
flohmarkt_ynh_exists_couchdb_user() {
|
||||||
ynh_local_curl -n -m GET -u admin -p "$password_couchdb_admin" -l "\"_id\":\"org.couchdb.user:${app}\"" \
|
flohmarkt_ynh_local_curl -n -m GET -u admin -p "$password_couchdb_admin" -l "\"_id\":\"org.couchdb.user:${app}\"" \
|
||||||
"http://127.0.0.1:5984/_users/org.couchdb.user%3A${app}"
|
"http://127.0.0.1:5984/_users/org.couchdb.user%3A${app}"
|
||||||
}
|
}
|
||||||
|
|
||||||
flohmarkt_ynh_exists_couchdb_db() {
|
flohmarkt_ynh_exists_couchdb_db() {
|
||||||
ynh_local_curl -n -m GET -u admin -p "$password_couchdb_admin" -l "\"db_name\":\"${app}\"" \
|
flohmarkt_ynh_local_curl -n -m GET -u admin -p "$password_couchdb_admin" -l "\"db_name\":\"${app}\"" \
|
||||||
"http://127.0.0.1:5984/${app}"
|
"http://127.0.0.1:5984/${app}"
|
||||||
}
|
}
|
||||||
|
|
||||||
flohmarkt_ynh_delete_couchdb_db() {
|
flohmarkt_ynh_delete_couchdb_db() {
|
||||||
local legacy_args='n'
|
local legacy_args='n'
|
||||||
local -A args_array=( [n]=name= )
|
local -A args_array=( [n]=name= )
|
||||||
ynh_handle_getopts_args "$@"
|
flohmarkt_ynh_handle_getopts_args "$@"
|
||||||
local name=${name:-${app}}
|
local name=${name:-${app}}
|
||||||
|
|
||||||
ynh_local_curl -n -m DELETE -u admin -p "$password_couchdb_admin" \
|
flohmarkt_ynh_local_curl -n -m DELETE -u admin -p "$password_couchdb_admin" \
|
||||||
--line_match='"ok":true' "http://127.0.0.1:5984/${name}"
|
--line_match='"ok":true' "http://127.0.0.1:5984/${name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,10 +702,10 @@ flohmarkt_ynh_copy_couchdb() {
|
||||||
local -A args_array=( [o]=old_name= [n]=new_name= )
|
local -A args_array=( [o]=old_name= [n]=new_name= )
|
||||||
local new_name
|
local new_name
|
||||||
local old_name
|
local old_name
|
||||||
ynh_handle_getopts_args "$@"
|
flohmarkt_ynh_handle_getopts_args "$@"
|
||||||
old_name=${old_name:-${app}}
|
old_name=${old_name:-${app}}
|
||||||
|
|
||||||
ynh_local_curl -n -m POST -u admin -p "$password_couchdb_admin" \
|
flohmarkt_ynh_local_curl -n -m POST -u admin -p "$password_couchdb_admin" \
|
||||||
-H "Accept: application/json" -H "Content-Type: application/json" \
|
-H "Accept: application/json" -H "Content-Type: application/json" \
|
||||||
-d '{ "create_target":true,"source" : "' -d"${old_name}" -d'",' \
|
-d '{ "create_target":true,"source" : "' -d"${old_name}" -d'",' \
|
||||||
-d '"target":"' -d "${new_name}" -d'"}' --seperator=none \
|
-d '"target":"' -d "${new_name}" -d'"}' --seperator=none \
|
||||||
|
@ -698,7 +718,7 @@ flohmarkt_ynh_rename_couchdb() {
|
||||||
local -A args_array=( [o]=old_name= [n]=new_name= )
|
local -A args_array=( [o]=old_name= [n]=new_name= )
|
||||||
local new_name
|
local new_name
|
||||||
local old_name
|
local old_name
|
||||||
ynh_handle_getopts_args "$@"
|
flohmarkt_ynh_handle_getopts_args "$@"
|
||||||
old_name=${old_name:-${app}}
|
old_name=${old_name:-${app}}
|
||||||
|
|
||||||
flohmarkt_ynh_copy_couchdb -o "$old_name" -n "$new_name"
|
flohmarkt_ynh_copy_couchdb -o "$old_name" -n "$new_name"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/9
|
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/9
|
||||||
# check if couchdb is already installed
|
# check if couchdb is already installed
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# reinstall couchdb
|
# reinstall couchdb
|
||||||
ynh_script_progression --message="Reinstalling couchdb..." --weight=40
|
ynh_script_progression --message="Reinstalling couchdb..." --weight=40
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# UPGRADE_PACKAGE if only the YunoHost package has changed
|
# UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||||
# UPGRADE_APP if the upstream app version has changed
|
# UPGRADE_APP if the upstream app version has changed
|
||||||
|
|
Loading…
Add table
Reference in a new issue